From: JucaBlues Date: Thu, 8 May 2008 03:44:07 +0000 (+0000) Subject: distinguish between hkern and vkern tags X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1f29ece7a5be5230692c25ff5132d46b20dcd692;p=inkscape.git distinguish between hkern and vkern tags --- diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index a8609f5ee..6d7006f57 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -30,7 +30,7 @@ static void sp_glyph_kerning_update(SPObject *object, SPCtx *ctx, guint flags); static SPObjectClass *parent_class; -GType sp_glyph_kerning_get_type(void) +GType sp_glyph_kerning_h_get_type(void) { static GType type = 0; @@ -42,12 +42,35 @@ GType sp_glyph_kerning_get_type(void) (GClassInitFunc) sp_glyph_kerning_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof(SPGlyphKerning), + sizeof(SPHkern), 16, /* n_preallocs */ (GInstanceInitFunc) sp_glyph_kerning_init, NULL, /* value_table */ }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPGlyphKerning", &info, (GTypeFlags) 0); + type = g_type_register_static(SP_TYPE_OBJECT, "SPHkern", &info, (GTypeFlags) 0); + } + + return type; +} + +GType sp_glyph_kerning_v_get_type(void) +{ + static GType type = 0; + + if (!type) { + GTypeInfo info = { + sizeof(SPGlyphKerningClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) sp_glyph_kerning_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(SPVkern), + 16, /* n_preallocs */ + (GInstanceInitFunc) sp_glyph_kerning_init, + NULL, /* value_table */ + }; + type = g_type_register_static(SP_TYPE_OBJECT, "SPVkern", &info, (GTypeFlags) 0); } return type; @@ -100,39 +123,40 @@ static void sp_glyph_kerning_release(SPObject *object) static void sp_glyph_kerning_set(SPObject *object, unsigned int key, const gchar *value) { - SPGlyphKerning *glyphkern = SP_GLYPH_KERNING(object); + SPGlyphKerning * glyphkern = (SPGlyphKerning*) object; //even if it is a VKern this will work. I did it this way just to avoind warnings. double number; + const char* tag = (SP_IS_HKERN(object) ? "hkern" : "vkern"); switch (key) { case SP_ATTR_U1: if (glyphkern->u1) g_free(glyphkern->u1); glyphkern->u1 = g_strdup(value);//todo: object->requestModified(SP_OBJECT_MODIFIED_FLAG); -g_warning(": SP_ATTR_U1: %s", value); +g_warning("<%s>: SP_ATTR_U1: %s", tag, value); break; case SP_ATTR_U2: if (glyphkern->u2) g_free(glyphkern->u2); glyphkern->u2 = g_strdup(value);//todo: object->requestModified(SP_OBJECT_MODIFIED_FLAG); -g_warning(": SP_ATTR_U2: %s", value); +g_warning("<%s>: SP_ATTR_U2: %s", tag, value); break; case SP_ATTR_G1: if (glyphkern->g1) g_free(glyphkern->g1); glyphkern->g1 = g_strdup(value);//todo: object->requestModified(SP_OBJECT_MODIFIED_FLAG); -g_warning(": SP_ATTR_G1: %s", value); +g_warning("<%s>: SP_ATTR_G1: %s", tag, value); break; case SP_ATTR_G2: if (glyphkern->g2) g_free(glyphkern->g2); glyphkern->g2 = g_strdup(value);//todo: object->requestModified(SP_OBJECT_MODIFIED_FLAG); -g_warning(": SP_ATTR_G2: %s", value); +g_warning("<%s>: SP_ATTR_G2: %s", tag, value); break; case SP_ATTR_K: number = helperfns_read_number(value); if (number != glyphkern->k){ glyphkern->k = number; -g_warning(": SP_ATTR_K: %f", number); +g_warning("<%s>: SP_ATTR_K: %f", tag, number); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } break; @@ -142,6 +166,7 @@ g_warning(": SP_ATTR_K: %f", number); } break; } +///should free tag? } /** @@ -150,7 +175,7 @@ g_warning(": SP_ATTR_K: %f", number); static void sp_glyph_kerning_update(SPObject *object, SPCtx *ctx, guint flags) { - SPGlyphKerning *glyph = SP_GLYPH_KERNING(object); + SPGlyphKerning *glyph = (SPGlyphKerning *)object; (void)glyph; if (flags & SP_OBJECT_MODIFIED_FLAG) { diff --git a/src/sp-glyph-kerning.h b/src/sp-glyph-kerning.h index 40a2afe0f..2933a8abe 100644 --- a/src/sp-glyph-kerning.h +++ b/src/sp-glyph-kerning.h @@ -14,11 +14,17 @@ #include "sp-object.h" -#define SP_TYPE_GLYPH_KERNING (sp_glyph_kerning_get_type ()) -#define SP_GLYPH_KERNING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_GLYPH_KERNING, SPGlyphKerning)) -#define SP_GLYPH_KERNING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_GLYPH_KERNING, SPGlyphKerningClass)) -#define SP_IS_GLYPH_KERNING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_GLYPH_KERNING)) -#define SP_IS_GLYPH_KERNING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_GLYPH_KERNING)) +#define SP_TYPE_HKERN (sp_glyph_kerning_h_get_type ()) +#define SP_HKERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_HKERN, SPHkern)) +#define SP_HKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_HKERN, SPGlyphKerningClass)) +#define SP_IS_HKERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_HKERN)) +#define SP_IS_HKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_HKERN)) + +#define SP_TYPE_VKERN (sp_glyph_kerning_v_get_type ()) +#define SP_VKERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_VKERN, SPVkern)) +#define SP_VKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_VKERN, SPGlyphKerningClass)) +#define SP_IS_VKERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_VKERN)) +#define SP_IS_VKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_VKERN)) struct SPGlyphKerning : public SPObject { char* u1; @@ -28,10 +34,14 @@ struct SPGlyphKerning : public SPObject { double k; }; +struct SPHkern : public SPGlyphKerning {}; +struct SPVkern : public SPGlyphKerning {}; + struct SPGlyphKerningClass { SPObjectClass parent_class; }; -GType sp_glyph_kerning_get_type (void); +GType sp_glyph_kerning_h_get_type (void); +GType sp_glyph_kerning_v_get_type (void); #endif //#ifndef __SP_GLYPH_KERNING_H__ diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index 2fc828166..aa59fcb91 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -146,7 +146,8 @@ populate_dtables() { "svg:font", SP_TYPE_FONT }, { "svg:glyph", SP_TYPE_GLYPH }, { "svg:missing-glyph", SP_TYPE_MISSING_GLYPH }, - { "svg:hkern", SP_TYPE_GLYPH_KERNING }, + { "svg:hkern", SP_TYPE_HKERN }, + { "svg:vkern", SP_TYPE_VKERN }, { "svg:g", SP_TYPE_GROUP }, { "svg:feBlend", SP_TYPE_FEBLEND }, { "svg:feColorMatrix", SP_TYPE_FECOLORMATRIX },