mathematical 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -10
- data/Rakefile +42 -3
- data/lib/mathematical.rb +5 -4
- data/lib/mathematical/mathematical.bundle +0 -0
- data/lib/mathematical/render.rb +6 -5
- data/lib/mathematical/version.rb +1 -1
- data/mathematical.gemspec +5 -5
- metadata +14 -296
- data/.gitignore +0 -24
- data/.gitmodules +0 -0
- data/Gemfile +0 -4
- data/ext/mathematical/README.itex2MML.md +0 -11
- data/ext/mathematical/README.lasem.md +0 -11
- data/ext/mathematical/extconf.rb +0 -51
- data/ext/mathematical/itex2MML.h +0 -63
- data/ext/mathematical/lasemrender.c +0 -257
- data/ext/mathematical/lex.yy.c +0 -6548
- data/ext/mathematical/lsm.c +0 -30
- data/ext/mathematical/lsm.h +0 -36
- data/ext/mathematical/lsmattributes.c +0 -279
- data/ext/mathematical/lsmattributes.h +0 -75
- data/ext/mathematical/lsmcairo.c +0 -598
- data/ext/mathematical/lsmcairo.h +0 -51
- data/ext/mathematical/lsmdebug.c +0 -179
- data/ext/mathematical/lsmdebug.h +0 -76
- data/ext/mathematical/lsmdom.h +0 -43
- data/ext/mathematical/lsmdomcharacterdata.c +0 -114
- data/ext/mathematical/lsmdomcharacterdata.h +0 -59
- data/ext/mathematical/lsmdomdocument.c +0 -292
- data/ext/mathematical/lsmdomdocument.h +0 -82
- data/ext/mathematical/lsmdomdocumentfragment.c +0 -81
- data/ext/mathematical/lsmdomdocumentfragment.h +0 -55
- data/ext/mathematical/lsmdomelement.c +0 -148
- data/ext/mathematical/lsmdomelement.h +0 -62
- data/ext/mathematical/lsmdomentities.c +0 -2155
- data/ext/mathematical/lsmdomentities.h +0 -35
- data/ext/mathematical/lsmdomenumtypes.c +0 -99
- data/ext/mathematical/lsmdomenumtypes.c.template +0 -39
- data/ext/mathematical/lsmdomenumtypes.h +0 -26
- data/ext/mathematical/lsmdomenumtypes.h.template +0 -26
- data/ext/mathematical/lsmdomimplementation.c +0 -82
- data/ext/mathematical/lsmdomimplementation.h +0 -41
- data/ext/mathematical/lsmdomnamednodemap.c +0 -118
- data/ext/mathematical/lsmdomnamednodemap.h +0 -64
- data/ext/mathematical/lsmdomnode.c +0 -725
- data/ext/mathematical/lsmdomnode.h +0 -120
- data/ext/mathematical/lsmdomnodelist.c +0 -70
- data/ext/mathematical/lsmdomnodelist.h +0 -58
- data/ext/mathematical/lsmdomparser.c +0 -461
- data/ext/mathematical/lsmdomparser.h +0 -54
- data/ext/mathematical/lsmdomtext.c +0 -82
- data/ext/mathematical/lsmdomtext.h +0 -55
- data/ext/mathematical/lsmdomtypes.h +0 -44
- data/ext/mathematical/lsmdomview.c +0 -422
- data/ext/mathematical/lsmdomview.h +0 -94
- data/ext/mathematical/lsmmathml.h +0 -66
- data/ext/mathematical/lsmmathmlactionelement.c +0 -93
- data/ext/mathematical/lsmmathmlactionelement.h +0 -57
- data/ext/mathematical/lsmmathmlaligngroupelement.c +0 -102
- data/ext/mathematical/lsmmathmlaligngroupelement.h +0 -56
- data/ext/mathematical/lsmmathmlalignmarkelement.c +0 -102
- data/ext/mathematical/lsmmathmlalignmarkelement.h +0 -56
- data/ext/mathematical/lsmmathmlattributes.c +0 -197
- data/ext/mathematical/lsmmathmlattributes.h +0 -126
- data/ext/mathematical/lsmmathmldocument.c +0 -306
- data/ext/mathematical/lsmmathmldocument.h +0 -61
- data/ext/mathematical/lsmmathmlelement.c +0 -491
- data/ext/mathematical/lsmmathmlelement.h +0 -107
- data/ext/mathematical/lsmmathmlenums.c +0 -429
- data/ext/mathematical/lsmmathmlenums.h +0 -182
- data/ext/mathematical/lsmmathmlenumtypes.c +0 -666
- data/ext/mathematical/lsmmathmlenumtypes.c.template +0 -39
- data/ext/mathematical/lsmmathmlenumtypes.h +0 -90
- data/ext/mathematical/lsmmathmlenumtypes.h.template +0 -26
- data/ext/mathematical/lsmmathmlerrorelement.c +0 -58
- data/ext/mathematical/lsmmathmlerrorelement.h +0 -56
- data/ext/mathematical/lsmmathmlfencedelement.c +0 -178
- data/ext/mathematical/lsmmathmlfencedelement.h +0 -65
- data/ext/mathematical/lsmmathmlfractionelement.c +0 -253
- data/ext/mathematical/lsmmathmlfractionelement.h +0 -62
- data/ext/mathematical/lsmmathmlglyphtableams.c +0 -597
- data/ext/mathematical/lsmmathmlglyphtableams.h +0 -45
- data/ext/mathematical/lsmmathmlitexelement.c +0 -187
- data/ext/mathematical/lsmmathmlitexelement.h +0 -60
- data/ext/mathematical/lsmmathmllayoututils.c +0 -191
- data/ext/mathematical/lsmmathmllayoututils.h +0 -58
- data/ext/mathematical/lsmmathmlmathelement.c +0 -204
- data/ext/mathematical/lsmmathmlmathelement.h +0 -81
- data/ext/mathematical/lsmmathmloperatordictionary.c +0 -3332
- data/ext/mathematical/lsmmathmloperatordictionary.h +0 -54
- data/ext/mathematical/lsmmathmloperatorelement.c +0 -307
- data/ext/mathematical/lsmmathmloperatorelement.h +0 -73
- data/ext/mathematical/lsmmathmlpaddedelement.c +0 -58
- data/ext/mathematical/lsmmathmlpaddedelement.h +0 -56
- data/ext/mathematical/lsmmathmlphantomelement.c +0 -71
- data/ext/mathematical/lsmmathmlphantomelement.h +0 -56
- data/ext/mathematical/lsmmathmlpresentationcontainer.c +0 -43
- data/ext/mathematical/lsmmathmlpresentationcontainer.h +0 -54
- data/ext/mathematical/lsmmathmlpresentationtoken.c +0 -303
- data/ext/mathematical/lsmmathmlpresentationtoken.h +0 -83
- data/ext/mathematical/lsmmathmlradicalelement.c +0 -266
- data/ext/mathematical/lsmmathmlradicalelement.h +0 -71
- data/ext/mathematical/lsmmathmlrowelement.c +0 -58
- data/ext/mathematical/lsmmathmlrowelement.h +0 -56
- data/ext/mathematical/lsmmathmlscriptelement.c +0 -282
- data/ext/mathematical/lsmmathmlscriptelement.h +0 -78
- data/ext/mathematical/lsmmathmlsemanticselement.c +0 -82
- data/ext/mathematical/lsmmathmlsemanticselement.h +0 -56
- data/ext/mathematical/lsmmathmlspaceelement.c +0 -142
- data/ext/mathematical/lsmmathmlspaceelement.h +0 -60
- data/ext/mathematical/lsmmathmlstringelement.c +0 -123
- data/ext/mathematical/lsmmathmlstringelement.h +0 -58
- data/ext/mathematical/lsmmathmlstyle.c +0 -130
- data/ext/mathematical/lsmmathmlstyle.h +0 -81
- data/ext/mathematical/lsmmathmlstyleelement.c +0 -307
- data/ext/mathematical/lsmmathmlstyleelement.h +0 -87
- data/ext/mathematical/lsmmathmltablecellelement.c +0 -122
- data/ext/mathematical/lsmmathmltablecellelement.h +0 -62
- data/ext/mathematical/lsmmathmltableelement.c +0 -545
- data/ext/mathematical/lsmmathmltableelement.h +0 -78
- data/ext/mathematical/lsmmathmltablerowelement.c +0 -120
- data/ext/mathematical/lsmmathmltablerowelement.h +0 -64
- data/ext/mathematical/lsmmathmltraits.c +0 -819
- data/ext/mathematical/lsmmathmltraits.h +0 -119
- data/ext/mathematical/lsmmathmltypes.h +0 -66
- data/ext/mathematical/lsmmathmlunderoverelement.c +0 -485
- data/ext/mathematical/lsmmathmlunderoverelement.h +0 -82
- data/ext/mathematical/lsmmathmlutils.c +0 -170
- data/ext/mathematical/lsmmathmlutils.h +0 -50
- data/ext/mathematical/lsmmathmlview.c +0 -1048
- data/ext/mathematical/lsmmathmlview.h +0 -164
- data/ext/mathematical/lsmproperties.c +0 -418
- data/ext/mathematical/lsmproperties.h +0 -85
- data/ext/mathematical/lsmstr.c +0 -231
- data/ext/mathematical/lsmstr.h +0 -114
- data/ext/mathematical/lsmsvg.h +0 -67
- data/ext/mathematical/lsmsvgaelement.c +0 -73
- data/ext/mathematical/lsmsvgaelement.h +0 -55
- data/ext/mathematical/lsmsvgattributes.h +0 -113
- data/ext/mathematical/lsmsvgcircleelement.c +0 -153
- data/ext/mathematical/lsmsvgcircleelement.h +0 -59
- data/ext/mathematical/lsmsvgclippathelement.c +0 -134
- data/ext/mathematical/lsmsvgclippathelement.h +0 -59
- data/ext/mathematical/lsmsvgcolors.c +0 -212
- data/ext/mathematical/lsmsvgcolors.h +0 -39
- data/ext/mathematical/lsmsvgdefselement.c +0 -74
- data/ext/mathematical/lsmsvgdefselement.h +0 -55
- data/ext/mathematical/lsmsvgdocument.c +0 -230
- data/ext/mathematical/lsmsvgdocument.h +0 -58
- data/ext/mathematical/lsmsvgelement.c +0 -367
- data/ext/mathematical/lsmsvgelement.h +0 -81
- data/ext/mathematical/lsmsvgellipseelement.c +0 -158
- data/ext/mathematical/lsmsvgellipseelement.h +0 -60
- data/ext/mathematical/lsmsvgenums.c +0 -544
- data/ext/mathematical/lsmsvgenums.h +0 -357
- data/ext/mathematical/lsmsvgenumtypes.c +0 -1083
- data/ext/mathematical/lsmsvgenumtypes.c.template +0 -39
- data/ext/mathematical/lsmsvgenumtypes.h +0 -111
- data/ext/mathematical/lsmsvgenumtypes.h.template +0 -26
- data/ext/mathematical/lsmsvgfilterblend.c +0 -105
- data/ext/mathematical/lsmsvgfilterblend.h +0 -58
- data/ext/mathematical/lsmsvgfiltercomposite.c +0 -109
- data/ext/mathematical/lsmsvgfiltercomposite.h +0 -58
- data/ext/mathematical/lsmsvgfilterelement.c +0 -266
- data/ext/mathematical/lsmsvgfilterelement.h +0 -66
- data/ext/mathematical/lsmsvgfilterflood.c +0 -86
- data/ext/mathematical/lsmsvgfilterflood.h +0 -55
- data/ext/mathematical/lsmsvgfiltergaussianblur.c +0 -114
- data/ext/mathematical/lsmsvgfiltergaussianblur.h +0 -57
- data/ext/mathematical/lsmsvgfiltermerge.c +0 -98
- data/ext/mathematical/lsmsvgfiltermerge.h +0 -55
- data/ext/mathematical/lsmsvgfiltermergenode.c +0 -87
- data/ext/mathematical/lsmsvgfiltermergenode.h +0 -57
- data/ext/mathematical/lsmsvgfilteroffset.c +0 -112
- data/ext/mathematical/lsmsvgfilteroffset.h +0 -58
- data/ext/mathematical/lsmsvgfilterprimitive.c +0 -168
- data/ext/mathematical/lsmsvgfilterprimitive.h +0 -66
- data/ext/mathematical/lsmsvgfilterspecularlighting.c +0 -127
- data/ext/mathematical/lsmsvgfilterspecularlighting.h +0 -60
- data/ext/mathematical/lsmsvgfiltersurface.c +0 -455
- data/ext/mathematical/lsmsvgfiltersurface.h +0 -66
- data/ext/mathematical/lsmsvgfiltertile.c +0 -102
- data/ext/mathematical/lsmsvgfiltertile.h +0 -57
- data/ext/mathematical/lsmsvggelement.c +0 -73
- data/ext/mathematical/lsmsvggelement.h +0 -55
- data/ext/mathematical/lsmsvggradientelement.c +0 -151
- data/ext/mathematical/lsmsvggradientelement.h +0 -68
- data/ext/mathematical/lsmsvgimageelement.c +0 -261
- data/ext/mathematical/lsmsvgimageelement.h +0 -67
- data/ext/mathematical/lsmsvglength.c +0 -93
- data/ext/mathematical/lsmsvglength.h +0 -59
- data/ext/mathematical/lsmsvglineargradientelement.c +0 -271
- data/ext/mathematical/lsmsvglineargradientelement.h +0 -60
- data/ext/mathematical/lsmsvglineelement.c +0 -153
- data/ext/mathematical/lsmsvglineelement.h +0 -60
- data/ext/mathematical/lsmsvgmarkerelement.c +0 -266
- data/ext/mathematical/lsmsvgmarkerelement.h +0 -74
- data/ext/mathematical/lsmsvgmaskelement.c +0 -232
- data/ext/mathematical/lsmsvgmaskelement.h +0 -64
- data/ext/mathematical/lsmsvgmatrix.c +0 -205
- data/ext/mathematical/lsmsvgmatrix.h +0 -59
- data/ext/mathematical/lsmsvgpathelement.c +0 -115
- data/ext/mathematical/lsmsvgpathelement.h +0 -59
- data/ext/mathematical/lsmsvgpatternelement.c +0 -398
- data/ext/mathematical/lsmsvgpatternelement.h +0 -69
- data/ext/mathematical/lsmsvgpolygonelement.c +0 -106
- data/ext/mathematical/lsmsvgpolygonelement.h +0 -57
- data/ext/mathematical/lsmsvgpolylineelement.c +0 -106
- data/ext/mathematical/lsmsvgpolylineelement.h +0 -57
- data/ext/mathematical/lsmsvgradialgradientelement.c +0 -323
- data/ext/mathematical/lsmsvgradialgradientelement.h +0 -61
- data/ext/mathematical/lsmsvgrectelement.c +0 -184
- data/ext/mathematical/lsmsvgrectelement.h +0 -62
- data/ext/mathematical/lsmsvgstopelement.c +0 -106
- data/ext/mathematical/lsmsvgstopelement.h +0 -57
- data/ext/mathematical/lsmsvgstyle.c +0 -558
- data/ext/mathematical/lsmsvgstyle.h +0 -217
- data/ext/mathematical/lsmsvgsvgelement.c +0 -260
- data/ext/mathematical/lsmsvgsvgelement.h +0 -71
- data/ext/mathematical/lsmsvgswitchelement.c +0 -103
- data/ext/mathematical/lsmsvgswitchelement.h +0 -55
- data/ext/mathematical/lsmsvgsymbolelement.c +0 -74
- data/ext/mathematical/lsmsvgsymbolelement.h +0 -55
- data/ext/mathematical/lsmsvgtextelement.c +0 -170
- data/ext/mathematical/lsmsvgtextelement.h +0 -58
- data/ext/mathematical/lsmsvgtraits.c +0 -1158
- data/ext/mathematical/lsmsvgtraits.h +0 -103
- data/ext/mathematical/lsmsvgtransformable.c +0 -106
- data/ext/mathematical/lsmsvgtransformable.h +0 -54
- data/ext/mathematical/lsmsvgtspanelement.c +0 -143
- data/ext/mathematical/lsmsvgtspanelement.h +0 -58
- data/ext/mathematical/lsmsvgtypes.h +0 -77
- data/ext/mathematical/lsmsvguseelement.c +0 -237
- data/ext/mathematical/lsmsvguseelement.h +0 -69
- data/ext/mathematical/lsmsvgview.c +0 -2400
- data/ext/mathematical/lsmsvgview.h +0 -168
- data/ext/mathematical/lsmtraits.c +0 -119
- data/ext/mathematical/lsmtraits.h +0 -49
- data/ext/mathematical/lsmtypes.h +0 -36
- data/ext/mathematical/lsmutils.c +0 -54
- data/ext/mathematical/lsmutils.h +0 -56
- data/ext/mathematical/mathematical.c +0 -122
- data/ext/mathematical/y.tab.c +0 -6179
- data/ext/mathematical/y.tab.h +0 -389
- data/script/bench +0 -21
- data/script/bootstrap +0 -9
- data/script/single_test +0 -7
- data/test/mathematical/basic_test.rb +0 -38
- data/test/mathematical/fixtures/after/brackets_display.html +0 -1
- data/test/mathematical/fixtures/after/dollar_sign_inline.html +0 -1
- data/test/mathematical/fixtures/after/equation_display.html +0 -1
- data/test/mathematical/fixtures/after/multiple_dollar_inline.html +0 -1
- data/test/mathematical/fixtures/after/parens_inline.html +0 -1
- data/test/mathematical/fixtures/before/brackets_display.text +0 -1
- data/test/mathematical/fixtures/before/dollar_sign_inline.text +0 -1
- data/test/mathematical/fixtures/before/equation_display.text +0 -1
- data/test/mathematical/fixtures/before/multiple_dollar_inline.text +0 -1
- data/test/mathematical/fixtures/before/parens_inline.text +0 -1
- data/test/mathematical/fixtures/performance/big_file.text +0 -1767
- data/test/mathematical/fixtures_test.rb +0 -31
- data/test/mathematical/performance_test.rb +0 -13
- data/test/test_helper.rb +0 -4
@@ -1,58 +0,0 @@
|
|
1
|
-
/* Lasem
|
2
|
-
*
|
3
|
-
* Copyright © 2009-2012 Emmanuel Pacaud
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General
|
16
|
-
* Public License along with this library; if not, write to the
|
17
|
-
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
|
-
* Boston, MA 02111-1307, USA.
|
19
|
-
*
|
20
|
-
* Author:
|
21
|
-
* Emmanuel Pacaud <emmanuel@gnome.org>
|
22
|
-
*/
|
23
|
-
|
24
|
-
#ifndef LSM_SVG_TEXT_ELEMENT_H
|
25
|
-
#define LSM_SVG_TEXT_ELEMENT_H
|
26
|
-
|
27
|
-
#include <lsmsvgtypes.h>
|
28
|
-
#include <lsmsvgtransformable.h>
|
29
|
-
|
30
|
-
G_BEGIN_DECLS
|
31
|
-
|
32
|
-
#define LSM_TYPE_SVG_TEXT_ELEMENT (lsm_svg_text_element_get_type ())
|
33
|
-
#define LSM_SVG_TEXT_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_SVG_TEXT_ELEMENT, LsmSvgTextElement))
|
34
|
-
#define LSM_SVG_TEXT_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_SVG_TEXT_ELEMENT, LsmSvgTextElementClass))
|
35
|
-
#define LSM_IS_SVG_TEXT_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_SVG_TEXT_ELEMENT))
|
36
|
-
#define LSM_IS_SVG_TEXT_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_SVG_TEXT_ELEMENT))
|
37
|
-
#define LSM_SVG_TEXT_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_SVG_TEXT_ELEMENT, LsmSvgTextElementClass))
|
38
|
-
|
39
|
-
typedef struct _LsmSvgTextElementClass LsmSvgTextElementClass;
|
40
|
-
|
41
|
-
struct _LsmSvgTextElement {
|
42
|
-
LsmSvgTransformable base;
|
43
|
-
|
44
|
-
LsmSvgLengthAttribute x;
|
45
|
-
LsmSvgLengthAttribute y;
|
46
|
-
};
|
47
|
-
|
48
|
-
struct _LsmSvgTextElementClass {
|
49
|
-
LsmSvgTransformableClass base_class;
|
50
|
-
};
|
51
|
-
|
52
|
-
GType lsm_svg_text_element_get_type (void);
|
53
|
-
|
54
|
-
LsmDomNode * lsm_svg_text_element_new (void);
|
55
|
-
|
56
|
-
G_END_DECLS
|
57
|
-
|
58
|
-
#endif
|
@@ -1,1158 +0,0 @@
|
|
1
|
-
/* Lasem
|
2
|
-
*
|
3
|
-
* Copyright © 2009 Emmanuel Pacaud
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General
|
16
|
-
* Public License along with this library; if not, write to the
|
17
|
-
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
|
-
* Boston, MA 02111-1307, USA.
|
19
|
-
*
|
20
|
-
* Author:
|
21
|
-
* Emmanuel Pacaud <emmanuel@gnome.org>
|
22
|
-
*/
|
23
|
-
|
24
|
-
#include <lsmsvgtraits.h>
|
25
|
-
#include <lsmstr.h>
|
26
|
-
#include <lsmsvgcolors.h>
|
27
|
-
#include <math.h>
|
28
|
-
#include <string.h>
|
29
|
-
#include <stdlib.h>
|
30
|
-
|
31
|
-
const LsmSvgColor lsm_svg_color_null = {0.0, 0.0, 0.0};
|
32
|
-
const LsmSvgDashArray lsm_svg_dash_array_null = {0, NULL};
|
33
|
-
|
34
|
-
static gboolean
|
35
|
-
lsm_svg_blending_mode_trait_from_string (LsmTrait *abstract_trait, char *string)
|
36
|
-
{
|
37
|
-
LsmSvgBlendingMode *trait = (LsmSvgBlendingMode *) abstract_trait;
|
38
|
-
|
39
|
-
*trait = lsm_svg_blending_mode_from_string (string);
|
40
|
-
|
41
|
-
return *trait >= 0;
|
42
|
-
}
|
43
|
-
|
44
|
-
char *
|
45
|
-
lsm_svg_blending_mode_trait_to_string (LsmTrait *abstract_trait)
|
46
|
-
{
|
47
|
-
LsmSvgBlendingMode *trait = (LsmSvgBlendingMode *) abstract_trait;
|
48
|
-
|
49
|
-
return g_strdup (lsm_svg_blending_mode_to_string (*trait));
|
50
|
-
}
|
51
|
-
|
52
|
-
const LsmTraitClass lsm_svg_blending_mode_trait_class = {
|
53
|
-
.size = sizeof (LsmSvgBlendingMode),
|
54
|
-
.from_string = lsm_svg_blending_mode_trait_from_string,
|
55
|
-
.to_string = lsm_svg_blending_mode_trait_to_string
|
56
|
-
};
|
57
|
-
|
58
|
-
static gboolean
|
59
|
-
lsm_svg_comp_op_trait_from_string (LsmTrait *abstract_trait, char *string)
|
60
|
-
{
|
61
|
-
LsmSvgCompOp *trait = (LsmSvgCompOp *) abstract_trait;
|
62
|
-
|
63
|
-
*trait = lsm_svg_comp_op_from_string (string);
|
64
|
-
|
65
|
-
return *trait >= 0;
|
66
|
-
}
|
67
|
-
|
68
|
-
char *
|
69
|
-
lsm_svg_comp_op_trait_to_string (LsmTrait *abstract_trait)
|
70
|
-
{
|
71
|
-
LsmSvgCompOp *trait = (LsmSvgCompOp *) abstract_trait;
|
72
|
-
|
73
|
-
return g_strdup (lsm_svg_comp_op_to_string (*trait));
|
74
|
-
}
|
75
|
-
|
76
|
-
const LsmTraitClass lsm_svg_comp_op_trait_class = {
|
77
|
-
.size = sizeof (LsmSvgCompOp),
|
78
|
-
.from_string = lsm_svg_comp_op_trait_from_string,
|
79
|
-
.to_string = lsm_svg_comp_op_trait_to_string
|
80
|
-
};
|
81
|
-
|
82
|
-
static gboolean
|
83
|
-
lsm_svg_enable_background_trait_from_string (LsmTrait *abstract_trait, char *string)
|
84
|
-
{
|
85
|
-
LsmSvgEnableBackground *trait = (LsmSvgEnableBackground *) abstract_trait;
|
86
|
-
|
87
|
-
*trait = lsm_svg_enable_background_from_string (string);
|
88
|
-
|
89
|
-
return *trait >= 0;
|
90
|
-
}
|
91
|
-
|
92
|
-
char *
|
93
|
-
lsm_svg_enable_background_trait_to_string (LsmTrait *abstract_trait)
|
94
|
-
{
|
95
|
-
LsmSvgEnableBackground *trait = (LsmSvgEnableBackground *) abstract_trait;
|
96
|
-
|
97
|
-
return g_strdup (lsm_svg_enable_background_to_string (*trait));
|
98
|
-
}
|
99
|
-
|
100
|
-
const LsmTraitClass lsm_svg_enable_background_trait_class = {
|
101
|
-
.size = sizeof (LsmSvgEnableBackground),
|
102
|
-
.from_string = lsm_svg_enable_background_trait_from_string,
|
103
|
-
.to_string = lsm_svg_enable_background_trait_to_string
|
104
|
-
};
|
105
|
-
|
106
|
-
static gboolean
|
107
|
-
lsm_svg_length_trait_from_string (LsmTrait *abstract_trait, char *string)
|
108
|
-
{
|
109
|
-
LsmSvgLength *svg_length = (LsmSvgLength *) abstract_trait;
|
110
|
-
char *length_type_str;
|
111
|
-
|
112
|
-
svg_length->value_unit = g_ascii_strtod (string, &length_type_str);
|
113
|
-
svg_length->type = lsm_svg_length_type_from_string (length_type_str);
|
114
|
-
|
115
|
-
return length_type_str != string && svg_length->type >= 0;
|
116
|
-
}
|
117
|
-
|
118
|
-
static char *
|
119
|
-
lsm_svg_length_trait_to_string (LsmTrait *abstract_trait)
|
120
|
-
{
|
121
|
-
LsmSvgLength *svg_length = (LsmSvgLength *) abstract_trait;
|
122
|
-
|
123
|
-
return g_strdup_printf ("%g%s",
|
124
|
-
svg_length->value_unit,
|
125
|
-
lsm_svg_length_type_to_string (svg_length->type));
|
126
|
-
}
|
127
|
-
|
128
|
-
const LsmTraitClass lsm_svg_length_trait_class = {
|
129
|
-
.size = sizeof (LsmSvgLength),
|
130
|
-
.from_string = lsm_svg_length_trait_from_string,
|
131
|
-
.to_string = lsm_svg_length_trait_to_string
|
132
|
-
};
|
133
|
-
|
134
|
-
static void
|
135
|
-
_init_matrix (LsmSvgMatrix *matrix, LsmSvgTransformType transform, unsigned int n_values, double values[])
|
136
|
-
{
|
137
|
-
switch (transform) {
|
138
|
-
case LSM_SVG_TRANSFORM_TYPE_SCALE:
|
139
|
-
if (n_values == 1) {
|
140
|
-
lsm_svg_matrix_init_scale (matrix, values[0], values[0]);
|
141
|
-
return;
|
142
|
-
} else if (n_values == 2) {
|
143
|
-
lsm_svg_matrix_init_scale (matrix, values[0], values[1]);
|
144
|
-
return;
|
145
|
-
}
|
146
|
-
break;
|
147
|
-
case LSM_SVG_TRANSFORM_TYPE_TRANSLATE:
|
148
|
-
if (n_values == 1) {
|
149
|
-
lsm_svg_matrix_init_translate (matrix, values[0], values[0]);
|
150
|
-
return;
|
151
|
-
} else if (n_values == 2) {
|
152
|
-
lsm_svg_matrix_init_translate (matrix, values[0], values[1]);
|
153
|
-
return;
|
154
|
-
}
|
155
|
-
break;
|
156
|
-
case LSM_SVG_TRANSFORM_TYPE_MATRIX:
|
157
|
-
if (n_values == 6) {
|
158
|
-
lsm_svg_matrix_init (matrix,
|
159
|
-
values[0], values[1],
|
160
|
-
values[2], values[3],
|
161
|
-
values[4], values[5]);
|
162
|
-
return;
|
163
|
-
}
|
164
|
-
break;
|
165
|
-
case LSM_SVG_TRANSFORM_TYPE_ROTATE:
|
166
|
-
if (n_values == 1) {
|
167
|
-
lsm_svg_matrix_init_rotate (matrix, values[0] * M_PI / 180.0);
|
168
|
-
return;
|
169
|
-
} else if (n_values == 3) {
|
170
|
-
LsmSvgMatrix matrix_b;
|
171
|
-
|
172
|
-
lsm_svg_matrix_init_translate (matrix, values[1], values[2]);
|
173
|
-
lsm_svg_matrix_init_rotate (&matrix_b, values[0] * M_PI / 180.0);
|
174
|
-
lsm_svg_matrix_multiply (matrix, &matrix_b, matrix);
|
175
|
-
lsm_svg_matrix_init_translate (&matrix_b, -values[1], -values[2]);
|
176
|
-
lsm_svg_matrix_multiply (matrix, &matrix_b, matrix);
|
177
|
-
return;
|
178
|
-
}
|
179
|
-
break;
|
180
|
-
case LSM_SVG_TRANSFORM_TYPE_SKEW_X:
|
181
|
-
if (n_values == 1) {
|
182
|
-
lsm_svg_matrix_init_skew_x (matrix, values[0] * M_PI / 180.0);
|
183
|
-
return;
|
184
|
-
}
|
185
|
-
break;
|
186
|
-
case LSM_SVG_TRANSFORM_TYPE_SKEW_Y:
|
187
|
-
if (n_values == 1) {
|
188
|
-
lsm_svg_matrix_init_skew_y (matrix, values[0] * M_PI / 180.0);
|
189
|
-
return;
|
190
|
-
}
|
191
|
-
default:
|
192
|
-
break;
|
193
|
-
}
|
194
|
-
|
195
|
-
lsm_svg_matrix_init_identity (matrix);
|
196
|
-
}
|
197
|
-
|
198
|
-
static gboolean
|
199
|
-
lsm_svg_matrix_trait_from_string (LsmTrait *abstract_trait, char *string)
|
200
|
-
{
|
201
|
-
LsmSvgMatrix *matrix = (LsmSvgMatrix *) abstract_trait;
|
202
|
-
|
203
|
-
lsm_svg_matrix_init_identity (matrix);
|
204
|
-
|
205
|
-
while (*string != '\0') {
|
206
|
-
LsmSvgTransformType transform;
|
207
|
-
double values[6];
|
208
|
-
|
209
|
-
lsm_str_skip_spaces (&string);
|
210
|
-
|
211
|
-
if (strncmp (string, "translate", 9) == 0) {
|
212
|
-
transform = LSM_SVG_TRANSFORM_TYPE_TRANSLATE;
|
213
|
-
string += 9;
|
214
|
-
} else if (strncmp (string, "scale", 5) == 0) {
|
215
|
-
transform = LSM_SVG_TRANSFORM_TYPE_SCALE;
|
216
|
-
string += 5;
|
217
|
-
} else if (strncmp (string, "rotate", 6) == 0) {
|
218
|
-
transform = LSM_SVG_TRANSFORM_TYPE_ROTATE;
|
219
|
-
string += 6;
|
220
|
-
} else if (strncmp (string, "matrix", 6) == 0) {
|
221
|
-
transform = LSM_SVG_TRANSFORM_TYPE_MATRIX;
|
222
|
-
string += 6;
|
223
|
-
} else if (strncmp (string, "skewX", 5) == 0) {
|
224
|
-
transform = LSM_SVG_TRANSFORM_TYPE_SKEW_X;
|
225
|
-
string += 5;
|
226
|
-
} else if (strncmp (string, "skewY", 5) == 0) {
|
227
|
-
transform = LSM_SVG_TRANSFORM_TYPE_SKEW_Y;
|
228
|
-
string += 5;
|
229
|
-
} else
|
230
|
-
return FALSE;
|
231
|
-
|
232
|
-
lsm_str_skip_spaces (&string);
|
233
|
-
|
234
|
-
if (*string == '(') {
|
235
|
-
unsigned int n_values = 0;
|
236
|
-
|
237
|
-
string++;
|
238
|
-
|
239
|
-
while (*string != ')' && *string != '\0' && n_values < 6) {
|
240
|
-
lsm_str_skip_comma_and_spaces (&string);
|
241
|
-
|
242
|
-
if (!lsm_str_parse_double (&string, &values[n_values]))
|
243
|
-
break;
|
244
|
-
|
245
|
-
n_values++;
|
246
|
-
}
|
247
|
-
|
248
|
-
lsm_str_skip_comma_and_spaces (&string);
|
249
|
-
|
250
|
-
if (*string == ')') {
|
251
|
-
LsmSvgMatrix new_matrix;
|
252
|
-
|
253
|
-
string++;
|
254
|
-
|
255
|
-
_init_matrix (&new_matrix, transform, n_values, values);
|
256
|
-
|
257
|
-
lsm_svg_matrix_multiply (matrix, &new_matrix, matrix);
|
258
|
-
} else
|
259
|
-
return FALSE;
|
260
|
-
} else
|
261
|
-
return FALSE;
|
262
|
-
}
|
263
|
-
|
264
|
-
return TRUE;
|
265
|
-
}
|
266
|
-
|
267
|
-
static char *
|
268
|
-
lsm_svg_matrix_trait_to_string (LsmTrait *abstract_trait)
|
269
|
-
{
|
270
|
-
LsmSvgMatrix *matrix = (LsmSvgMatrix *) abstract_trait;
|
271
|
-
|
272
|
-
/* TODO smarter serialization, checking for zeros */
|
273
|
-
return g_strdup_printf ("matrix(%g,%g,%g,%g,%g,%g)",
|
274
|
-
matrix->a,
|
275
|
-
matrix->b,
|
276
|
-
matrix->c,
|
277
|
-
matrix->d,
|
278
|
-
matrix->e,
|
279
|
-
matrix->f);
|
280
|
-
}
|
281
|
-
|
282
|
-
const LsmTraitClass lsm_svg_matrix_trait_class = {
|
283
|
-
.size = sizeof (LsmSvgMatrix),
|
284
|
-
.from_string = lsm_svg_matrix_trait_from_string,
|
285
|
-
.to_string = lsm_svg_matrix_trait_to_string
|
286
|
-
};
|
287
|
-
|
288
|
-
static double
|
289
|
-
_hue_to_rgb (double m1, double m2, double h)
|
290
|
-
{
|
291
|
-
if (h < 0)
|
292
|
-
h = h + 1.0;
|
293
|
-
if (h > 1)
|
294
|
-
h = h - 1.0;
|
295
|
-
if (h * 6.0 < 1.0)
|
296
|
-
return m1 + (m2 - m1 ) * h * 6.0;
|
297
|
-
if (h * 2.0 < 1.0)
|
298
|
-
return m2;
|
299
|
-
if (h * 3.0 < 2.0)
|
300
|
-
return m1 + (m2 - m1) * (2.0 / 3.0 - h) * 6.0;
|
301
|
-
|
302
|
-
return m1;
|
303
|
-
}
|
304
|
-
|
305
|
-
static char *
|
306
|
-
_parse_color (char *string,
|
307
|
-
LsmSvgColor *svg_color,
|
308
|
-
LsmSvgPaintType *paint_type)
|
309
|
-
{
|
310
|
-
unsigned int color = 0;
|
311
|
-
|
312
|
-
lsm_str_skip_spaces (&string);
|
313
|
-
|
314
|
-
if (g_strcmp0 (string, "currentColor") == 0) {
|
315
|
-
svg_color->red = -1.0;
|
316
|
-
svg_color->green = -1.0;
|
317
|
-
svg_color->blue = -1.0;
|
318
|
-
|
319
|
-
*paint_type = LSM_SVG_PAINT_TYPE_CURRENT_COLOR;
|
320
|
-
|
321
|
-
string += 12; /* strlen ("current_color") */
|
322
|
-
|
323
|
-
return string;
|
324
|
-
}
|
325
|
-
|
326
|
-
if (*string == '#') {
|
327
|
-
int value, i;
|
328
|
-
string++;
|
329
|
-
|
330
|
-
for (i = 0; i < 6; i++) {
|
331
|
-
if (*string >= '0' && *string <= '9')
|
332
|
-
value = *string - '0';
|
333
|
-
else if (*string >= 'A' && *string <= 'F')
|
334
|
-
value = *string - 'A' + 10;
|
335
|
-
else if (*string >= 'a' && *string <= 'f')
|
336
|
-
value = *string - 'a' + 10;
|
337
|
-
else
|
338
|
-
break;
|
339
|
-
|
340
|
-
color = (color << 4) + value;
|
341
|
-
string++;
|
342
|
-
}
|
343
|
-
|
344
|
-
if (i == 3) {
|
345
|
-
color = ((color & 0xf00) << 8) | ((color & 0x0f0) << 4) | (color & 0x00f);
|
346
|
-
color |= color << 4;
|
347
|
-
} else if (i != 6)
|
348
|
-
color = 0;
|
349
|
-
|
350
|
-
*paint_type = LSM_SVG_PAINT_TYPE_RGB_COLOR;
|
351
|
-
} else if (strncmp (string, "rgb(", 4) == 0) {
|
352
|
-
int i;
|
353
|
-
double value;
|
354
|
-
|
355
|
-
|
356
|
-
string += 4; /* strlen ("rgb(") */
|
357
|
-
|
358
|
-
lsm_str_skip_spaces (&string);
|
359
|
-
|
360
|
-
for (i = 0; i < 3; i++) {
|
361
|
-
if (!lsm_str_parse_double (&string, &value))
|
362
|
-
break;
|
363
|
-
|
364
|
-
if (*string == '%') {
|
365
|
-
value = value * 255.0 / 100.0;
|
366
|
-
string++;
|
367
|
-
}
|
368
|
-
|
369
|
-
if (i < 2)
|
370
|
-
lsm_str_skip_comma_and_spaces (&string);
|
371
|
-
|
372
|
-
color = (color << 8) + (int) (0.5 + CLAMP (value, 0.0, 255.0));
|
373
|
-
}
|
374
|
-
|
375
|
-
lsm_str_skip_spaces (&string);
|
376
|
-
|
377
|
-
if (*string != ')' || i != 3)
|
378
|
-
color = 0;
|
379
|
-
|
380
|
-
*paint_type = LSM_SVG_PAINT_TYPE_RGB_COLOR;
|
381
|
-
} else if (strncmp (string, "hsl(", 4) == 0) {
|
382
|
-
double value[3];
|
383
|
-
int i;
|
384
|
-
|
385
|
-
string += 4; /* strlen ("hsl(") */
|
386
|
-
|
387
|
-
lsm_str_skip_spaces (&string);
|
388
|
-
|
389
|
-
for (i = 0; i < 3; i++) {
|
390
|
-
if (!lsm_str_parse_double (&string, &value[i]))
|
391
|
-
break;
|
392
|
-
|
393
|
-
if (i > 0) {
|
394
|
-
if (*string != '%')
|
395
|
-
break;
|
396
|
-
string++;
|
397
|
-
}
|
398
|
-
|
399
|
-
lsm_str_skip_comma_and_spaces (&string);
|
400
|
-
}
|
401
|
-
|
402
|
-
lsm_str_skip_spaces (&string);
|
403
|
-
|
404
|
-
if (*string == ')' && i == 3) {
|
405
|
-
double m1, m2;
|
406
|
-
double h,s,l;
|
407
|
-
|
408
|
-
h = value[0] / 360.0;
|
409
|
-
s = value[1] / 100.0;
|
410
|
-
l = value[2] / 100.0;
|
411
|
-
|
412
|
-
if (l <= 0.5)
|
413
|
-
m2 = l*(s + 1.0);
|
414
|
-
else
|
415
|
-
m2 = l + s - l * s;
|
416
|
-
m1 = l * 2.0 - m2;
|
417
|
-
|
418
|
-
svg_color->red = _hue_to_rgb (m1, m2, h + 1.0/3.0);
|
419
|
-
svg_color->green = _hue_to_rgb (m1, m2, h);
|
420
|
-
svg_color->blue = _hue_to_rgb (m1, m2, h - 1.0/3.0);
|
421
|
-
|
422
|
-
*paint_type = LSM_SVG_PAINT_TYPE_RGB_COLOR;
|
423
|
-
|
424
|
-
return string;
|
425
|
-
}
|
426
|
-
} else if (g_strcmp0 (string, "none") != 0) {
|
427
|
-
color = lsm_svg_color_from_string (string);
|
428
|
-
|
429
|
-
*paint_type = LSM_SVG_PAINT_TYPE_RGB_COLOR;
|
430
|
-
} else {
|
431
|
-
*paint_type = LSM_SVG_PAINT_TYPE_NONE;
|
432
|
-
}
|
433
|
-
|
434
|
-
svg_color->red = (double) ((color & 0xff0000) >> 16) / 255.0;
|
435
|
-
svg_color->green = (double) ((color & 0x00ff00) >> 8) / 255.0;
|
436
|
-
svg_color->blue = (double) (color & 0x0000ff) / 255.0;
|
437
|
-
|
438
|
-
return string;
|
439
|
-
}
|
440
|
-
|
441
|
-
static gboolean
|
442
|
-
lsm_svg_paint_trait_from_string (LsmTrait *abstract_trait, char *string)
|
443
|
-
{
|
444
|
-
LsmSvgPaint *paint = (LsmSvgPaint *) abstract_trait;
|
445
|
-
LsmSvgPaintType paint_type;
|
446
|
-
|
447
|
-
g_free (paint->url);
|
448
|
-
|
449
|
-
if (strncmp (string, "url(#", 5) == 0) {
|
450
|
-
unsigned int length;
|
451
|
-
|
452
|
-
length = 5;
|
453
|
-
while (string[length] != ')')
|
454
|
-
length++;
|
455
|
-
length++;
|
456
|
-
|
457
|
-
paint->url = g_new (char, length);
|
458
|
-
if (paint->url != NULL) {
|
459
|
-
memcpy (paint->url, string, length - 1);
|
460
|
-
paint->url[length - 1] = '\0';
|
461
|
-
}
|
462
|
-
string += length;
|
463
|
-
} else {
|
464
|
-
paint->url = NULL;
|
465
|
-
}
|
466
|
-
|
467
|
-
string = _parse_color (string, &paint->color, &paint_type);
|
468
|
-
|
469
|
-
if (paint->url != NULL)
|
470
|
-
switch (paint_type) {
|
471
|
-
case LSM_SVG_PAINT_TYPE_RGB_COLOR:
|
472
|
-
paint_type = LSM_SVG_PAINT_TYPE_URI_RGB_COLOR;
|
473
|
-
break;
|
474
|
-
case LSM_SVG_PAINT_TYPE_CURRENT_COLOR:
|
475
|
-
paint_type = LSM_SVG_PAINT_TYPE_URI_CURRENT_COLOR;
|
476
|
-
break;
|
477
|
-
case LSM_SVG_PAINT_TYPE_NONE:
|
478
|
-
paint_type = LSM_SVG_PAINT_TYPE_URI;
|
479
|
-
break;
|
480
|
-
case LSM_SVG_PAINT_TYPE_RGB_COLOR_ICC_COLOR:
|
481
|
-
paint_type = LSM_SVG_PAINT_TYPE_URI_RGB_COLOR_ICC_COLOR;
|
482
|
-
break;
|
483
|
-
default:
|
484
|
-
paint_type = LSM_SVG_PAINT_TYPE_URI;
|
485
|
-
break;
|
486
|
-
}
|
487
|
-
|
488
|
-
paint->type = paint_type;
|
489
|
-
|
490
|
-
/* TODO better syntax error check */
|
491
|
-
|
492
|
-
return TRUE;
|
493
|
-
}
|
494
|
-
|
495
|
-
char *
|
496
|
-
lsm_svg_paint_trait_to_string (LsmTrait *abstract_trait)
|
497
|
-
{
|
498
|
-
LsmSvgPaint *paint = (LsmSvgPaint *) abstract_trait;
|
499
|
-
|
500
|
-
if (paint->color.red < 0.0 || paint->color.green < 0.0 || paint->color.blue < 0.0)
|
501
|
-
return g_strdup ("currentColor");
|
502
|
-
|
503
|
-
/* FIXME */
|
504
|
-
if (paint->url != NULL)
|
505
|
-
return g_strdup (paint->url);
|
506
|
-
|
507
|
-
return g_strdup_printf ("rgb(%g%%,%g%%,%g%%)",
|
508
|
-
100.0 * paint->color.red,
|
509
|
-
100.0 * paint->color.green,
|
510
|
-
100.0 * paint->color.blue);
|
511
|
-
}
|
512
|
-
|
513
|
-
const LsmTraitClass lsm_svg_paint_trait_class = {
|
514
|
-
.size = sizeof (LsmSvgPaint),
|
515
|
-
.from_string = lsm_svg_paint_trait_from_string,
|
516
|
-
.to_string = lsm_svg_paint_trait_to_string
|
517
|
-
};
|
518
|
-
|
519
|
-
static gboolean
|
520
|
-
lsm_svg_fill_rule_trait_from_string (LsmTrait *abstract_trait, char *string)
|
521
|
-
{
|
522
|
-
LsmSvgFillRule *trait = (LsmSvgFillRule *) abstract_trait;
|
523
|
-
|
524
|
-
*trait = lsm_svg_fill_rule_from_string (string);
|
525
|
-
|
526
|
-
return *trait >= 0;
|
527
|
-
}
|
528
|
-
|
529
|
-
char *
|
530
|
-
lsm_svg_fill_rule_trait_to_string (LsmTrait *abstract_trait)
|
531
|
-
{
|
532
|
-
LsmSvgFillRule *trait = (LsmSvgFillRule *) abstract_trait;
|
533
|
-
|
534
|
-
return g_strdup (lsm_svg_fill_rule_to_string (*trait));
|
535
|
-
}
|
536
|
-
|
537
|
-
const LsmTraitClass lsm_svg_fill_rule_trait_class = {
|
538
|
-
.size = sizeof (LsmSvgFillRule),
|
539
|
-
.from_string = lsm_svg_fill_rule_trait_from_string,
|
540
|
-
.to_string = lsm_svg_fill_rule_trait_to_string
|
541
|
-
};
|
542
|
-
|
543
|
-
static gboolean
|
544
|
-
lsm_svg_font_style_trait_from_string (LsmTrait *abstract_trait, char *string)
|
545
|
-
{
|
546
|
-
LsmSvgFontStyle *trait = (LsmSvgFontStyle *) abstract_trait;
|
547
|
-
|
548
|
-
*trait = lsm_svg_font_style_from_string (string);
|
549
|
-
|
550
|
-
return *trait >= 0;
|
551
|
-
}
|
552
|
-
|
553
|
-
char *
|
554
|
-
lsm_svg_font_style_trait_to_string (LsmTrait *abstract_trait)
|
555
|
-
{
|
556
|
-
LsmSvgFontStyle *trait = (LsmSvgFontStyle *) abstract_trait;
|
557
|
-
|
558
|
-
return g_strdup (lsm_svg_font_style_to_string (*trait));
|
559
|
-
}
|
560
|
-
|
561
|
-
const LsmTraitClass lsm_svg_font_style_trait_class = {
|
562
|
-
.size = sizeof (LsmSvgFontStyle),
|
563
|
-
.from_string = lsm_svg_font_style_trait_from_string,
|
564
|
-
.to_string = lsm_svg_font_style_trait_to_string
|
565
|
-
};
|
566
|
-
|
567
|
-
static gboolean
|
568
|
-
lsm_svg_font_stretch_trait_from_string (LsmTrait *abstract_trait, char *string)
|
569
|
-
{
|
570
|
-
LsmSvgFontStretch *trait = (LsmSvgFontStretch *) abstract_trait;
|
571
|
-
|
572
|
-
*trait = lsm_svg_font_stretch_from_string (string);
|
573
|
-
|
574
|
-
return *trait >= 0;
|
575
|
-
}
|
576
|
-
|
577
|
-
char *
|
578
|
-
lsm_svg_font_stretch_trait_to_string (LsmTrait *abstract_trait)
|
579
|
-
{
|
580
|
-
LsmSvgFontStretch *trait = (LsmSvgFontStretch *) abstract_trait;
|
581
|
-
|
582
|
-
return g_strdup (lsm_svg_font_stretch_to_string (*trait));
|
583
|
-
}
|
584
|
-
|
585
|
-
const LsmTraitClass lsm_svg_font_stretch_trait_class = {
|
586
|
-
.size = sizeof (LsmSvgFontStretch),
|
587
|
-
.from_string = lsm_svg_font_stretch_trait_from_string,
|
588
|
-
.to_string = lsm_svg_font_stretch_trait_to_string
|
589
|
-
};
|
590
|
-
|
591
|
-
static gboolean
|
592
|
-
lsm_svg_font_weight_trait_from_string (LsmTrait *abstract_trait, char *string)
|
593
|
-
{
|
594
|
-
LsmSvgFontWeight *trait = (LsmSvgFontWeight *) abstract_trait;
|
595
|
-
|
596
|
-
*trait = lsm_svg_font_weight_from_string (string);
|
597
|
-
|
598
|
-
if (*trait < 0)
|
599
|
-
*trait = strtol (string, NULL, 10);
|
600
|
-
|
601
|
-
return *trait >= 100 && *trait <= 1000;
|
602
|
-
}
|
603
|
-
|
604
|
-
char *
|
605
|
-
lsm_svg_font_weight_trait_to_string (LsmTrait *abstract_trait)
|
606
|
-
{
|
607
|
-
LsmSvgFontWeight *trait = (LsmSvgFontWeight *) abstract_trait;
|
608
|
-
const char *string;
|
609
|
-
|
610
|
-
string = lsm_svg_font_weight_to_string (*trait);
|
611
|
-
|
612
|
-
if (string != NULL)
|
613
|
-
return g_strdup (string);
|
614
|
-
|
615
|
-
return g_strdup_printf ("%d", *trait);
|
616
|
-
}
|
617
|
-
|
618
|
-
const LsmTraitClass lsm_svg_font_weight_trait_class = {
|
619
|
-
.size = sizeof (LsmSvgFontWeight),
|
620
|
-
.from_string = lsm_svg_font_weight_trait_from_string,
|
621
|
-
.to_string = lsm_svg_font_weight_trait_to_string
|
622
|
-
};
|
623
|
-
|
624
|
-
static gboolean
|
625
|
-
lsm_svg_line_join_trait_from_string (LsmTrait *abstract_trait, char *string)
|
626
|
-
{
|
627
|
-
LsmSvgLineJoin *trait = (LsmSvgLineJoin *) abstract_trait;
|
628
|
-
|
629
|
-
*trait = lsm_svg_line_join_from_string (string);
|
630
|
-
|
631
|
-
return *trait >= 0;
|
632
|
-
}
|
633
|
-
|
634
|
-
char *
|
635
|
-
lsm_svg_line_join_trait_to_string (LsmTrait *abstract_trait)
|
636
|
-
{
|
637
|
-
LsmSvgLineJoin *trait = (LsmSvgLineJoin *) abstract_trait;
|
638
|
-
|
639
|
-
return g_strdup (lsm_svg_line_join_to_string (*trait));
|
640
|
-
}
|
641
|
-
|
642
|
-
const LsmTraitClass lsm_svg_line_join_trait_class = {
|
643
|
-
.size = sizeof (LsmSvgLineJoin),
|
644
|
-
.from_string = lsm_svg_line_join_trait_from_string,
|
645
|
-
.to_string = lsm_svg_line_join_trait_to_string
|
646
|
-
};
|
647
|
-
|
648
|
-
static gboolean
|
649
|
-
lsm_svg_line_cap_trait_from_string (LsmTrait *abstract_trait, char *string)
|
650
|
-
{
|
651
|
-
LsmSvgLineCap *trait = (LsmSvgLineCap *) abstract_trait;
|
652
|
-
|
653
|
-
*trait = lsm_svg_line_cap_from_string (string);
|
654
|
-
|
655
|
-
return *trait >= 0;
|
656
|
-
}
|
657
|
-
|
658
|
-
static char *
|
659
|
-
lsm_svg_line_cap_trait_to_string (LsmTrait *abstract_trait)
|
660
|
-
{
|
661
|
-
LsmSvgLineCap *trait = (LsmSvgLineCap *) abstract_trait;
|
662
|
-
|
663
|
-
return g_strdup (lsm_svg_line_cap_to_string (*trait));
|
664
|
-
}
|
665
|
-
|
666
|
-
const LsmTraitClass lsm_svg_line_cap_trait_class = {
|
667
|
-
.size = sizeof (LsmSvgLineCap),
|
668
|
-
.from_string = lsm_svg_line_cap_trait_from_string,
|
669
|
-
.to_string = lsm_svg_line_cap_trait_to_string
|
670
|
-
};
|
671
|
-
|
672
|
-
LsmSvgDashArray *
|
673
|
-
lsm_svg_dash_array_new (unsigned int n_dashes)
|
674
|
-
{
|
675
|
-
LsmSvgDashArray *array;
|
676
|
-
|
677
|
-
g_return_val_if_fail (n_dashes > 0, (LsmSvgDashArray *) &lsm_svg_dash_array_null);
|
678
|
-
|
679
|
-
array = g_new (LsmSvgDashArray, 1);
|
680
|
-
array->n_dashes = n_dashes;
|
681
|
-
array->dashes = g_new (LsmSvgLength, n_dashes);
|
682
|
-
|
683
|
-
return array;
|
684
|
-
}
|
685
|
-
|
686
|
-
void
|
687
|
-
lsm_svg_dash_array_free (LsmSvgDashArray *array)
|
688
|
-
{
|
689
|
-
if (array == NULL || array == &lsm_svg_dash_array_null)
|
690
|
-
return;
|
691
|
-
|
692
|
-
g_free (array->dashes);
|
693
|
-
g_free (array);
|
694
|
-
}
|
695
|
-
|
696
|
-
LsmSvgDashArray *
|
697
|
-
lsm_svg_dash_array_duplicate (const LsmSvgDashArray *origin)
|
698
|
-
{
|
699
|
-
LsmSvgDashArray *duplicate;
|
700
|
-
|
701
|
-
if (origin == NULL || origin == &lsm_svg_dash_array_null)
|
702
|
-
return (LsmSvgDashArray *) &lsm_svg_dash_array_null;
|
703
|
-
|
704
|
-
duplicate = lsm_svg_dash_array_new (origin->n_dashes);
|
705
|
-
|
706
|
-
if (duplicate != &lsm_svg_dash_array_null)
|
707
|
-
memcpy (duplicate->dashes, origin->dashes, sizeof (LsmSvgLength) * origin->n_dashes);
|
708
|
-
|
709
|
-
return duplicate;
|
710
|
-
}
|
711
|
-
|
712
|
-
static gboolean
|
713
|
-
lsm_svg_dash_array_trait_from_string (LsmTrait *abstract_trait, char *string)
|
714
|
-
{
|
715
|
-
LsmSvgDashArray *dash_array = (LsmSvgDashArray *) abstract_trait;
|
716
|
-
unsigned int n_dashes = 1;
|
717
|
-
double value;
|
718
|
-
double sum = 0.0;
|
719
|
-
gboolean is_error = FALSE;
|
720
|
-
|
721
|
-
g_free (dash_array->dashes);
|
722
|
-
dash_array->n_dashes = 0;
|
723
|
-
dash_array->dashes = NULL;
|
724
|
-
|
725
|
-
if (strcmp (string, "none") != 0 &&
|
726
|
-
strcmp (string, "inherit")) {
|
727
|
-
char *iter = (char *) string;
|
728
|
-
unsigned int i;
|
729
|
-
|
730
|
-
while (*iter != '\0') {
|
731
|
-
if (*iter == ',' ||
|
732
|
-
*iter == ' ') {
|
733
|
-
n_dashes++;
|
734
|
-
do {
|
735
|
-
iter++;
|
736
|
-
} while (*iter == ',' ||
|
737
|
-
*iter == ' ');
|
738
|
-
} else
|
739
|
-
iter++;
|
740
|
-
}
|
741
|
-
|
742
|
-
if (n_dashes > 0) {
|
743
|
-
LsmSvgLength length;
|
744
|
-
|
745
|
-
dash_array->n_dashes = n_dashes;
|
746
|
-
dash_array->dashes = g_new (LsmSvgLength, n_dashes);
|
747
|
-
|
748
|
-
iter = (char *)string;
|
749
|
-
lsm_str_skip_spaces (&iter);
|
750
|
-
|
751
|
-
for (i = 0; i < n_dashes; i++) {
|
752
|
-
if (lsm_str_parse_double (&iter, &length.value_unit)) {
|
753
|
-
length.type = lsm_svg_length_type_from_string (iter);
|
754
|
-
dash_array->dashes[i] = length;
|
755
|
-
while (*iter != '\0' && *iter != ' ' && *iter != ',')
|
756
|
-
iter ++;
|
757
|
-
} else {
|
758
|
-
dash_array->dashes[i].value_unit = 0.0;
|
759
|
-
dash_array->dashes[i].type = LSM_SVG_LENGTH_TYPE_NUMBER;
|
760
|
-
}
|
761
|
-
lsm_str_skip_comma_and_spaces (&iter);
|
762
|
-
|
763
|
-
value = dash_array->dashes[i].value_unit;
|
764
|
-
if (value < 0.0) {
|
765
|
-
is_error = TRUE;
|
766
|
-
break;
|
767
|
-
}
|
768
|
-
sum += value;
|
769
|
-
}
|
770
|
-
}
|
771
|
-
|
772
|
-
if (is_error || sum <= 0.0) {
|
773
|
-
g_free (dash_array->dashes);
|
774
|
-
dash_array->n_dashes = 0;
|
775
|
-
dash_array->dashes = NULL;
|
776
|
-
|
777
|
-
return !is_error;
|
778
|
-
}
|
779
|
-
}
|
780
|
-
|
781
|
-
return TRUE;
|
782
|
-
}
|
783
|
-
|
784
|
-
static char *
|
785
|
-
lsm_svg_dash_array_trait_to_string (LsmTrait *abstract_trait)
|
786
|
-
{
|
787
|
-
g_assert_not_reached ();
|
788
|
-
}
|
789
|
-
|
790
|
-
static void
|
791
|
-
lsm_svg_dash_array_trait_finalize (LsmTrait *abstract_trait)
|
792
|
-
{
|
793
|
-
LsmSvgDashArray *dash_array = (LsmSvgDashArray *) abstract_trait;
|
794
|
-
|
795
|
-
g_free (dash_array->dashes);
|
796
|
-
dash_array->n_dashes = 0;
|
797
|
-
dash_array->dashes = NULL;
|
798
|
-
}
|
799
|
-
|
800
|
-
const LsmTraitClass lsm_svg_dash_array_trait_class = {
|
801
|
-
.size = sizeof (LsmSvgDashArray),
|
802
|
-
.from_string = lsm_svg_dash_array_trait_from_string,
|
803
|
-
.to_string = lsm_svg_dash_array_trait_to_string,
|
804
|
-
.finalize = lsm_svg_dash_array_trait_finalize
|
805
|
-
};
|
806
|
-
|
807
|
-
static gboolean
|
808
|
-
lsm_svg_display_trait_from_string (LsmTrait *abstract_trait, char *string)
|
809
|
-
{
|
810
|
-
LsmSvgDisplay *trait = (LsmSvgDisplay *) abstract_trait;
|
811
|
-
|
812
|
-
*trait = lsm_svg_display_from_string (string);
|
813
|
-
|
814
|
-
return *trait >= 0;
|
815
|
-
}
|
816
|
-
|
817
|
-
char *
|
818
|
-
lsm_svg_display_trait_to_string (LsmTrait *abstract_trait)
|
819
|
-
{
|
820
|
-
LsmSvgDisplay *trait = (LsmSvgDisplay *) abstract_trait;
|
821
|
-
|
822
|
-
return g_strdup (lsm_svg_display_to_string (*trait));
|
823
|
-
}
|
824
|
-
|
825
|
-
const LsmTraitClass lsm_svg_display_trait_class = {
|
826
|
-
.size = sizeof (LsmSvgDisplay),
|
827
|
-
.from_string = lsm_svg_display_trait_from_string,
|
828
|
-
.to_string = lsm_svg_display_trait_to_string
|
829
|
-
};
|
830
|
-
|
831
|
-
static gboolean
|
832
|
-
lsm_svg_color_trait_from_string (LsmTrait *abstract_trait, char *string)
|
833
|
-
{
|
834
|
-
LsmSvgColor *color = (LsmSvgColor *) abstract_trait;
|
835
|
-
LsmSvgPaintType paint_type;
|
836
|
-
|
837
|
-
_parse_color (string, color, &paint_type);
|
838
|
-
|
839
|
-
/* TODO Better error check */
|
840
|
-
|
841
|
-
return TRUE;
|
842
|
-
}
|
843
|
-
|
844
|
-
static char *
|
845
|
-
lsm_svg_color_trait_to_string (LsmTrait *abstract_trait)
|
846
|
-
{
|
847
|
-
LsmSvgColor *color = (LsmSvgColor *) abstract_trait;
|
848
|
-
|
849
|
-
if (color->red < 0.0 || color->green < 0.0 || color->blue < 0.0)
|
850
|
-
return g_strdup ("currentColor");
|
851
|
-
|
852
|
-
return g_strdup_printf ("rgb(%g%%,%g%%,%g%%)",
|
853
|
-
100.0 * color->red,
|
854
|
-
100.0 * color->green,
|
855
|
-
100.0 * color->blue);
|
856
|
-
}
|
857
|
-
|
858
|
-
const LsmTraitClass lsm_svg_color_trait_class = {
|
859
|
-
.size = sizeof (LsmSvgColor),
|
860
|
-
.from_string = lsm_svg_color_trait_from_string,
|
861
|
-
.to_string = lsm_svg_color_trait_to_string
|
862
|
-
};
|
863
|
-
|
864
|
-
static gboolean
|
865
|
-
lsm_svg_marker_units_trait_from_string (LsmTrait *abstract_trait, char *string)
|
866
|
-
{
|
867
|
-
LsmSvgMarkerUnits *trait = (LsmSvgMarkerUnits *) abstract_trait;
|
868
|
-
|
869
|
-
*trait = lsm_svg_marker_units_from_string (string);
|
870
|
-
|
871
|
-
return *trait >= 0;
|
872
|
-
}
|
873
|
-
|
874
|
-
char *
|
875
|
-
lsm_svg_marker_units_trait_to_string (LsmTrait *abstract_trait)
|
876
|
-
{
|
877
|
-
LsmSvgMarkerUnits *trait = (LsmSvgMarkerUnits *) abstract_trait;
|
878
|
-
|
879
|
-
return g_strdup (lsm_svg_marker_units_to_string (*trait));
|
880
|
-
}
|
881
|
-
|
882
|
-
const LsmTraitClass lsm_svg_marker_units_trait_class = {
|
883
|
-
.size = sizeof (LsmSvgMarkerUnits),
|
884
|
-
.from_string = lsm_svg_marker_units_trait_from_string,
|
885
|
-
.to_string = lsm_svg_marker_units_trait_to_string
|
886
|
-
};
|
887
|
-
|
888
|
-
static gboolean
|
889
|
-
lsm_svg_pattern_units_trait_from_string (LsmTrait *abstract_trait, char *string)
|
890
|
-
{
|
891
|
-
LsmSvgPatternUnits *trait = (LsmSvgPatternUnits *) abstract_trait;
|
892
|
-
|
893
|
-
*trait = lsm_svg_pattern_units_from_string (string);
|
894
|
-
|
895
|
-
return *trait >= 0;
|
896
|
-
}
|
897
|
-
|
898
|
-
char *
|
899
|
-
lsm_svg_pattern_units_trait_to_string (LsmTrait *abstract_trait)
|
900
|
-
{
|
901
|
-
LsmSvgPatternUnits *trait = (LsmSvgPatternUnits *) abstract_trait;
|
902
|
-
|
903
|
-
return g_strdup (lsm_svg_pattern_units_to_string (*trait));
|
904
|
-
}
|
905
|
-
|
906
|
-
const LsmTraitClass lsm_svg_pattern_units_trait_class = {
|
907
|
-
.size = sizeof (LsmSvgPatternUnits),
|
908
|
-
.from_string = lsm_svg_pattern_units_trait_from_string,
|
909
|
-
.to_string = lsm_svg_pattern_units_trait_to_string
|
910
|
-
};
|
911
|
-
|
912
|
-
static gboolean
|
913
|
-
lsm_svg_preserve_aspect_ratio_trait_from_string (LsmTrait *abstract_trait, char *string)
|
914
|
-
{
|
915
|
-
LsmSvgPreserveAspectRatio *trait = (LsmSvgPreserveAspectRatio *) abstract_trait;
|
916
|
-
|
917
|
-
char **tokens;
|
918
|
-
unsigned int i = 0;
|
919
|
-
|
920
|
-
tokens = g_strsplit (string, " ", -1);
|
921
|
-
|
922
|
-
if (tokens[i] != NULL && strcmp (tokens[i], "defer") == 0) {
|
923
|
-
trait->defer = TRUE;
|
924
|
-
i++;
|
925
|
-
} else
|
926
|
-
trait->defer = FALSE;
|
927
|
-
|
928
|
-
if (tokens[i] != NULL) {
|
929
|
-
trait->align = lsm_svg_align_from_string (tokens[i]);
|
930
|
-
i++;
|
931
|
-
if (tokens[i] != NULL)
|
932
|
-
trait->meet_or_slice = lsm_svg_meet_or_slice_from_string (tokens[i]);
|
933
|
-
else
|
934
|
-
trait->meet_or_slice = LSM_SVG_MEET_OR_SLICE_MEET;
|
935
|
-
} else trait->align = LSM_SVG_ALIGN_X_MID_Y_MID;
|
936
|
-
|
937
|
-
g_strfreev (tokens);
|
938
|
-
|
939
|
-
/* TODO Better error check */
|
940
|
-
|
941
|
-
return TRUE;
|
942
|
-
}
|
943
|
-
|
944
|
-
char *
|
945
|
-
lsm_svg_preserve_aspect_ratio_trait_to_string (LsmTrait *abstract_trait)
|
946
|
-
{
|
947
|
-
LsmSvgPreserveAspectRatio *trait = (LsmSvgPreserveAspectRatio *) abstract_trait;
|
948
|
-
|
949
|
-
return g_strdup_printf ("%s%s %s", trait->defer ? "defer " : "",
|
950
|
-
lsm_svg_align_to_string (trait->align),
|
951
|
-
lsm_svg_meet_or_slice_to_string (trait->meet_or_slice));
|
952
|
-
}
|
953
|
-
|
954
|
-
const LsmTraitClass lsm_svg_preserve_aspect_ratio_trait_class = {
|
955
|
-
.size = sizeof (LsmSvgPreserveAspectRatio),
|
956
|
-
.from_string = lsm_svg_preserve_aspect_ratio_trait_from_string,
|
957
|
-
.to_string = lsm_svg_preserve_aspect_ratio_trait_to_string
|
958
|
-
};
|
959
|
-
|
960
|
-
static gboolean
|
961
|
-
lsm_svg_spread_method_trait_from_string (LsmTrait *abstract_trait, char *string)
|
962
|
-
{
|
963
|
-
LsmSvgSpreadMethod *trait = (LsmSvgSpreadMethod *) abstract_trait;
|
964
|
-
|
965
|
-
*trait = lsm_svg_spread_method_from_string (string);
|
966
|
-
|
967
|
-
return *trait >= 0;
|
968
|
-
}
|
969
|
-
|
970
|
-
static char *
|
971
|
-
lsm_svg_spread_method_trait_to_string (LsmTrait *abstract_trait)
|
972
|
-
{
|
973
|
-
LsmSvgSpreadMethod *trait = (LsmSvgSpreadMethod *) abstract_trait;
|
974
|
-
|
975
|
-
return g_strdup (lsm_svg_spread_method_to_string (*trait));
|
976
|
-
}
|
977
|
-
|
978
|
-
const LsmTraitClass lsm_svg_spread_method_trait_class = {
|
979
|
-
.size = sizeof (LsmSvgSpreadMethod),
|
980
|
-
.from_string = lsm_svg_spread_method_trait_from_string,
|
981
|
-
.to_string = lsm_svg_spread_method_trait_to_string
|
982
|
-
};
|
983
|
-
|
984
|
-
static gboolean
|
985
|
-
lsm_svg_angle_trait_from_string (LsmTrait *abstract_trait, char *string)
|
986
|
-
{
|
987
|
-
LsmSvgAngle *trait = (LsmSvgAngle *) abstract_trait;
|
988
|
-
char *end_ptr;
|
989
|
-
|
990
|
-
if (g_strcmp0 (string, "auto") == 0) {
|
991
|
-
trait->type = LSM_SVG_ANGLE_TYPE_AUTO;
|
992
|
-
trait->angle = 0.0;
|
993
|
-
|
994
|
-
return TRUE;
|
995
|
-
}
|
996
|
-
|
997
|
-
trait->type = LSM_SVG_ANGLE_TYPE_FIXED;
|
998
|
-
trait->angle = g_ascii_strtod (string, &end_ptr);
|
999
|
-
|
1000
|
-
return end_ptr != string;
|
1001
|
-
}
|
1002
|
-
|
1003
|
-
static char *
|
1004
|
-
lsm_svg_angle_trait_to_string (LsmTrait *abstract_trait)
|
1005
|
-
{
|
1006
|
-
LsmSvgAngle *trait = (LsmSvgAngle *) abstract_trait;
|
1007
|
-
|
1008
|
-
if (trait->type == LSM_SVG_ANGLE_TYPE_AUTO)
|
1009
|
-
return g_strdup ("auto");
|
1010
|
-
|
1011
|
-
return g_strdup_printf ("%g", trait->angle);
|
1012
|
-
}
|
1013
|
-
|
1014
|
-
const LsmTraitClass lsm_svg_angle_trait_class = {
|
1015
|
-
.size = sizeof (LsmSvgAngle),
|
1016
|
-
.from_string = lsm_svg_angle_trait_from_string,
|
1017
|
-
.to_string = lsm_svg_angle_trait_to_string
|
1018
|
-
};
|
1019
|
-
|
1020
|
-
static gboolean
|
1021
|
-
lsm_svg_text_anchor_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1022
|
-
{
|
1023
|
-
LsmSvgTextAnchor *trait = (LsmSvgTextAnchor *) abstract_trait;
|
1024
|
-
|
1025
|
-
*trait = lsm_svg_text_anchor_from_string (string);
|
1026
|
-
|
1027
|
-
return *trait >= 0;
|
1028
|
-
}
|
1029
|
-
|
1030
|
-
char *
|
1031
|
-
lsm_svg_text_anchor_trait_to_string (LsmTrait *abstract_trait)
|
1032
|
-
{
|
1033
|
-
LsmSvgTextAnchor *trait = (LsmSvgTextAnchor *) abstract_trait;
|
1034
|
-
|
1035
|
-
return g_strdup (lsm_svg_text_anchor_to_string (*trait));
|
1036
|
-
}
|
1037
|
-
|
1038
|
-
const LsmTraitClass lsm_svg_text_anchor_trait_class = {
|
1039
|
-
.size = sizeof (LsmSvgTextAnchor),
|
1040
|
-
.from_string = lsm_svg_text_anchor_trait_from_string,
|
1041
|
-
.to_string = lsm_svg_text_anchor_trait_to_string
|
1042
|
-
};
|
1043
|
-
|
1044
|
-
static gboolean
|
1045
|
-
lsm_svg_visibility_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1046
|
-
{
|
1047
|
-
LsmSvgVisibility *trait = (LsmSvgVisibility *) abstract_trait;
|
1048
|
-
|
1049
|
-
*trait = lsm_svg_visibility_from_string (string);
|
1050
|
-
|
1051
|
-
return *trait >= 0;
|
1052
|
-
}
|
1053
|
-
|
1054
|
-
char *
|
1055
|
-
lsm_svg_visibility_trait_to_string (LsmTrait *abstract_trait)
|
1056
|
-
{
|
1057
|
-
LsmSvgVisibility *trait = (LsmSvgVisibility *) abstract_trait;
|
1058
|
-
|
1059
|
-
return g_strdup (lsm_svg_visibility_to_string (*trait));
|
1060
|
-
}
|
1061
|
-
|
1062
|
-
const LsmTraitClass lsm_svg_visibility_trait_class = {
|
1063
|
-
.size = sizeof (LsmSvgVisibility),
|
1064
|
-
.from_string = lsm_svg_visibility_trait_from_string,
|
1065
|
-
.to_string = lsm_svg_visibility_trait_to_string
|
1066
|
-
};
|
1067
|
-
|
1068
|
-
static gboolean
|
1069
|
-
lsm_svg_one_or_two_double_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1070
|
-
{
|
1071
|
-
LsmSvgOneOrTwoDouble *trait = (LsmSvgOneOrTwoDouble *) abstract_trait;
|
1072
|
-
char *end_ptr;
|
1073
|
-
|
1074
|
-
trait->a = g_ascii_strtod (string, &end_ptr);
|
1075
|
-
if (end_ptr == string) {
|
1076
|
-
trait->b = 0.0;
|
1077
|
-
return FALSE;
|
1078
|
-
}
|
1079
|
-
|
1080
|
-
string = end_ptr;
|
1081
|
-
|
1082
|
-
lsm_str_skip_spaces (&string);
|
1083
|
-
|
1084
|
-
if (string[0] == '\0') {
|
1085
|
-
trait->b = trait->a;
|
1086
|
-
return TRUE;
|
1087
|
-
}
|
1088
|
-
|
1089
|
-
trait->b = g_ascii_strtod (string, &end_ptr);
|
1090
|
-
|
1091
|
-
return end_ptr != string;
|
1092
|
-
}
|
1093
|
-
|
1094
|
-
static char *
|
1095
|
-
lsm_svg_one_or_two_double_trait_to_string (LsmTrait *abstract_trait)
|
1096
|
-
{
|
1097
|
-
LsmSvgOneOrTwoDouble *trait = (LsmSvgOneOrTwoDouble *) abstract_trait;
|
1098
|
-
|
1099
|
-
if (trait->a == trait->b)
|
1100
|
-
return g_strdup_printf ("%g", trait->a);
|
1101
|
-
|
1102
|
-
return g_strdup_printf ("%g %g", trait->a, trait->b);
|
1103
|
-
}
|
1104
|
-
|
1105
|
-
const LsmTraitClass lsm_svg_one_or_two_double_trait_class = {
|
1106
|
-
.size = sizeof (double),
|
1107
|
-
.from_string = lsm_svg_one_or_two_double_trait_from_string,
|
1108
|
-
.to_string = lsm_svg_one_or_two_double_trait_to_string
|
1109
|
-
};
|
1110
|
-
|
1111
|
-
static gboolean
|
1112
|
-
lsm_svg_overflow_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1113
|
-
{
|
1114
|
-
LsmSvgOverflow *trait = (LsmSvgOverflow *) abstract_trait;
|
1115
|
-
|
1116
|
-
*trait = lsm_svg_overflow_from_string (string);
|
1117
|
-
|
1118
|
-
return *trait >= 0;
|
1119
|
-
}
|
1120
|
-
|
1121
|
-
char *
|
1122
|
-
lsm_svg_overflow_trait_to_string (LsmTrait *abstract_trait)
|
1123
|
-
{
|
1124
|
-
LsmSvgOverflow *trait = (LsmSvgOverflow *) abstract_trait;
|
1125
|
-
|
1126
|
-
return g_strdup (lsm_svg_overflow_to_string (*trait));
|
1127
|
-
}
|
1128
|
-
|
1129
|
-
const LsmTraitClass lsm_svg_overflow_trait_class = {
|
1130
|
-
.size = sizeof (LsmSvgOverflow),
|
1131
|
-
.from_string = lsm_svg_overflow_trait_from_string,
|
1132
|
-
.to_string = lsm_svg_overflow_trait_to_string
|
1133
|
-
};
|
1134
|
-
|
1135
|
-
static gboolean
|
1136
|
-
lsm_svg_writing_mode_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1137
|
-
{
|
1138
|
-
LsmSvgDisplay *trait = (LsmSvgDisplay *) abstract_trait;
|
1139
|
-
|
1140
|
-
*trait = lsm_svg_writing_mode_from_string (string);
|
1141
|
-
|
1142
|
-
return *trait >= 0;
|
1143
|
-
}
|
1144
|
-
|
1145
|
-
char *
|
1146
|
-
lsm_svg_writing_mode_trait_to_string (LsmTrait *abstract_trait)
|
1147
|
-
{
|
1148
|
-
LsmSvgDisplay *trait = (LsmSvgDisplay *) abstract_trait;
|
1149
|
-
|
1150
|
-
return g_strdup (lsm_svg_writing_mode_to_string (*trait));
|
1151
|
-
}
|
1152
|
-
|
1153
|
-
const LsmTraitClass lsm_svg_writing_mode_trait_class = {
|
1154
|
-
.size = sizeof (LsmSvgWritingMode),
|
1155
|
-
.from_string = lsm_svg_writing_mode_trait_from_string,
|
1156
|
-
.to_string = lsm_svg_writing_mode_trait_to_string
|
1157
|
-
};
|
1158
|
-
|