Code

Pot and Dutch translation update
[inkscape.git] / src / sp-font-face.cpp
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
5 #ifdef ENABLE_SVG_FONTS
6 #define __SP_FONTFACE_C__
8 /*
9  * SVG <font-face> element implementation
10  *
11  * Section 20.8.3 of the W3C SVG 1.1 spec
12  * available at:
13  * http://www.w3.org/TR/SVG/fonts.html#FontFaceElement
14  *
15  * Author:
16  *   Felipe C. da S. Sanches <juca@members.fsf.org>
17  *
18  * Copyright (C) 2008, Felipe C. da S. Sanches
19  *
20  * Released under GNU GPL, read the file 'COPYING' for more information
21  */
23 #include "xml/repr.h"
24 #include "attributes.h"
25 #include "sp-font-face.h"
26 #include "document.h"
28 //TODO: apparently unused. Maybe should be removed.
29 class ObjectContainer
30 {
32 public:
33     ObjectContainer(double def){
34         this->isset = false;
35         this->default_value = def;
36     }
38     double get(){
39         if (this->isset)
40             return this->obj;
41         else
42             return this->default_value;
43     }
45     void set(double val){
46         this->obj = val;
47         this->isset = true;
48     }
50     void unset(){
51         this->isset = false;
52     }
54 private:
55     double obj;
56     double default_value;
57     bool isset;
58 };
60 static std::vector<FontFaceStyleType> sp_read_fontFaceStyleType(gchar const *value){
61     std::vector<FontFaceStyleType> v;
63     if (!value){
64         v.push_back(SP_FONTFACE_STYLE_ALL);
65         return v;
66     }
68     if (strncmp(value, "all", 3) == 0){
69         value += 3;
70         while(value[0]==',' || value[0]==' ')
71             value++;
72         v.push_back(SP_FONTFACE_STYLE_ALL);
73         return v;
74     }
76     while(value[0]!='\0'){
77         switch(value[0]){
78             case 'n':
79                 if (strncmp(value, "normal", 6) == 0){
80                     v.push_back(SP_FONTFACE_STYLE_NORMAL);
81                     value += 6;
82                 }
83                 break;
84             case 'i':
85                 if (strncmp(value, "italic", 6) == 0){
86                     v.push_back(SP_FONTFACE_STYLE_ITALIC);
87                     value += 6;
88                 }
89                 break;
90             case 'o':
91                 if (strncmp(value, "oblique", 7) == 0){
92                     v.push_back(SP_FONTFACE_STYLE_OBLIQUE);
93                     value += 7;
94                 }
95                 break;
96         }
97         while(value[0]==',' || value[0]==' ')
98             value++;
99     }
100     return v;
103 static std::vector<FontFaceVariantType> sp_read_fontFaceVariantType(gchar const *value){
104     std::vector<FontFaceVariantType> v;
106     if (!value){
107         v.push_back(SP_FONTFACE_VARIANT_NORMAL);
108         return v;
109     }
111     while(value[0]!='\0'){
112         switch(value[0]){
113             case 'n':
114                 if (strncmp(value, "normal", 6) == 0){
115                     v.push_back(SP_FONTFACE_VARIANT_NORMAL);
116                     value += 6;
117                 }
118                 break;
119             case 's':
120                 if (strncmp(value, "small-caps", 10) == 0){
121                     v.push_back(SP_FONTFACE_VARIANT_SMALL_CAPS);
122                     value += 10;
123                 }
124                 break;
125         }
126         while(value[0]==',' || value[0]==' ')
127             value++;
128     }
129     return v;
132 static std::vector<FontFaceWeightType> sp_read_fontFaceWeightType(gchar const *value){
133     std::vector<FontFaceWeightType> v;
135     if (!value){
136         v.push_back(SP_FONTFACE_WEIGHT_ALL);
137         return v;
138     }
140     if (strncmp(value, "all", 3) == 0){
141         value += 3;
142         while(value[0]==',' || value[0]==' ')
143             value++;
144         v.push_back(SP_FONTFACE_WEIGHT_ALL);
145         return v;
146     }
148     while(value[0]!='\0'){
149         switch(value[0]){
150             case 'n':
151                 if (strncmp(value, "normal", 6) == 0){
152                     v.push_back(SP_FONTFACE_WEIGHT_NORMAL);
153                     value += 6;
154                 }
155                 break;
156             case 'b':
157                 if (strncmp(value, "bold", 4) == 0){
158                     v.push_back(SP_FONTFACE_WEIGHT_BOLD);
159                     value += 4;
160                 }
161                 break;
162             case '1':
163                 if (strncmp(value, "100", 3) == 0){
164                     v.push_back(SP_FONTFACE_WEIGHT_100);
165                     value += 3;
166                 }
167                 break;
168             case '2':
169                 if (strncmp(value, "200", 3) == 0){
170                     v.push_back(SP_FONTFACE_WEIGHT_200);
171                     value += 3;
172                 }
173                 break;
174             case '3':
175                 if (strncmp(value, "300", 3) == 0){
176                     v.push_back(SP_FONTFACE_WEIGHT_300);
177                     value += 3;
178                 }
179                 break;
180             case '4':
181                 if (strncmp(value, "400", 3) == 0){
182                     v.push_back(SP_FONTFACE_WEIGHT_400);
183                     value += 3;
184                 }
185                 break;
186             case '5':
187                 if (strncmp(value, "500", 3) == 0){
188                     v.push_back(SP_FONTFACE_WEIGHT_500);
189                     value += 3;
190                 }
191                 break;
192             case '6':
193                 if (strncmp(value, "600", 3) == 0){
194                     v.push_back(SP_FONTFACE_WEIGHT_600);
195                     value += 3;
196                 }
197                 break;
198             case '7':
199                 if (strncmp(value, "700", 3) == 0){
200                     v.push_back(SP_FONTFACE_WEIGHT_700);
201                     value += 3;
202                 }
203                 break;
204             case '8':
205                 if (strncmp(value, "800", 3) == 0){
206                     v.push_back(SP_FONTFACE_WEIGHT_800);
207                     value += 3;
208                 }
209                 break;
210             case '9':
211                 if (strncmp(value, "900", 3) == 0){
212                     v.push_back(SP_FONTFACE_WEIGHT_900);
213                     value += 3;
214                 }
215                 break;
216         }
217         while(value[0]==',' || value[0]==' ')
218             value++;
219     }
220     return v;
223 static std::vector<FontFaceStretchType> sp_read_fontFaceStretchType(gchar const *value){
224     std::vector<FontFaceStretchType> v;
226     if (!value){
227         v.push_back(SP_FONTFACE_STRETCH_NORMAL);
228         return v;
229     }
231     if (strncmp(value, "all", 3) == 0){
232         value += 3;
233         while(value[0]==',' || value[0]==' ')
234             value++;
235         v.push_back(SP_FONTFACE_STRETCH_ALL);
236         return v;
237     }
239     while(value[0]!='\0'){
240         switch(value[0]){
241             case 'n':
242                 if (strncmp(value, "normal", 6) == 0){
243                     v.push_back(SP_FONTFACE_STRETCH_NORMAL);
244                     value += 6;
245                 }
246                 break;
247             case 'u':
248                 if (strncmp(value, "ultra-condensed", 15) == 0){
249                     v.push_back(SP_FONTFACE_STRETCH_ULTRA_CONDENSED);
250                     value += 15;
251                 }
252                 if (strncmp(value, "ultra-expanded", 14) == 0){
253                     v.push_back(SP_FONTFACE_STRETCH_ULTRA_EXPANDED);
254                     value += 14;
255                 }
256                 break;
257             case 'e':
258                 if (strncmp(value, "expanded", 8) == 0){
259                     v.push_back(SP_FONTFACE_STRETCH_EXPANDED);
260                     value += 8;
261                 }
262                 if (strncmp(value, "extra-condensed", 15) == 0){
263                     v.push_back(SP_FONTFACE_STRETCH_EXTRA_CONDENSED);
264                     value += 15;
265                 }
266                 if (strncmp(value, "extra-expanded", 14) == 0){
267                     v.push_back(SP_FONTFACE_STRETCH_EXTRA_EXPANDED);
268                     value += 14;
269                 }
270                 break;
271             case 'c':
272                 if (strncmp(value, "condensed", 9) == 0){
273                     v.push_back(SP_FONTFACE_STRETCH_CONDENSED);
274                     value += 9;
275                 }
276                 break;
277             case 's':
278                 if (strncmp(value, "semi-condensed", 14) == 0){
279                     v.push_back(SP_FONTFACE_STRETCH_SEMI_CONDENSED);
280                     value += 14;
281                 }
282                 if (strncmp(value, "semi-expanded", 13) == 0){
283                     v.push_back(SP_FONTFACE_STRETCH_SEMI_EXPANDED);
284                     value += 13;
285                 }
286                 break;
287         }
288         while(value[0]==',' || value[0]==' ')
289             value++;
290     }
291     return v;
294 static void sp_fontface_class_init(SPFontFaceClass *fc);
295 static void sp_fontface_init(SPFontFace *font);
297 static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
298 static void sp_fontface_release(SPObject *object);
299 static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *value);
300 static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
302 static void sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
303 static void sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child);
304 static void sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags);
306 static SPObjectClass *parent_class;
308 GType sp_fontface_get_type(void)
310     static GType type = 0;
312     if (!type) {
313         GTypeInfo info = {
314             sizeof(SPFontFaceClass),
315             NULL,       /* base_init */
316             NULL,       /* base_finalize */
317             (GClassInitFunc) sp_fontface_class_init,
318             NULL,       /* class_finalize */
319             NULL,       /* class_data */
320             sizeof(SPFontFace),
321             16, /* n_preallocs */
322             (GInstanceInitFunc) sp_fontface_init,
323             NULL,       /* value_table */
324         };
325         type = g_type_register_static(SP_TYPE_OBJECT, "SPFontFace", &info, (GTypeFlags) 0);
326     }
328     return type;
331 static void sp_fontface_class_init(SPFontFaceClass *fc)
333     SPObjectClass *sp_object_class = (SPObjectClass *) fc;
335     parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
337     sp_object_class->build = sp_fontface_build;
338     sp_object_class->release = sp_fontface_release;
339     sp_object_class->set = sp_fontface_set;
340     sp_object_class->write = sp_fontface_write;
341     sp_object_class->child_added = sp_fontface_child_added;
342     sp_object_class->remove_child = sp_fontface_remove_child;
343     sp_object_class->update = sp_fontface_update;
346 static void sp_fontface_init(SPFontFace *face)
348     std::vector<FontFaceStyleType> style;
349     style.push_back(SP_FONTFACE_STYLE_ALL);
350     face->font_style = style;
352     std::vector<FontFaceVariantType> variant;
353     variant.push_back(SP_FONTFACE_VARIANT_NORMAL);
354     face->font_variant = variant;
356     std::vector<FontFaceWeightType> weight;
357     weight.push_back(SP_FONTFACE_WEIGHT_ALL);
358     face->font_weight = weight;
360     std::vector<FontFaceStretchType> stretch;
361     stretch.push_back(SP_FONTFACE_STRETCH_NORMAL);
362     face->font_stretch = stretch;
363     face->font_family = NULL;
364     /*
365     //face->font_style = ;
366     //face->font_variant = ;
367     //face->font_weight = ;
368     //face->font_stretch = ;
369     face->font_size = NULL;
370     //face->unicode_range = ;
371     face->units_per_em = 1000;
372     //face->panose_1 = ;
373     face->stem_v = ;
374     face->stem_h = ;
375     face->slope = 0;
376     face->cap_height = ;
377     face->x_height = ;
378     face->accent_height = ;
379     face->ascent = ;
380     face->descent = ;
381     face->widths = NULL;
382     face->bbox = NULL;
383     face->ideographic = ;
384     face->alphabetic = ;
385     face->mathematical = ;
386     face->hanging = ;
387     face->v_ideographic = ;
388     face->v_alphabetic = ;
389     face->v_mathematical = ;
390     face->v_hanging = ;
391     face->underline_position = ;
392     face->underline_thickness = ;
393     face->strikethrough_position = ;
394     face->strikethrough_thickness = ;
395     face->overline_position = ;
396     face->overline_thickness = ;
397 */
400 static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
402     if (((SPObjectClass *) (parent_class))->build) {
403         ((SPObjectClass *) (parent_class))->build(object, document, repr);
404     }
406     sp_object_read_attr(object, "font-family");
407     sp_object_read_attr(object, "font-style");
408     sp_object_read_attr(object, "font-variant");
409     sp_object_read_attr(object, "font-weight");
410     sp_object_read_attr(object, "font-stretch");
411     sp_object_read_attr(object, "font-size");
412     sp_object_read_attr(object, "unicode-range");
413     sp_object_read_attr(object, "units-per-em");
414     sp_object_read_attr(object, "panose-1");
415     sp_object_read_attr(object, "stem-v");
416     sp_object_read_attr(object, "stem-h");
417     sp_object_read_attr(object, "slope");
418     sp_object_read_attr(object, "cap-height");
419     sp_object_read_attr(object, "x-height");
420     sp_object_read_attr(object, "accent-height");
421     sp_object_read_attr(object, "ascent");
422     sp_object_read_attr(object, "descent");
423     sp_object_read_attr(object, "widths");
424     sp_object_read_attr(object, "bbox");
425     sp_object_read_attr(object, "ideographic");
426     sp_object_read_attr(object, "alphabetic");
427     sp_object_read_attr(object, "mathematical");
428     sp_object_read_attr(object, "ranging");
429     sp_object_read_attr(object, "v-ideogaphic");
430     sp_object_read_attr(object, "v-alphabetic");
431     sp_object_read_attr(object, "v-mathematical");
432     sp_object_read_attr(object, "v-hanging");
433     sp_object_read_attr(object, "underline-position");
434     sp_object_read_attr(object, "underline-thickness");
435     sp_object_read_attr(object, "strikethrough-position");
436     sp_object_read_attr(object, "strikethrough-thickness");
437     sp_object_read_attr(object, "overline-position");
438     sp_object_read_attr(object, "overline-thickness");
441 static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/)
445 /**
446  * Callback for child_added event.
447  */
448 static void
449 sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
451     SPFontFace *f = SP_FONTFACE(object);
453     if (((SPObjectClass *) parent_class)->child_added)
454         (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref);
456     sp_fontface_children_modified(f);
457     object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
461 /**
462  * Callback for remove_child event.
463  */
464 static void
465 sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child)
467     SPFontFace *f = SP_FONTFACE(object);
469     if (((SPObjectClass *) parent_class)->remove_child)
470         (* ((SPObjectClass *) parent_class)->remove_child)(object, child);
472     sp_fontface_children_modified(f);
473     object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
476 static void sp_fontface_release(SPObject *object)
478     //SPFontFace *font = SP_FONTFACE(object);
480     if (((SPObjectClass *) parent_class)->release) {
481         ((SPObjectClass *) parent_class)->release(object);
482     }
485 static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *value)
487     SPFontFace *face = SP_FONTFACE(object);
488     std::vector<FontFaceStyleType> style;
489     std::vector<FontFaceVariantType> variant;
490     std::vector<FontFaceWeightType> weight;
491     std::vector<FontFaceStretchType> stretch;
493     switch (key) {
494         case SP_PROP_FONT_FAMILY:
495             if (face->font_family) {
496                 g_free(face->font_family);
497             }
498             face->font_family = g_strdup(value);
499             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
500             break;
501         case SP_PROP_FONT_STYLE:
502             style = sp_read_fontFaceStyleType(value);
503             if (face->font_style.size() != style.size()){
504                 face->font_style = style;
505                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
506             } else {
507                 for (unsigned int i=0;i<style.size();i++){
508                     if (style[i] != face->font_style[i]){
509                         face->font_style = style;
510                         object->requestModified(SP_OBJECT_MODIFIED_FLAG);
511                         break;
512                     }
513                 }
514             }
515             break;
516         case SP_PROP_FONT_VARIANT:
517             variant = sp_read_fontFaceVariantType(value);
518             if (face->font_variant.size() != variant.size()){
519                 face->font_variant = variant;
520                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
521             } else {
522                 for (unsigned int i=0;i<variant.size();i++){
523                     if (variant[i] != face->font_variant[i]){
524                         face->font_variant = variant;
525                         object->requestModified(SP_OBJECT_MODIFIED_FLAG);
526                         break;
527                     }
528                 }
529             }
530             break;
531         case SP_PROP_FONT_WEIGHT:
532             weight = sp_read_fontFaceWeightType(value);
533             if (face->font_weight.size() != weight.size()){
534                 face->font_weight = weight;
535                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
536             } else {
537                 for (unsigned int i=0;i<weight.size();i++){
538                     if (weight[i] != face->font_weight[i]){
539                         face->font_weight = weight;
540                         object->requestModified(SP_OBJECT_MODIFIED_FLAG);
541                         break;
542                     }
543                 }
544             }
545             break;
546         case SP_PROP_FONT_STRETCH:
547             stretch = sp_read_fontFaceStretchType(value);
548             if (face->font_stretch.size() != stretch.size()){
549                 face->font_stretch = stretch;
550                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
551             } else {
552                 for (unsigned int i=0;i<stretch.size();i++){
553                     if (stretch[i] != face->font_stretch[i]){
554                         face->font_stretch = stretch;
555                         object->requestModified(SP_OBJECT_MODIFIED_FLAG);
556                         break;
557                     }
558                 }
559             }
560             break;
561         case SP_ATTR_UNITS_PER_EM:
562         {
563             double number = value ? g_ascii_strtod(value, 0) : 0;
564             if (number != face->units_per_em){
565                 face->units_per_em = number;
566                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
567             }
568             break;
569         }
570         case SP_ATTR_STEMV:
571         {
572             double number = value ? g_ascii_strtod(value, 0) : 0;
573             if (number != face->stemv){
574                 face->stemv = number;
575                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
576             }
577             break;
578         }
579         case SP_ATTR_STEMH:
580         {
581             double number = value ? g_ascii_strtod(value, 0) : 0;
582             if (number != face->stemh){
583                 face->stemh = number;
584                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
585             }
586             break;
587         }
588         case SP_ATTR_SLOPE:
589         {
590             double number = value ? g_ascii_strtod(value, 0) : 0;
591             if (number != face->slope){
592                 face->slope = number;
593                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
594             }
595             break;
596         }
597         case SP_ATTR_CAP_HEIGHT:
598         {
599             double number = value ? g_ascii_strtod(value, 0) : 0;
600             if (number != face->cap_height){
601                 face->cap_height = number;
602                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
603             }
604             break;
605         }
606         case SP_ATTR_X_HEIGHT:
607         {
608             double number = value ? g_ascii_strtod(value, 0) : 0;
609             if (number != face->x_height){
610                 face->x_height = number;
611                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
612             }
613             break;
614         }
615         case SP_ATTR_ACCENT_HEIGHT:
616         {
617             double number = value ? g_ascii_strtod(value, 0) : 0;
618             if (number != face->accent_height){
619                 face->accent_height = number;
620                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
621             }
622             break;
623         }
624         case SP_ATTR_ASCENT:
625         {
626             double number = value ? g_ascii_strtod(value, 0) : 0;
627             if (number != face->ascent){
628                 face->ascent = number;
629                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
630             }
631             break;
632         }
633         case SP_ATTR_DESCENT:
634         {
635             double number = value ? g_ascii_strtod(value, 0) : 0;
636             if (number != face->descent){
637                 face->descent = number;
638                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
639             }
640             break;
641         }
642         case SP_ATTR_IDEOGRAPHIC:
643         {
644             double number = value ? g_ascii_strtod(value, 0) : 0;
645             if (number != face->ideographic){
646                 face->ideographic = number;
647                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
648             }
649             break;
650         }
651         case SP_ATTR_ALPHABETIC:
652         {
653             double number = value ? g_ascii_strtod(value, 0) : 0;
654             if (number != face->alphabetic){
655                 face->alphabetic = number;
656                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
657             }
658             break;
659         }
660         case SP_ATTR_MATHEMATICAL:
661         {
662             double number = value ? g_ascii_strtod(value, 0) : 0;
663             if (number != face->mathematical){
664                 face->mathematical = number;
665                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
666             }
667             break;
668         }
669         case SP_ATTR_HANGING:
670         {
671             double number = value ? g_ascii_strtod(value, 0) : 0;
672             if (number != face->hanging){
673                 face->hanging = number;
674                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
675             }
676             break;
677         }
678         case SP_ATTR_V_IDEOGRAPHIC:
679         {
680             double number = value ? g_ascii_strtod(value, 0) : 0;
681             if (number != face->v_ideographic){
682                 face->v_ideographic = number;
683                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
684             }
685             break;
686         }
687         case SP_ATTR_V_ALPHABETIC:
688         {
689             double number = value ? g_ascii_strtod(value, 0) : 0;
690             if (number != face->v_alphabetic){
691                 face->v_alphabetic = number;
692                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
693             }
694             break;
695         }
696         case SP_ATTR_V_MATHEMATICAL:
697         {
698             double number = value ? g_ascii_strtod(value, 0) : 0;
699             if (number != face->v_mathematical){
700                 face->v_mathematical = number;
701                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
702             }
703             break;
704         }
705         case SP_ATTR_V_HANGING:
706         {
707             double number = value ? g_ascii_strtod(value, 0) : 0;
708             if (number != face->v_hanging){
709                 face->v_hanging = number;
710                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
711             }
712             break;
713         }
714         case SP_ATTR_UNDERLINE_POSITION:
715         {
716             double number = value ? g_ascii_strtod(value, 0) : 0;
717             if (number != face->underline_position){
718                 face->underline_position = number;
719                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
720             }
721             break;
722         }
723         case SP_ATTR_UNDERLINE_THICKNESS:
724         {
725             double number = value ? g_ascii_strtod(value, 0) : 0;
726             if (number != face->underline_thickness){
727                 face->underline_thickness = number;
728                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
729             }
730             break;
731         }
732         case SP_ATTR_STRIKETHROUGH_POSITION:
733         {
734             double number = value ? g_ascii_strtod(value, 0) : 0;
735             if (number != face->strikethrough_position){
736                 face->strikethrough_position = number;
737                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
738             }
739             break;
740         }
741         case SP_ATTR_STRIKETHROUGH_THICKNESS:
742         {
743             double number = value ? g_ascii_strtod(value, 0) : 0;
744             if (number != face->strikethrough_thickness){
745                 face->strikethrough_thickness = number;
746                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
747             }
748             break;
749         }
750         case SP_ATTR_OVERLINE_POSITION:
751         {
752             double number = value ? g_ascii_strtod(value, 0) : 0;
753             if (number != face->overline_position){
754                 face->overline_position = number;
755                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
756             }
757             break;
758         }
759         case SP_ATTR_OVERLINE_THICKNESS:
760         {
761             double number = value ? g_ascii_strtod(value, 0) : 0;
762             if (number != face->overline_thickness){
763                 face->overline_thickness = number;
764                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
765             }
766             break;
767         }
768         default:
769             if (((SPObjectClass *) (parent_class))->set) {
770                 ((SPObjectClass *) (parent_class))->set(object, key, value);
771             }
772             break;
773     }
776 /**
777  * Receives update notifications.
778  */
779 static void
780 sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags)
782     if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
783         sp_object_read_attr(object, "font-family");
784         sp_object_read_attr(object, "font-style");
785         sp_object_read_attr(object, "font-variant");
786         sp_object_read_attr(object, "font-weight");
787         sp_object_read_attr(object, "font-stretch");
788         sp_object_read_attr(object, "font-size");
789         sp_object_read_attr(object, "unicode-range");
790         sp_object_read_attr(object, "units-per-em");
791         sp_object_read_attr(object, "panose-1");
792         sp_object_read_attr(object, "stemv");
793         sp_object_read_attr(object, "stemh");
794         sp_object_read_attr(object, "slope");
795         sp_object_read_attr(object, "cap-height");
796         sp_object_read_attr(object, "x-height");
797         sp_object_read_attr(object, "accent-height");
798         sp_object_read_attr(object, "ascent");
799         sp_object_read_attr(object, "descent");
800         sp_object_read_attr(object, "widths");
801         sp_object_read_attr(object, "bbox");
802         sp_object_read_attr(object, "ideographic");
803         sp_object_read_attr(object, "alphabetic");
804         sp_object_read_attr(object, "mathematical");
805         sp_object_read_attr(object, "hanging");
806         sp_object_read_attr(object, "v-ideographic");
807         sp_object_read_attr(object, "v-alphabetic");
808         sp_object_read_attr(object, "v-mathematical");
809         sp_object_read_attr(object, "v-hanging");
810         sp_object_read_attr(object, "underline-position");
811         sp_object_read_attr(object, "underline-thickness");
812         sp_object_read_attr(object, "strikethrough-position");
813         sp_object_read_attr(object, "strikethrough-thickness");
814         sp_object_read_attr(object, "overline-position");
815         sp_object_read_attr(object, "overline-thickness");
816     }
818     if (((SPObjectClass *) parent_class)->update) {
819         ((SPObjectClass *) parent_class)->update(object, ctx, flags);
820     }
823 #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
825 static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
827     SPFontFace *face = SP_FONTFACE(object);
829     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
830         repr = xml_doc->createElement("svg:font-face");
831     }
833     //TODO:
834     //sp_repr_set_svg_double(repr, "font-family", face->font_family);
835     //sp_repr_set_svg_double(repr, "font-style", face->font_style);
836     //sp_repr_set_svg_double(repr, "font-variant", face->font_variant);
837     //sp_repr_set_svg_double(repr, "font-weight", face->font_weight);
838     //sp_repr_set_svg_double(repr, "font-stretch", face->font_stretch);
839     //sp_repr_set_svg_double(repr, "font-size", face->font_size);
840     //sp_repr_set_svg_double(repr, "unicode-range", face->unicode_range);
841     sp_repr_set_svg_double(repr, "units-per-em", face->units_per_em);
842     //sp_repr_set_svg_double(repr, "panose-1", face->panose_1);
843     sp_repr_set_svg_double(repr, "stemv", face->stemv);
844     sp_repr_set_svg_double(repr, "stemh", face->stemh);
845     sp_repr_set_svg_double(repr, "slope", face->slope);
846     sp_repr_set_svg_double(repr, "cap-height", face->cap_height);
847     sp_repr_set_svg_double(repr, "x-height", face->x_height);
848     sp_repr_set_svg_double(repr, "accent-height", face->accent_height);
849     sp_repr_set_svg_double(repr, "ascent", face->ascent);
850     sp_repr_set_svg_double(repr, "descent", face->descent);
851     //sp_repr_set_svg_double(repr, "widths", face->widths);
852     //sp_repr_set_svg_double(repr, "bbox", face->bbox);
853     sp_repr_set_svg_double(repr, "ideographic", face->ideographic);
854     sp_repr_set_svg_double(repr, "alphabetic", face->alphabetic);
855     sp_repr_set_svg_double(repr, "mathematical", face->mathematical);
856     sp_repr_set_svg_double(repr, "hanging", face->hanging);
857     sp_repr_set_svg_double(repr, "v-ideographic", face->v_ideographic);
858     sp_repr_set_svg_double(repr, "v-alphabetic", face->v_alphabetic);
859     sp_repr_set_svg_double(repr, "v-mathematical", face->v_mathematical);
860     sp_repr_set_svg_double(repr, "v-hanging", face->v_hanging);
861     sp_repr_set_svg_double(repr, "underline-position", face->underline_position);
862     sp_repr_set_svg_double(repr, "underline-thickness", face->underline_thickness);
863     sp_repr_set_svg_double(repr, "strikethrough-position", face->strikethrough_position);
864     sp_repr_set_svg_double(repr, "strikethrough-thickness", face->strikethrough_thickness);
865     sp_repr_set_svg_double(repr, "overline-position", face->overline_position);
866     sp_repr_set_svg_double(repr, "overline-thickness", face->overline_thickness);
868     if (repr != SP_OBJECT_REPR(object)) {
869         COPY_ATTR(repr, object->repr, "font-family");
870         COPY_ATTR(repr, object->repr, "font-style");
871         COPY_ATTR(repr, object->repr, "font-variant");
872         COPY_ATTR(repr, object->repr, "font-weight");
873         COPY_ATTR(repr, object->repr, "font-stretch");
874         COPY_ATTR(repr, object->repr, "font-size");
875         COPY_ATTR(repr, object->repr, "unicode-range");
876         COPY_ATTR(repr, object->repr, "units-per-em");
877         COPY_ATTR(repr, object->repr, "panose-1");
878         COPY_ATTR(repr, object->repr, "stemv");
879         COPY_ATTR(repr, object->repr, "stemh");
880         COPY_ATTR(repr, object->repr, "slope");
881         COPY_ATTR(repr, object->repr, "cap-height");
882         COPY_ATTR(repr, object->repr, "x-height");
883         COPY_ATTR(repr, object->repr, "accent-height");
884         COPY_ATTR(repr, object->repr, "ascent");
885         COPY_ATTR(repr, object->repr, "descent");
886         COPY_ATTR(repr, object->repr, "widths");
887         COPY_ATTR(repr, object->repr, "bbox");
888         COPY_ATTR(repr, object->repr, "ideographic");
889         COPY_ATTR(repr, object->repr, "alphabetic");
890         COPY_ATTR(repr, object->repr, "mathematical");
891         COPY_ATTR(repr, object->repr, "hanging");
892         COPY_ATTR(repr, object->repr, "v-ideographic");
893         COPY_ATTR(repr, object->repr, "v-alphabetic");
894         COPY_ATTR(repr, object->repr, "v-mathematical");
895         COPY_ATTR(repr, object->repr, "v-hanging");
896         COPY_ATTR(repr, object->repr, "underline-position");
897         COPY_ATTR(repr, object->repr, "underline-thickness");
898         COPY_ATTR(repr, object->repr, "strikethrough-position");
899         COPY_ATTR(repr, object->repr, "strikethrough-thickness");
900         COPY_ATTR(repr, object->repr, "overline-position");
901         COPY_ATTR(repr, object->repr, "overline-thickness");
902     }
904     if (((SPObjectClass *) (parent_class))->write) {
905         ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
906     }
908     return repr;
910 #endif //#ifdef ENABLE_SVG_FONTS
911 /*
912   Local Variables:
913   mode:c++
914   c-file-style:"stroustrup"
915   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
916   indent-tabs-mode:nil
917   fill-column:99
918   End:
919 */
920 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :