summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 64a590d)
raw | patch | inline | side by side (parent: 64a590d)
author | JucaBlues <JucaBlues@users.sourceforge.net> | |
Thu, 8 May 2008 03:44:07 +0000 (03:44 +0000) | ||
committer | JucaBlues <JucaBlues@users.sourceforge.net> | |
Thu, 8 May 2008 03:44:07 +0000 (03:44 +0000) |
src/sp-glyph-kerning.cpp | patch | blob | history | |
src/sp-glyph-kerning.h | patch | blob | history | |
src/sp-object-repr.cpp | patch | blob | history |
index a8609f5ee3b7b0bdb0605a2193bf6fb7e71e8dd2..6d7006f577a89e1df10445bcefb59399d136ac39 100644 (file)
--- a/src/sp-glyph-kerning.cpp
+++ b/src/sp-glyph-kerning.cpp
static SPObjectClass *parent_class;
-GType sp_glyph_kerning_get_type(void)
+GType sp_glyph_kerning_h_get_type(void)
{
static GType type = 0;
(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;
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("<glyph-kerning>: 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("<glyph-kerning>: 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("<glyph-kerning>: 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("<glyph-kerning>: 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("<glyph-kerning>: SP_ATTR_K: %f", number);
+g_warning("<%s>: SP_ATTR_K: %f", tag, number);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
break;
}
+///should free tag?
}
/**
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 40a2afe0f9819fbb25c80c93c4e9f7e03d9e9703..2933a8abe578ce36b0ca3ae3ffdadb02f6b6bce4 100644 (file)
--- a/src/sp-glyph-kerning.h
+++ b/src/sp-glyph-kerning.h
#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;
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 2fc8281660109134840e80614b42537d209cbc6b..aa59fcb911ecf3f14287d60a2293e7d9a2ee38fe 100644 (file)
--- a/src/sp-object-repr.cpp
+++ b/src/sp-object-repr.cpp
{ "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 },