Code

LIBNR REMOVAL. Deleted nr-path.h/.cpp which is no longer used. (removed all referenc...
[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 <felipe.sanches@gmail.com>
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"
27 #include "helper-fns.h"
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     }
67     
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     }
139     
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     }
230     
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 /*
364     face->font_family = NULL;
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     double number;
489     std::vector<FontFaceStyleType> style;
490     std::vector<FontFaceVariantType> variant;
491     std::vector<FontFaceWeightType> weight;
492     std::vector<FontFaceStretchType> stretch;
494     switch (key) {
495         case SP_PROP_FONT_STYLE:
496             style = sp_read_fontFaceStyleType(value);
497             if (face->font_style.size() != style.size()){
498                 face->font_style = style;
499                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
500             } else {
501                 for (unsigned int i=0;i<style.size();i++){
502                     if(style[i] != face->font_style[i]){
503                         face->font_style = style;
504                         object->requestModified(SP_OBJECT_MODIFIED_FLAG);
505                         break;
506                     }
507                 }
508             }
509             break;
510         case SP_PROP_FONT_VARIANT:
511             variant = sp_read_fontFaceVariantType(value);
512             if (face->font_variant.size() != variant.size()){
513                 face->font_variant = variant;
514                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
515             } else {
516                 for (unsigned int i=0;i<variant.size();i++){
517                     if(variant[i] != face->font_variant[i]){
518                         face->font_variant = variant;
519                         object->requestModified(SP_OBJECT_MODIFIED_FLAG);
520                         break;
521                     }
522                 }
523             }
524             break;
525         case SP_PROP_FONT_WEIGHT:
526             weight = sp_read_fontFaceWeightType(value);
527             if (face->font_weight.size() != weight.size()){
528                 face->font_weight = weight;
529                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
530             } else {
531                 for (unsigned int i=0;i<weight.size();i++){
532                     if(weight[i] != face->font_weight[i]){
533                         face->font_weight = weight;
534                         object->requestModified(SP_OBJECT_MODIFIED_FLAG);
535                         break;
536                     }
537                 }
538             }
539             break;
540         case SP_PROP_FONT_STRETCH:
541             stretch = sp_read_fontFaceStretchType(value);
542             if (face->font_stretch.size() != stretch.size()){
543                 face->font_stretch = stretch;
544                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
545             } else {
546                 for (unsigned int i=0;i<stretch.size();i++){
547                     if(stretch[i] != face->font_stretch[i]){
548                         face->font_stretch = stretch;
549                         object->requestModified(SP_OBJECT_MODIFIED_FLAG);
550                         break;
551                     }
552                 }
553             }
554             break;
555         case SP_ATTR_UNITS_PER_EM:
556             number = helperfns_read_number(value);
557             if (number != face->units_per_em){
558                 face->units_per_em = number;
559                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
560             }
561             break;
562         case SP_ATTR_STEMV:
563             number = helperfns_read_number(value);
564             if (number != face->stemv){
565                 face->stemv = number;
566                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
567             }
568             break;
569         case SP_ATTR_STEMH:
570             number = helperfns_read_number(value);
571             if (number != face->stemh){
572                 face->stemh = number;
573                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
574             }
575             break;
576         case SP_ATTR_SLOPE:
577             number = helperfns_read_number(value);
578             if (number != face->slope){
579                 face->slope = number;
580                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
581             }
582             break;
583         case SP_ATTR_CAP_HEIGHT:
584             number = helperfns_read_number(value);
585             if (number != face->cap_height){
586                 face->cap_height = number;
587                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
588             }
589             break;
590         case SP_ATTR_X_HEIGHT:
591             number = helperfns_read_number(value);
592             if (number != face->x_height){
593                 face->x_height = number;
594                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
595             }
596             break;
597         case SP_ATTR_ACCENT_HEIGHT:
598             number = helperfns_read_number(value);
599             if (number != face->accent_height){
600                 face->accent_height = number;
601                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
602             }
603             break;
604         case SP_ATTR_ASCENT:
605             number = helperfns_read_number(value);
606             if (number != face->ascent){
607                 face->ascent = number;
608                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
609             }
610             break;
611         case SP_ATTR_DESCENT:
612             number = helperfns_read_number(value);
613             if (number != face->descent){
614                 face->descent = number;
615                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
616             }
617             break;
618         case SP_ATTR_IDEOGRAPHIC:
619             number = helperfns_read_number(value);
620             if (number != face->ideographic){
621                 face->ideographic = number;
622                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
623             }
624             break;
625         case SP_ATTR_ALPHABETIC:
626             number = helperfns_read_number(value);
627             if (number != face->alphabetic){
628                 face->alphabetic = number;
629                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
630             }
631             break;
632         case SP_ATTR_MATHEMATICAL:
633             number = helperfns_read_number(value);
634             if (number != face->mathematical){
635                 face->mathematical = number;
636                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
637             }
638             break;
639         case SP_ATTR_HANGING:
640             number = helperfns_read_number(value);
641             if (number != face->hanging){
642                 face->hanging = number;
643                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
644             }
645             break;
646         case SP_ATTR_V_IDEOGRAPHIC:
647             number = helperfns_read_number(value);
648             if (number != face->v_ideographic){
649                 face->v_ideographic = number;
650                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
651             }
652             break;
653         case SP_ATTR_V_ALPHABETIC:
654             number = helperfns_read_number(value);
655             if (number != face->v_alphabetic){
656                 face->v_alphabetic = number;
657                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
658             }
659             break;
660         case SP_ATTR_V_MATHEMATICAL:
661             number = helperfns_read_number(value);
662             if (number != face->v_mathematical){
663                 face->v_mathematical = number;
664                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
665             }
666             break;
667         case SP_ATTR_V_HANGING:
668             number = helperfns_read_number(value);
669             if (number != face->v_hanging){
670                 face->v_hanging = number;
671                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
672             }
673             break;
674         case SP_ATTR_UNDERLINE_POSITION:
675             number = helperfns_read_number(value);
676             if (number != face->underline_position){
677                 face->underline_position = number;
678                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
679             }
680             break;
681         case SP_ATTR_UNDERLINE_THICKNESS:
682             number = helperfns_read_number(value);
683             if (number != face->underline_thickness){
684                 face->underline_thickness = number;
685                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
686             }
687             break;
688         case SP_ATTR_STRIKETHROUGH_POSITION:
689             number = helperfns_read_number(value);
690             if (number != face->strikethrough_position){
691                 face->strikethrough_position = number;
692                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
693             }
694             break;
695         case SP_ATTR_STRIKETHROUGH_THICKNESS:
696             number = helperfns_read_number(value);
697             if (number != face->strikethrough_thickness){
698                 face->strikethrough_thickness = number;
699                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
700             }
701             break;
702         case SP_ATTR_OVERLINE_POSITION:
703             number = helperfns_read_number(value);
704             if (number != face->overline_position){
705                 face->overline_position = number;
706                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
707             }
708             break;
709         case SP_ATTR_OVERLINE_THICKNESS:
710             number = helperfns_read_number(value);
711             if (number != face->overline_thickness){
712                 face->overline_thickness = number;
713                 object->requestModified(SP_OBJECT_MODIFIED_FLAG);
714             }
715             break;
716         default:
717             if (((SPObjectClass *) (parent_class))->set) {
718                 ((SPObjectClass *) (parent_class))->set(object, key, value);
719             }
720             break;
721     }
724 /**
725  * Receives update notifications.
726  */
727 static void
728 sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags)
730     if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
731         sp_object_read_attr(object, "font-family");
732         sp_object_read_attr(object, "font-style");
733         sp_object_read_attr(object, "font-variant");
734         sp_object_read_attr(object, "font-weight");
735         sp_object_read_attr(object, "font-stretch");
736         sp_object_read_attr(object, "font-size");
737         sp_object_read_attr(object, "unicode-range");
738         sp_object_read_attr(object, "units-per-em");
739         sp_object_read_attr(object, "panose-1");
740         sp_object_read_attr(object, "stemv");
741         sp_object_read_attr(object, "stemh");
742         sp_object_read_attr(object, "slope");
743         sp_object_read_attr(object, "cap-height");
744         sp_object_read_attr(object, "x-height");
745         sp_object_read_attr(object, "accent-height");
746         sp_object_read_attr(object, "ascent");
747         sp_object_read_attr(object, "descent");
748         sp_object_read_attr(object, "widths");
749         sp_object_read_attr(object, "bbox");
750         sp_object_read_attr(object, "ideographic");
751         sp_object_read_attr(object, "alphabetic");
752         sp_object_read_attr(object, "mathematical");
753         sp_object_read_attr(object, "hanging");
754         sp_object_read_attr(object, "v-ideographic");
755         sp_object_read_attr(object, "v-alphabetic");
756         sp_object_read_attr(object, "v-mathematical");
757         sp_object_read_attr(object, "v-hanging");
758         sp_object_read_attr(object, "underline-position");
759         sp_object_read_attr(object, "underline-thickness");
760         sp_object_read_attr(object, "strikethrough-position");
761         sp_object_read_attr(object, "strikethrough-thickness");
762         sp_object_read_attr(object, "overline-position");
763         sp_object_read_attr(object, "overline-thickness");
764     }
766     if (((SPObjectClass *) parent_class)->update) {
767         ((SPObjectClass *) parent_class)->update(object, ctx, flags);
768     }
771 #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
773 static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
775     SPFontFace *face = SP_FONTFACE(object);
777     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
778         repr = xml_doc->createElement("svg:font-face");
779     }
781     //TODO:
782     //sp_repr_set_svg_double(repr, "font-family", face->font_family);
783     //sp_repr_set_svg_double(repr, "font-style", face->font_style);
784     //sp_repr_set_svg_double(repr, "font-variant", face->font_variant);
785     //sp_repr_set_svg_double(repr, "font-weight", face->font_weight);
786     //sp_repr_set_svg_double(repr, "font-stretch", face->font_stretch);
787     //sp_repr_set_svg_double(repr, "font-size", face->font_size);
788     //sp_repr_set_svg_double(repr, "unicode-range", face->unicode_range);
789     sp_repr_set_svg_double(repr, "units-per-em", face->units_per_em);
790     //sp_repr_set_svg_double(repr, "panose-1", face->panose_1);
791     sp_repr_set_svg_double(repr, "stemv", face->stemv);
792     sp_repr_set_svg_double(repr, "stemh", face->stemh);
793     sp_repr_set_svg_double(repr, "slope", face->slope);
794     sp_repr_set_svg_double(repr, "cap-height", face->cap_height);
795     sp_repr_set_svg_double(repr, "x-height", face->x_height);
796     sp_repr_set_svg_double(repr, "accent-height", face->accent_height);
797     sp_repr_set_svg_double(repr, "ascent", face->ascent);
798     sp_repr_set_svg_double(repr, "descent", face->descent);
799     //sp_repr_set_svg_double(repr, "widths", face->widths);
800     //sp_repr_set_svg_double(repr, "bbox", face->bbox);
801     sp_repr_set_svg_double(repr, "ideographic", face->ideographic);
802     sp_repr_set_svg_double(repr, "alphabetic", face->alphabetic);
803     sp_repr_set_svg_double(repr, "mathematical", face->mathematical);
804     sp_repr_set_svg_double(repr, "hanging", face->hanging);
805     sp_repr_set_svg_double(repr, "v-ideographic", face->v_ideographic);
806     sp_repr_set_svg_double(repr, "v-alphabetic", face->v_alphabetic);
807     sp_repr_set_svg_double(repr, "v-mathematical", face->v_mathematical);
808     sp_repr_set_svg_double(repr, "v-hanging", face->v_hanging);
809     sp_repr_set_svg_double(repr, "underline-position", face->underline_position);
810     sp_repr_set_svg_double(repr, "underline-thickness", face->underline_thickness);
811     sp_repr_set_svg_double(repr, "strikethrough-position", face->strikethrough_position);
812     sp_repr_set_svg_double(repr, "strikethrough-thickness", face->strikethrough_thickness);
813     sp_repr_set_svg_double(repr, "overline-position", face->overline_position);
814     sp_repr_set_svg_double(repr, "overline-thickness", face->overline_thickness);
816     if (repr != SP_OBJECT_REPR(object)) {
817         COPY_ATTR(repr, object->repr, "font-family");
818         COPY_ATTR(repr, object->repr, "font-style");
819         COPY_ATTR(repr, object->repr, "font-variant");
820         COPY_ATTR(repr, object->repr, "font-weight");
821         COPY_ATTR(repr, object->repr, "font-stretch");
822         COPY_ATTR(repr, object->repr, "font-size");
823         COPY_ATTR(repr, object->repr, "unicode-range");
824         COPY_ATTR(repr, object->repr, "units-per-em");
825         COPY_ATTR(repr, object->repr, "panose-1");
826         COPY_ATTR(repr, object->repr, "stemv");
827         COPY_ATTR(repr, object->repr, "stemh");
828         COPY_ATTR(repr, object->repr, "slope");
829         COPY_ATTR(repr, object->repr, "cap-height");
830         COPY_ATTR(repr, object->repr, "x-height");
831         COPY_ATTR(repr, object->repr, "accent-height");
832         COPY_ATTR(repr, object->repr, "ascent");
833         COPY_ATTR(repr, object->repr, "descent");
834         COPY_ATTR(repr, object->repr, "widths");
835         COPY_ATTR(repr, object->repr, "bbox");
836         COPY_ATTR(repr, object->repr, "ideographic");
837         COPY_ATTR(repr, object->repr, "alphabetic");
838         COPY_ATTR(repr, object->repr, "mathematical");
839         COPY_ATTR(repr, object->repr, "hanging");
840         COPY_ATTR(repr, object->repr, "v-ideographic");
841         COPY_ATTR(repr, object->repr, "v-alphabetic");
842         COPY_ATTR(repr, object->repr, "v-mathematical");
843         COPY_ATTR(repr, object->repr, "v-hanging");
844         COPY_ATTR(repr, object->repr, "underline-position");
845         COPY_ATTR(repr, object->repr, "underline-thickness");
846         COPY_ATTR(repr, object->repr, "strikethrough-position");
847         COPY_ATTR(repr, object->repr, "strikethrough-thickness");
848         COPY_ATTR(repr, object->repr, "overline-position");
849         COPY_ATTR(repr, object->repr, "overline-thickness");
850     }
852     if (((SPObjectClass *) (parent_class))->write) {
853         ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
854     }
856     return repr;
858 #endif //#ifdef ENABLE_SVG_FONTS
859 /*
860   Local Variables:
861   mode:c++
862   c-file-style:"stroustrup"
863   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
864   indent-tabs-mode:nil
865   fill-column:99
866   End:
867 */
868 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :