sp-font.cpp revision 39e454bdef986f01ef929a38513fc09b4ae80e32
153bb1867986d6db392e2cfa711ad6231fce8abeJon A. Cruz#ifdef HAVE_CONFIG_H
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh# include <config.h>
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#endif
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#ifdef ENABLE_SVG_FONTS
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh/*
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * SVG <font> element implementation
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh *
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Author:
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Felipe C. da S. Sanches <juca@members.fsf.org>
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh *
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Copyright (C) 2008, Felipe C. da S. Sanches
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh *
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Released under GNU GPL, read the file 'COPYING' for more information
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh */
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
75b857d473541532819bd791105cb352c9a43214buliabyak#include "xml/repr.h"
75b857d473541532819bd791105cb352c9a43214buliabyak#include "attributes.h"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#include "sp-font.h"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#include "sp-glyph.h"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#include "sp-missing-glyph.h"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#include "document.h"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh#include "display/nr-svgfonts.h"
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshstatic void sp_font_class_init(SPFontClass *fc);
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshstatic void sp_font_init(SPFont *font);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshstatic void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshstatic void sp_font_release(SPObject *object);
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshstatic void sp_font_set(SPObject *object, unsigned int key, const gchar *value);
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshstatic Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshstatic void sp_font_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
c751b68e56ace7b9d649ee20b7f25ed1f65922e3Matthew Petroffstatic void sp_font_remove_child(SPObject *object, Inkscape::XML::Node *child);
3711b3e25395437ee0a09dbbb2a76d999c4ef322mikloshstatic void sp_font_update(SPObject *object, SPCtx *ctx, guint flags);
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh
b5b35fce2e3df933e5223ef6645d814eacf51cfamiklosh// static gchar *sp_font_description(SPItem *item);
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshstatic SPObjectClass *parent_class;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshGType sp_font_get_type(void)
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh{
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh static GType type = 0;
dc4f69a188c203f2fdc65f22d0d57904a8c52dd7miklosh
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh if (!type) {
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh GTypeInfo info = {
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sizeof(SPFontClass),
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh NULL, /* base_init */
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh NULL, /* base_finalize */
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh (GClassInitFunc) sp_font_class_init,
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh NULL, /* class_finalize */
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh NULL, /* class_data */
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh sizeof(SPFont),
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh 16, /* n_preallocs */
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh (GInstanceInitFunc) sp_font_init,
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh NULL, /* value_table */
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh };
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh type = g_type_register_static(SP_TYPE_OBJECT, "SPFont", &info, (GTypeFlags) 0);
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh }
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh return type;
63e32b5fcb40d1d6ceffa7fa1f03e679cb694b23Jon A. Cruz}
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emikloshstatic void sp_font_class_init(SPFontClass *fc)
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh{
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh SPObjectClass *sp_object_class = (SPObjectClass *) fc;
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh sp_object_class->build = sp_font_build;
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh sp_object_class->release = sp_font_release;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_class->set = sp_font_set;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_class->write = sp_font_write;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_class->child_added = sp_font_child_added;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_class->remove_child = sp_font_remove_child;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_class->update = sp_font_update;
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz}
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz
1cda9431ef400135f5e1bd899a94b921bdad0eafmiklosh//I think we should have extra stuff here and in the set method in order to set default value as specified at http://www.w3.org/TR/SVG/fonts.html
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh
68664e00e2372534b4df2fdc5f54f836bafece18miklosh// TODO determine better values and/or make these dynamic:
dc4f69a188c203f2fdc65f22d0d57904a8c52dd7mikloshdouble FNT_DEFAULT_ADV = 90; // TODO determine proper default
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruzdouble FNT_DEFAULT_ASCENT = 90; // TODO determine proper default
3711b3e25395437ee0a09dbbb2a76d999c4ef322mikloshdouble FNT_UNITS_PER_EM = 90; // TODO determine proper default
a4d12a5147f3d1d6b568a326e39ef5dca384248dmiklosh
1667116521643e2475184b048e0abb77a2aa9735mikloshstatic void sp_font_init(SPFont *font)
cb814cb0df20053ca3ef16ce55da474435daf045miklosh{
cb814cb0df20053ca3ef16ce55da474435daf045miklosh font->horiz_origin_x = 0;
cb814cb0df20053ca3ef16ce55da474435daf045miklosh font->horiz_origin_y = 0;
cb814cb0df20053ca3ef16ce55da474435daf045miklosh font->horiz_adv_x = FNT_DEFAULT_ADV;
75b857d473541532819bd791105cb352c9a43214buliabyak font->vert_origin_x = FNT_DEFAULT_ADV / 2.0;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh font->vert_origin_y = FNT_DEFAULT_ASCENT;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh font->vert_adv_y = FNT_UNITS_PER_EM;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh}
1cda9431ef400135f5e1bd899a94b921bdad0eafmiklosh
3711b3e25395437ee0a09dbbb2a76d999c4ef322mikloshstatic void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
68664e00e2372534b4df2fdc5f54f836bafece18miklosh{
dc4f69a188c203f2fdc65f22d0d57904a8c52dd7miklosh if (((SPObjectClass *) (parent_class))->build) {
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh ((SPObjectClass *) (parent_class))->build(object, document, repr);
cb814cb0df20053ca3ef16ce55da474435daf045miklosh }
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh
1667116521643e2475184b048e0abb77a2aa9735miklosh sp_object_read_attr(object, "horiz-origin-x");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "horiz-origin-y");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "horiz-adv-x");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "vert-origin-x");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "vert-origin-y");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "vert-adv-y");
1667116521643e2475184b048e0abb77a2aa9735miklosh
1667116521643e2475184b048e0abb77a2aa9735miklosh document->add_resource("font", object);
1667116521643e2475184b048e0abb77a2aa9735miklosh}
f9ab06d037336cf8796b54c94a119f40eda79a46Kris
f9ab06d037336cf8796b54c94a119f40eda79a46Kris
f9ab06d037336cf8796b54c94a119f40eda79a46Krisstatic void sp_font_children_modified(SPFont */*sp_font*/)
f9ab06d037336cf8796b54c94a119f40eda79a46Kris{
f9ab06d037336cf8796b54c94a119f40eda79a46Kris}
1667116521643e2475184b048e0abb77a2aa9735miklosh
f9ab06d037336cf8796b54c94a119f40eda79a46Kris/**
f9ab06d037336cf8796b54c94a119f40eda79a46Kris * Callback for child_added event.
1667116521643e2475184b048e0abb77a2aa9735miklosh */
75b857d473541532819bd791105cb352c9a43214buliabyakstatic void
be17b6e6b80af045ef40c635ea563ebd987269b8tavmjong-freesp_font_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
be17b6e6b80af045ef40c635ea563ebd987269b8tavmjong-free{
be17b6e6b80af045ef40c635ea563ebd987269b8tavmjong-free SPFont *f = SP_FONT(object);
be17b6e6b80af045ef40c635ea563ebd987269b8tavmjong-free
be17b6e6b80af045ef40c635ea563ebd987269b8tavmjong-free if (((SPObjectClass *) parent_class)->child_added)
75b857d473541532819bd791105cb352c9a43214buliabyak (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref);
75b857d473541532819bd791105cb352c9a43214buliabyak
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh sp_font_children_modified(f);
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh}
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh
1667116521643e2475184b048e0abb77a2aa9735miklosh/**
7ddc475794d846646261f6b12015d44ac361d070Kris De Gussem * Callback for remove_child event.
7ddc475794d846646261f6b12015d44ac361d070Kris De Gussem */
7ddc475794d846646261f6b12015d44ac361d070Kris De Gussemstatic void
1667116521643e2475184b048e0abb77a2aa9735mikloshsp_font_remove_child(SPObject *object, Inkscape::XML::Node *child)
1667116521643e2475184b048e0abb77a2aa9735miklosh{
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh SPFont *f = SP_FONT(object);
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh if (((SPObjectClass *) parent_class)->remove_child)
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh (* ((SPObjectClass *) parent_class)->remove_child)(object, child);
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_font_children_modified(f);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
68664e00e2372534b4df2fdc5f54f836bafece18miklosh}
68664e00e2372534b4df2fdc5f54f836bafece18miklosh
68664e00e2372534b4df2fdc5f54f836bafece18mikloshstatic void sp_font_release(SPObject *object)
68664e00e2372534b4df2fdc5f54f836bafece18miklosh{
68664e00e2372534b4df2fdc5f54f836bafece18miklosh //SPFont *font = SP_FONT(object);
68664e00e2372534b4df2fdc5f54f836bafece18miklosh SP_OBJECT_DOCUMENT(object)->remove_resource("font", object);
68664e00e2372534b4df2fdc5f54f836bafece18miklosh
68664e00e2372534b4df2fdc5f54f836bafece18miklosh if (((SPObjectClass *) parent_class)->release) {
68664e00e2372534b4df2fdc5f54f836bafece18miklosh ((SPObjectClass *) parent_class)->release(object);
68664e00e2372534b4df2fdc5f54f836bafece18miklosh }
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh}
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emikloshstatic void sp_font_set(SPObject *object, unsigned int key, const gchar *value)
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh{
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh SPFont *font = SP_FONT(object);
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh // TODO these are floating point, so some epsilon comparison would be good
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh switch (key) {
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh case SP_ATTR_HORIZ_ORIGIN_X:
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh {
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh double number = value ? g_ascii_strtod(value, 0) : 0;
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh if (number != font->horiz_origin_x){
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh font->horiz_origin_x = number;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh object->requestModified(SP_OBJECT_MODIFIED_FLAG);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh }
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh break;
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh }
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh case SP_ATTR_HORIZ_ORIGIN_Y:
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh {
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh double number = value ? g_ascii_strtod(value, 0) : 0;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh if (number != font->horiz_origin_y){
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh font->horiz_origin_y = number;
1667116521643e2475184b048e0abb77a2aa9735miklosh object->requestModified(SP_OBJECT_MODIFIED_FLAG);
1667116521643e2475184b048e0abb77a2aa9735miklosh }
1667116521643e2475184b048e0abb77a2aa9735miklosh break;
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh }
1667116521643e2475184b048e0abb77a2aa9735miklosh case SP_ATTR_HORIZ_ADV_X:
1667116521643e2475184b048e0abb77a2aa9735miklosh {
1667116521643e2475184b048e0abb77a2aa9735miklosh double number = value ? g_ascii_strtod(value, 0) : FNT_DEFAULT_ADV;
1667116521643e2475184b048e0abb77a2aa9735miklosh if (number != font->horiz_adv_x){
1667116521643e2475184b048e0abb77a2aa9735miklosh font->horiz_adv_x = number;
1667116521643e2475184b048e0abb77a2aa9735miklosh object->requestModified(SP_OBJECT_MODIFIED_FLAG);
1667116521643e2475184b048e0abb77a2aa9735miklosh }
1667116521643e2475184b048e0abb77a2aa9735miklosh break;
1667116521643e2475184b048e0abb77a2aa9735miklosh }
1667116521643e2475184b048e0abb77a2aa9735miklosh case SP_ATTR_VERT_ORIGIN_X:
1667116521643e2475184b048e0abb77a2aa9735miklosh {
1667116521643e2475184b048e0abb77a2aa9735miklosh double number = value ? g_ascii_strtod(value, 0) : FNT_DEFAULT_ADV / 2.0;
1667116521643e2475184b048e0abb77a2aa9735miklosh if (number != font->vert_origin_x){
1667116521643e2475184b048e0abb77a2aa9735miklosh font->vert_origin_x = number;
1667116521643e2475184b048e0abb77a2aa9735miklosh object->requestModified(SP_OBJECT_MODIFIED_FLAG);
1667116521643e2475184b048e0abb77a2aa9735miklosh }
1667116521643e2475184b048e0abb77a2aa9735miklosh break;
1667116521643e2475184b048e0abb77a2aa9735miklosh }
1667116521643e2475184b048e0abb77a2aa9735miklosh case SP_ATTR_VERT_ORIGIN_Y:
1667116521643e2475184b048e0abb77a2aa9735miklosh {
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh double number = value ? g_ascii_strtod(value, 0) : FNT_DEFAULT_ASCENT;
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh if (number != font->vert_origin_y){
68664e00e2372534b4df2fdc5f54f836bafece18miklosh font->vert_origin_y = number;
1cda9431ef400135f5e1bd899a94b921bdad0eafmiklosh object->requestModified(SP_OBJECT_MODIFIED_FLAG);
68664e00e2372534b4df2fdc5f54f836bafece18miklosh }
68664e00e2372534b4df2fdc5f54f836bafece18miklosh break;
68664e00e2372534b4df2fdc5f54f836bafece18miklosh }
68664e00e2372534b4df2fdc5f54f836bafece18miklosh case SP_ATTR_VERT_ADV_Y:
68664e00e2372534b4df2fdc5f54f836bafece18miklosh {
68664e00e2372534b4df2fdc5f54f836bafece18miklosh double number = value ? g_ascii_strtod(value, 0) : FNT_UNITS_PER_EM;
68664e00e2372534b4df2fdc5f54f836bafece18miklosh if (number != font->vert_adv_y){
68664e00e2372534b4df2fdc5f54f836bafece18miklosh font->vert_adv_y = number;
68664e00e2372534b4df2fdc5f54f836bafece18miklosh object->requestModified(SP_OBJECT_MODIFIED_FLAG);
13c1b2b6c3fc75e657813da1865541253a2b1dceapenner }
1c03744513f6db77018fe703507fe04011c20b09Krzysztof Kosiński break;
1c03744513f6db77018fe703507fe04011c20b09Krzysztof Kosiński }
1c03744513f6db77018fe703507fe04011c20b09Krzysztof Kosiński default:
13c1b2b6c3fc75e657813da1865541253a2b1dceapenner if (((SPObjectClass *) (parent_class))->set) {
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh ((SPObjectClass *) (parent_class))->set(object, key, value);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh }
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh break;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh }
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh}
1667116521643e2475184b048e0abb77a2aa9735miklosh
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh/**
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Receives update notifications.
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh */
3711b3e25395437ee0a09dbbb2a76d999c4ef322mikloshstatic void
7a7fa095a483e8b652af9f00e5169f62c84f09b9mikloshsp_font_update(SPObject *object, SPCtx *ctx, guint flags)
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh{
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh sp_object_read_attr(object, "horiz-origin-x");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "horiz-origin-y");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "horiz-adv-x");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "vert-origin-x");
d9a7c806ee7f408ddb61ff4f233c9d96111ee2b5johanengelen sp_object_read_attr(object, "vert-origin-y");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_object_read_attr(object, "vert-adv-y");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh }
fba63a357654d8b3e84c60007e40aa698cd45d19miklosh
d9a7c806ee7f408ddb61ff4f233c9d96111ee2b5johanengelen if (((SPObjectClass *) parent_class)->update) {
d9a7c806ee7f408ddb61ff4f233c9d96111ee2b5johanengelen ((SPObjectClass *) parent_class)->update(object, ctx, flags);
d9a7c806ee7f408ddb61ff4f233c9d96111ee2b5johanengelen }
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh}
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
d27f5758e12c3107ee69e66702043931e0756f6bmikloshstatic Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
d27f5758e12c3107ee69e66702043931e0756f6bmiklosh{
d27f5758e12c3107ee69e66702043931e0756f6bmiklosh SPFont *font = SP_FONT(object);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh repr = xml_doc->createElement("svg:font");
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh }
b5b35fce2e3df933e5223ef6645d814eacf51cfamiklosh
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen sp_repr_set_svg_double(repr, "horiz-origin-x", font->horiz_origin_x);
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh sp_repr_set_svg_double(repr, "horiz-origin-y", font->horiz_origin_y);
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh sp_repr_set_svg_double(repr, "horiz-adv-x", font->horiz_adv_x);
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh sp_repr_set_svg_double(repr, "vert-origin-x", font->vert_origin_x);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_repr_set_svg_double(repr, "vert-origin-y", font->vert_origin_y);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh sp_repr_set_svg_double(repr, "vert-adv-y", font->vert_adv_y);
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh if (repr != SP_OBJECT_REPR(object)) {
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh /*All the below COPY_ATTR funtions are directly using
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh the XML Tree while they shouldn't*/
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh COPY_ATTR(repr, object->getRepr(), "horiz-origin-x");
0c6b51649b501e4e378921d918c6a113ab8e2bceJohan B. C. Engelen COPY_ATTR(repr, object->getRepr(), "horiz-origin-y");
0c6b51649b501e4e378921d918c6a113ab8e2bceJohan B. C. Engelen COPY_ATTR(repr, object->getRepr(), "horiz-adv-x");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh COPY_ATTR(repr, object->getRepr(), "vert-origin-x");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh COPY_ATTR(repr, object->getRepr(), "vert-origin-y");
0c6b51649b501e4e378921d918c6a113ab8e2bceJohan B. C. Engelen COPY_ATTR(repr, object->getRepr(), "vert-adv-y");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh }
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh if (((SPObjectClass *) (parent_class))->write) {
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh }
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh return repr;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh}
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#endif //#ifdef ENABLE_SVG_FONTS
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh/*
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh Local Variables:
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh mode:c++
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh c-file-style:"stroustrup"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh indent-tabs-mode:nil
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh fill-column:99
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh End:
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh*/
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh