Code

attribute loading for font-face tag
authorJucaBlues <JucaBlues@users.sourceforge.net>
Sat, 10 May 2008 02:32:09 +0000 (02:32 +0000)
committerJucaBlues <JucaBlues@users.sourceforge.net>
Sat, 10 May 2008 02:32:09 +0000 (02:32 +0000)
first draft. Still incomplete.

src/Makefile_insert
src/sp-font-face.cpp [new file with mode: 0644]
src/sp-font-face.h [new file with mode: 0644]
src/sp-object-repr.cpp

index 35c1e49eda1f9fc9aee4b9a4cf44c75da0aed657..f39ad098fd17258f1ad4b63db9d556b454c74ae8 100644 (file)
@@ -209,6 +209,7 @@ libinkpre_a_SOURCES =       \
        sp-flowregion.h sp-flowregion.cpp \
        sp-flowtext.h sp-flowtext.cpp \
         sp-font.cpp sp-font.h \
+        sp-font-face.cpp sp-font-face.h \
         sp-glyph.cpp sp-glyph.h \
         sp-missing-glyph.cpp sp-missing-glyph.h \
         sp-glyph-kerning.cpp sp-glyph-kerning.h \
diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp
new file mode 100644 (file)
index 0000000..23fc1f2
--- /dev/null
@@ -0,0 +1,574 @@
+#define __SP_FONTFACE_C__
+
+/*
+ * SVG <font-face> element implementation
+ *
+ * Section 20.8.3 of the W3C SVG 1.1 spec
+ * available at: 
+ * http://www.w3.org/TR/SVG/fonts.html#FontFaceElement
+ *
+ * Author:
+ *   Felipe C. da S. Sanches <felipe.sanches@gmail.com>
+ *
+ * Copyright (C) 2008, Felipe C. da S. Sanches
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "xml/repr.h"
+#include "attributes.h"
+#include "sp-font-face.h"
+#include "document.h"
+#include "helper-fns.h"
+
+class ObjectContainer
+{
+
+public:
+    ObjectContainer(double def){
+        this->isset = false;
+        this->default_value = def;
+    }
+
+    double get(){
+        if (this->isset)
+            return this->obj;
+        else
+            return this->default_value;
+    }
+
+    void set(double val){
+        this->obj = val;
+        this->isset = true;
+    }
+
+    void unset(){
+        this->isset = false;
+    }
+
+private:
+    double obj;
+    double default_value;
+    bool isset;
+};
+
+static void sp_fontface_class_init(SPFontFaceClass *fc);
+static void sp_fontface_init(SPFontFace *font);
+
+static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
+static void sp_fontface_release(SPObject *object);
+static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *value);
+static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+
+static void sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
+static void sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child);
+static void sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags);
+
+static SPObjectClass *parent_class;
+
+GType sp_fontface_get_type(void)
+{
+    static GType type = 0;
+
+    if (!type) {
+        GTypeInfo info = {
+            sizeof(SPFontFaceClass),
+            NULL,      /* base_init */
+            NULL,      /* base_finalize */
+            (GClassInitFunc) sp_fontface_class_init,
+            NULL,      /* class_finalize */
+            NULL,      /* class_data */
+            sizeof(SPFontFace),
+            16,        /* n_preallocs */
+            (GInstanceInitFunc) sp_fontface_init,
+            NULL,      /* value_table */
+        };
+        type = g_type_register_static(SP_TYPE_OBJECT, "SPFontFace", &info, (GTypeFlags) 0);
+    }
+
+    return type;
+}
+
+static void sp_fontface_class_init(SPFontFaceClass *fc)
+{
+    SPObjectClass *sp_object_class = (SPObjectClass *) fc;
+
+    parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
+
+    sp_object_class->build = sp_fontface_build;
+    sp_object_class->release = sp_fontface_release;
+    sp_object_class->set = sp_fontface_set;
+    sp_object_class->write = sp_fontface_write;
+    sp_object_class->child_added = sp_fontface_child_added;
+    sp_object_class->remove_child = sp_fontface_remove_child;
+    sp_object_class->update = sp_fontface_update;
+}
+
+static void sp_fontface_init(SPFontFace *font)
+{
+/*
+    face->font_family = NULL;
+    //face->font_style = ;
+    //face->font_variant = ;
+    //face->font_weight = ;
+    //face->font_stretch = ;
+    face->font_size = NULL;
+    //face->unicode_range = ;
+    face->units_per_em = 1000;
+    //face->panose_1 = ;
+    face->stem_v = ;
+    face->stem_h = ;
+    face->slope = 0;
+    face->cap_height = ;
+    face->x_height = ;
+    face->accent_height = ;
+    face->ascent = ;
+    face->descent = ;
+    face->widths = NULL;
+    face->bbox = NULL;
+    face->ideographic = ;
+    face->alphabetic = ;
+    face->mathematical = ;
+    face->hanging = ;
+    face->v_ideographic = ;
+    face->v_alphabetic = ;
+    face->v_mathematical = ;
+    face->v_hanging = ;
+    face->underline_position = ;
+    face->underline_thickness = ;
+    face->strikethrough_position = ;
+    face->strikethrough_thickness = ;
+    face->overline_position = ;
+    face->overline_thickness = ;
+*/
+}
+
+static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
+{
+    if (((SPObjectClass *) (parent_class))->build) {
+        ((SPObjectClass *) (parent_class))->build(object, document, repr);
+    }
+
+    sp_object_read_attr(object, "font-family");
+    sp_object_read_attr(object, "font-style");
+    sp_object_read_attr(object, "font-variant");
+    sp_object_read_attr(object, "font-weight");
+    sp_object_read_attr(object, "font-stretch");
+    sp_object_read_attr(object, "font-size");
+    sp_object_read_attr(object, "unicode-range");
+    sp_object_read_attr(object, "units-per-em");
+    sp_object_read_attr(object, "panose-1");
+    sp_object_read_attr(object, "stem-v");
+    sp_object_read_attr(object, "stem-h");
+    sp_object_read_attr(object, "slope");
+    sp_object_read_attr(object, "cap-height");
+    sp_object_read_attr(object, "x-height");
+    sp_object_read_attr(object, "accent-height");
+    sp_object_read_attr(object, "ascent");
+    sp_object_read_attr(object, "descent");
+    sp_object_read_attr(object, "widths");
+    sp_object_read_attr(object, "bbox");
+    sp_object_read_attr(object, "ideographic");
+    sp_object_read_attr(object, "alphabetic");
+    sp_object_read_attr(object, "mathematical");
+    sp_object_read_attr(object, "ranging");
+    sp_object_read_attr(object, "v-ideogaphic");
+    sp_object_read_attr(object, "v-alphabetic");
+    sp_object_read_attr(object, "v-mathematical");
+    sp_object_read_attr(object, "v-hanging");
+    sp_object_read_attr(object, "underline-position");
+    sp_object_read_attr(object, "underline-thickness");
+    sp_object_read_attr(object, "strikethrough-position");
+    sp_object_read_attr(object, "strikethrough-thickness");
+    sp_object_read_attr(object, "overline-position");
+    sp_object_read_attr(object, "overline-thickness");
+}
+
+static void sp_fontface_children_modified(SPFontFace *sp_fontface)
+{
+}
+
+/**
+ * Callback for child_added event.
+ */
+static void
+sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
+{
+    SPFontFace *f = SP_FONTFACE(object);
+
+    if (((SPObjectClass *) parent_class)->child_added)
+        (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref);
+
+    sp_fontface_children_modified(f);
+    object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+}
+
+
+/**
+ * Callback for remove_child event.
+ */
+static void
+sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child)
+{
+    SPFontFace *f = SP_FONTFACE(object);
+
+    if (((SPObjectClass *) parent_class)->remove_child)
+        (* ((SPObjectClass *) parent_class)->remove_child)(object, child);
+
+    sp_fontface_children_modified(f);
+    object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+}
+
+static void sp_fontface_release(SPObject *object)
+{
+    //SPFontFace *font = SP_FONTFACE(object);
+
+    if (((SPObjectClass *) parent_class)->release) {
+        ((SPObjectClass *) parent_class)->release(object);
+    }
+}
+
+static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *value)
+{
+    SPFontFace *face = SP_FONTFACE(object);
+    double number;
+
+    switch (key) {
+       case SP_ATTR_UNITS_PER_EM:
+            number = helperfns_read_number(value);
+            if (number != face->units_per_em){
+                face->units_per_em = number;
+g_warning("<font-face>: SP_ATTR_UNITS_PER_EM: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_STEMV:
+            number = helperfns_read_number(value);
+            if (number != face->stemv){
+                face->stemv = number;
+g_warning("<font-face>: SP_ATTR_STEMV: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_STEMH:
+            number = helperfns_read_number(value);
+            if (number != face->stemh){
+                face->stemh = number;
+g_warning("<font-face>: SP_ATTR_STEMH: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_SLOPE:
+            number = helperfns_read_number(value);
+            if (number != face->slope){
+                face->slope = number;
+g_warning("<font-face>: SP_ATTR_SLOPE: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_CAP_HEIGHT:
+            number = helperfns_read_number(value);
+            if (number != face->cap_height){
+                face->cap_height = number;
+g_warning("<font-face>: SP_ATTR_CAP_HEIGHT: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_X_HEIGHT:
+            number = helperfns_read_number(value);
+            if (number != face->x_height){
+                face->x_height = number;
+g_warning("<font-face>: SP_ATTR_X_HEIGHT: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_ACCENT_HEIGHT:
+            number = helperfns_read_number(value);
+            if (number != face->accent_height){
+                face->accent_height = number;
+g_warning("<font-face>: SP_ATTR_ACCENT_HEIGHT: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_ASCENT:
+            number = helperfns_read_number(value);
+            if (number != face->ascent){
+                face->ascent = number;
+g_warning("<font-face>: SP_ATTR_ASCENT: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_DESCENT:
+            number = helperfns_read_number(value);
+            if (number != face->descent){
+                face->descent = number;
+g_warning("<font-face>: SP_ATTR_DESCENT: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_IDEOGRAPHIC:
+            number = helperfns_read_number(value);
+            if (number != face->ideographic){
+                face->ideographic = number;
+g_warning("<font-face>: SP_ATTR_IDEOGRAPHIC: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_ALPHABETIC:
+            number = helperfns_read_number(value);
+            if (number != face->alphabetic){
+                face->alphabetic = number;
+g_warning("<font-face>: SP_ATTR_ALPHABETIC: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_MATHEMATICAL:
+            number = helperfns_read_number(value);
+            if (number != face->mathematical){
+                face->mathematical = number;
+g_warning("<font-face>: SP_ATTR_MATHEMATICAL: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_HANGING:
+            number = helperfns_read_number(value);
+            if (number != face->hanging){
+                face->hanging = number;
+g_warning("<font-face>: SP_ATTR_HANGING: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_V_IDEOGRAPHIC:
+            number = helperfns_read_number(value);
+            if (number != face->v_ideographic){
+                face->v_ideographic = number;
+g_warning("<font-face>: SP_ATTR_V_IDEOGRAPHIC: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_V_ALPHABETIC:
+            number = helperfns_read_number(value);
+            if (number != face->v_alphabetic){
+                face->v_alphabetic = number;
+g_warning("<font-face>: SP_ATTR_V_ALPHABETIC: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_V_MATHEMATICAL:
+            number = helperfns_read_number(value);
+            if (number != face->v_mathematical){
+                face->v_mathematical = number;
+g_warning("<font-face>: SP_ATTR_V_MATHEMATICAL: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_V_HANGING:
+            number = helperfns_read_number(value);
+            if (number != face->v_hanging){
+                face->v_hanging = number;
+g_warning("<font-face>: SP_ATTR_V_HANGING: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_UNDERLINE_POSITION:
+            number = helperfns_read_number(value);
+            if (number != face->underline_position){
+                face->underline_position = number;
+g_warning("<font-face>: SP_ATTR_UNDERLINE_POSITION: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_UNDERLINE_THICKNESS:
+            number = helperfns_read_number(value);
+            if (number != face->underline_thickness){
+                face->underline_thickness = number;
+g_warning("<font-face>: SP_ATTR_UNDERLINE_THICKNESS: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_STRIKETHROUGH_POSITION:
+            number = helperfns_read_number(value);
+            if (number != face->strikethrough_position){
+                face->strikethrough_position = number;
+g_warning("<font-face>: SP_ATTR_STRIKETHROUGH_POSITION: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_STRIKETHROUGH_THICKNESS:
+            number = helperfns_read_number(value);
+            if (number != face->strikethrough_thickness){
+                face->strikethrough_thickness = number;
+g_warning("<font-face>: SP_ATTR_STRIKETHROUGH_THICKNESS: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_OVERLINE_POSITION:
+            number = helperfns_read_number(value);
+            if (number != face->overline_position){
+                face->overline_position = number;
+g_warning("<font-face>: SP_ATTR_OVERLINE_POSITION: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       case SP_ATTR_OVERLINE_THICKNESS:
+            number = helperfns_read_number(value);
+            if (number != face->overline_thickness){
+                face->overline_thickness = number;
+g_warning("<font-face>: SP_ATTR_OVERLINE_THICKNESS: %f", number);
+                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            }
+            break;
+       default:
+            if (((SPObjectClass *) (parent_class))->set) {
+                ((SPObjectClass *) (parent_class))->set(object, key, value);
+            }
+            break;
+    }
+}
+
+/**
+ * Receives update notifications.
+ */
+static void
+sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags)
+{
+    if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
+        sp_object_read_attr(object, "font-family");
+        sp_object_read_attr(object, "font-style");
+        sp_object_read_attr(object, "font-variant");
+        sp_object_read_attr(object, "font-weight");
+        sp_object_read_attr(object, "font-stretch");
+        sp_object_read_attr(object, "font-size");
+        sp_object_read_attr(object, "unicode-range");
+        sp_object_read_attr(object, "units-per-em");
+        sp_object_read_attr(object, "panose-1");
+        sp_object_read_attr(object, "stemv");
+        sp_object_read_attr(object, "stemh");
+        sp_object_read_attr(object, "slope");
+        sp_object_read_attr(object, "cap-height");
+        sp_object_read_attr(object, "x-height");
+        sp_object_read_attr(object, "accent-height");
+        sp_object_read_attr(object, "ascent");
+        sp_object_read_attr(object, "descent");
+        sp_object_read_attr(object, "widths");
+        sp_object_read_attr(object, "bbox");
+        sp_object_read_attr(object, "ideographic");
+        sp_object_read_attr(object, "alphabetic");
+        sp_object_read_attr(object, "mathematical");
+        sp_object_read_attr(object, "hanging");
+        sp_object_read_attr(object, "v-ideographic");
+        sp_object_read_attr(object, "v-alphabetic");
+        sp_object_read_attr(object, "v-mathematical");
+        sp_object_read_attr(object, "v-hanging");
+        sp_object_read_attr(object, "underline-position");
+        sp_object_read_attr(object, "underline-thickness");
+        sp_object_read_attr(object, "strikethrough-position");
+        sp_object_read_attr(object, "strikethrough-thickness");
+        sp_object_read_attr(object, "overline-position");
+        sp_object_read_attr(object, "overline-thickness");
+    }
+
+    if (((SPObjectClass *) parent_class)->update) {
+        ((SPObjectClass *) parent_class)->update(object, ctx, flags);
+    }
+}
+
+#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
+
+static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+{
+    SPFontFace *face = SP_FONTFACE(object);
+
+    if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
+        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
+        repr = xml_doc->createElement("svg:font-face");
+    }
+
+    //TODO:
+    //sp_repr_set_svg_double(repr, "font-family", face->font_family);
+    //sp_repr_set_svg_double(repr, "font-style", face->font_style);
+    //sp_repr_set_svg_double(repr, "font-variant", face->font_variant);
+    //sp_repr_set_svg_double(repr, "font-weight", face->font_weight);
+    //sp_repr_set_svg_double(repr, "font-stretch", face->font_stretch);
+    //sp_repr_set_svg_double(repr, "font-size", face->font_size);
+    //sp_repr_set_svg_double(repr, "unicode-range", face->unicode_range);
+    sp_repr_set_svg_double(repr, "units-per-em", face->units_per_em);
+    //sp_repr_set_svg_double(repr, "panose-1", face->panose_1);
+    sp_repr_set_svg_double(repr, "stemv", face->stemv);
+    sp_repr_set_svg_double(repr, "stemh", face->stemh);
+    sp_repr_set_svg_double(repr, "slope", face->slope);
+    sp_repr_set_svg_double(repr, "cap-height", face->cap_height);
+    sp_repr_set_svg_double(repr, "x-height", face->x_height);
+    sp_repr_set_svg_double(repr, "accent-height", face->accent_height);
+    sp_repr_set_svg_double(repr, "ascent", face->ascent);
+    sp_repr_set_svg_double(repr, "descent", face->descent);
+    //sp_repr_set_svg_double(repr, "widths", face->widths);
+    //sp_repr_set_svg_double(repr, "bbox", face->bbox);
+    sp_repr_set_svg_double(repr, "ideographic", face->ideographic);
+    sp_repr_set_svg_double(repr, "alphabetic", face->alphabetic);
+    sp_repr_set_svg_double(repr, "mathematical", face->mathematical);
+    sp_repr_set_svg_double(repr, "hanging", face->hanging);
+    sp_repr_set_svg_double(repr, "v-ideographic", face->v_ideographic);
+    sp_repr_set_svg_double(repr, "v-alphabetic", face->v_alphabetic);
+    sp_repr_set_svg_double(repr, "v-mathematical", face->v_mathematical);
+    sp_repr_set_svg_double(repr, "v-hanging", face->v_hanging);
+    sp_repr_set_svg_double(repr, "underline-position", face->underline_position);
+    sp_repr_set_svg_double(repr, "underline-thickness", face->underline_thickness);
+    sp_repr_set_svg_double(repr, "strikethrough-position", face->strikethrough_position);
+    sp_repr_set_svg_double(repr, "strikethrough-thickness", face->strikethrough_thickness);
+    sp_repr_set_svg_double(repr, "overline-position", face->overline_position);
+    sp_repr_set_svg_double(repr, "overline-thickness", face->overline_thickness);
+
+    if (repr != SP_OBJECT_REPR(object)) {
+        COPY_ATTR(repr, object->repr, "font-family");
+        COPY_ATTR(repr, object->repr, "font-style");
+        COPY_ATTR(repr, object->repr, "font-variant");
+        COPY_ATTR(repr, object->repr, "font-weight");
+        COPY_ATTR(repr, object->repr, "font-stretch");
+        COPY_ATTR(repr, object->repr, "font-size");
+        COPY_ATTR(repr, object->repr, "unicode-range");
+        COPY_ATTR(repr, object->repr, "units-per-em");
+        COPY_ATTR(repr, object->repr, "panose-1");
+        COPY_ATTR(repr, object->repr, "stemv");
+        COPY_ATTR(repr, object->repr, "stemh");
+        COPY_ATTR(repr, object->repr, "slope");
+        COPY_ATTR(repr, object->repr, "cap-height");
+        COPY_ATTR(repr, object->repr, "x-height");
+        COPY_ATTR(repr, object->repr, "accent-height");
+        COPY_ATTR(repr, object->repr, "ascent");
+        COPY_ATTR(repr, object->repr, "descent");
+        COPY_ATTR(repr, object->repr, "widths");
+        COPY_ATTR(repr, object->repr, "bbox");
+        COPY_ATTR(repr, object->repr, "ideographic");
+        COPY_ATTR(repr, object->repr, "alphabetic");
+        COPY_ATTR(repr, object->repr, "mathematical");
+        COPY_ATTR(repr, object->repr, "hanging");
+        COPY_ATTR(repr, object->repr, "v-ideographic");
+        COPY_ATTR(repr, object->repr, "v-alphabetic");
+        COPY_ATTR(repr, object->repr, "v-mathematical");
+        COPY_ATTR(repr, object->repr, "v-hanging");
+        COPY_ATTR(repr, object->repr, "underline-position");
+        COPY_ATTR(repr, object->repr, "underline-thickness");
+        COPY_ATTR(repr, object->repr, "strikethrough-position");
+        COPY_ATTR(repr, object->repr, "strikethrough-thickness");
+        COPY_ATTR(repr, object->repr, "overline-position");
+        COPY_ATTR(repr, object->repr, "overline-thickness");
+    }
+
+    if (((SPObjectClass *) (parent_class))->write) {
+        ((SPObjectClass *) (parent_class))->write(object, repr, flags);
+    }
+
+    return repr;
+}
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/sp-font-face.h b/src/sp-font-face.h
new file mode 100644 (file)
index 0000000..aaf0920
--- /dev/null
@@ -0,0 +1,113 @@
+#ifndef __SP_FONTFACE_H__
+#define __SP_FONTFACE_H__
+
+/*
+ * SVG <font-face> element implementation
+ *
+ * Section 20.8.3 of the W3C SVG 1.1 spec
+ * available at: 
+ * http://www.w3.org/TR/SVG/fonts.html#FontFaceElement
+ *
+ * Authors:
+ *    Felipe C. da S. Sanches <felipe.sanches@gmail.com>
+ *
+ * Copyright (C) 2008 Felipe C. da S. Sanches
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "sp-object.h"
+
+#define SP_TYPE_FONTFACE (sp_fontface_get_type ())
+#define SP_FONTFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_FONTFACE, SPFontFace))
+#define SP_FONTFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_FONTFACE, SPFontFaceClass))
+#define SP_IS_FONTFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_FONTFACE))
+#define SP_IS_FONTFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_FONTFACE))
+
+enum FontFaceStyleType{
+       SP_FONTFACE_STYLE_ALL,
+       SP_FONTFACE_STYLE_NORMAL,
+       SP_FONTFACE_STYLE_ITALIC,
+       SP_FONTFACE_STYLE_OBLIQUE
+};
+
+enum FontFaceVariantType{
+       SP_FONTFACE_VARIANT_NORMAL,
+       SP_FONTFACE_VARIANT_SMALL_CAPS
+};
+
+enum FontFaceWeightType{
+       SP_FONTFACE_WEIGHT_ALL,
+       SP_FONTFACE_WEIGHT_NORMAL,
+       SP_FONTFACE_WEIGHT_BOLD,
+       SP_FONTFACE_WEIGHT_100,
+       SP_FONTFACE_WEIGHT_200,
+       SP_FONTFACE_WEIGHT_300,
+       SP_FONTFACE_WEIGHT_400,
+       SP_FONTFACE_WEIGHT_500,
+       SP_FONTFACE_WEIGHT_600,
+       SP_FONTFACE_WEIGHT_700,
+       SP_FONTFACE_WEIGHT_800,
+       SP_FONTFACE_WEIGHT_900
+};
+
+enum FontFaceStretchType{
+       SP_FONTFACE_SRTETCH_ALL,
+       SP_FONTFACE_SRTETCH_NORMAL,
+       SP_FONTFACE_SRTETCH_ULTRA_CONDENSED,
+       SP_FONTFACE_SRTETCH_EXTRA_CONDENSED,
+       SP_FONTFACE_SRTETCH_CONDENSED,
+       SP_FONTFACE_SRTETCH_SEMI_CONDENSED,
+       SP_FONTFACE_SRTETCH_SEMI_EXPANDED,
+       SP_FONTFACE_SRTETCH_EXPANDED,
+       SP_FONTFACE_SRTETCH_EXTRA_EXPANDED,
+       SP_FONTFACE_SRTETCH_ULTRA_EXPANDED
+};
+
+enum FontFaceUnicodeRangeType{
+       FONTFACE_UNICODERANGE_FIXME_HERE,
+};
+
+struct SPFontFace : public SPObject {
+    char* font_family;
+    std::vector<FontFaceStyleType> font_style;
+    std::vector<FontFaceVariantType> font_variant;
+    std::vector<FontFaceWeightType> font_weight;
+    std::vector<FontFaceStretchType> font_stretch;
+    char* font_size;
+    std::vector<FontFaceUnicodeRangeType> unicode_range;
+    double units_per_em;
+    std::vector<int> panose_1;
+    double stemv;
+    double stemh;
+    double slope;
+    double cap_height;
+    double x_height;
+    double accent_height;
+    double ascent;
+    double descent;
+    char* widths;
+    char* bbox;
+    double ideographic;
+    double alphabetic;
+    double mathematical;
+    double hanging;
+    double v_ideographic;
+    double v_alphabetic;
+    double v_mathematical;
+    double v_hanging;
+    double underline_position;
+    double underline_thickness;
+    double strikethrough_position;
+    double strikethrough_thickness;
+    double overline_position;
+    double overline_thickness;
+};
+
+struct SPFontFaceClass {
+       SPObjectClass parent_class;
+};
+
+GType sp_fontface_get_type (void);
+
+#endif //#ifndef __SP_FONTFACE_H__
index aa59fcb911ecf3f14287d60a2293e7d9a2ee38fe..6ed2f9adab00879452af4a2803d0a47d83ec8aca 100644 (file)
@@ -44,6 +44,7 @@
 #include "sp-flowregion.h"
 #include "sp-flowtext.h"
 #include "sp-font.h"
+#include "sp-font-face.h"
 #include "sp-glyph.h"
 #include "sp-missing-glyph.h"
 #include "sp-glyph-kerning.h"
@@ -144,6 +145,7 @@ populate_dtables()
         { "svg:flowRoot", SP_TYPE_FLOWTEXT },
         { "svg:flowSpan", SP_TYPE_FLOWTSPAN },
         { "svg:font", SP_TYPE_FONT },
+        { "svg:font-face", SP_TYPE_FONTFACE },
         { "svg:glyph", SP_TYPE_GLYPH },
         { "svg:missing-glyph", SP_TYPE_MISSING_GLYPH },
         { "svg:hkern", SP_TYPE_HKERN },