summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d570df7)
raw | patch | inline | side by side (parent: d570df7)
author | JucaBlues <JucaBlues@users.sourceforge.net> | |
Wed, 27 Feb 2008 05:19:40 +0000 (05:19 +0000) | ||
committer | JucaBlues <JucaBlues@users.sourceforge.net> | |
Wed, 27 Feb 2008 05:19:40 +0000 (05:19 +0000) |
<glyph> node parameter loading
src/Makefile_insert | patch | blob | history | |
src/sp-glyph.cpp | patch | blob | history | |
src/sp-glyph.h | [new file with mode: 0644] | patch | blob |
src/sp-object-repr.cpp | patch | blob | history |
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 201f8aaf2a136440ce7c391e42f7d5053f762887..10b5efe421c6eb1832dfe3104ebded858ab2db3d 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
sp-flowregion.h sp-flowregion.cpp \
sp-flowtext.h sp-flowtext.cpp \
sp-font.cpp sp-font.h \
+ sp-glyph.cpp sp-glyph.h \
sp-gaussian-blur.cpp sp-gaussian-blur.h \
sp-gaussian-blur-fns.h \
sp-gradient-fns.h \
diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp
index 0bbe14674d256e67b2c7c1ba6c3f579a0a2c0dcb..eab219f51bfd4313731a98dbf32a6a028c6c79ad 100644 (file)
--- a/src/sp-glyph.cpp
+++ b/src/sp-glyph.cpp
#include "sp-glyph.h"
#include "document.h"
-static void sp_glyph_class_init(SPGlyphClass *fc);
+static void sp_glyph_class_init(SPGlyphClass *gc);
static void sp_glyph_init(SPGlyph *glyph);
static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
static void sp_glyph_init(SPGlyph *glyph)
{
//TODO: correct these values:
- glyph->unicode = "";
- glyph->glyph-name = "";
- glyph->d = "";
- glyph->orientation = "";
- glyph->arabic-form = "";
- glyph->lang = "";
- glyph->horiz-adv-x = 0;
- glyph->vert-origin-x = 0;
- glyph->vert-origin-y = 0;
- glyph->vert-adv-y = 0;
+ glyph->unicode = NULL;
+ glyph->glyph_name = NULL;
+ glyph->d = NULL;
+ glyph->orientation = NULL;
+ glyph->arabic_form = NULL;
+ glyph->lang = NULL;
+ glyph->horiz_adv_x = 0;
+ glyph->vert_origin_x = 0;
+ glyph->vert_origin_y = 0;
+ glyph->vert_adv_y = 0;
}
static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
@@ -123,21 +123,41 @@ static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value)
double number;
switch (key) {
- case SP_ATTR_HORIZ_ORIGIN_X:
- number = helperfns_read_number(value);
- if (number != glyph->horiz_origin_x){
- glyph->horiz_origin_x = number;
-g_warning("SP_ATTR_HORIZ_ORIGIN_X: %f", number);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- }
+ case SP_ATTR_UNICODE:
+ if (glyph->unicode) g_free(glyph->unicode);
+ glyph->unicode = g_strdup(value);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+g_warning("SP_ATTR_UNICODE: %s", value);
+ break;
+ case SP_ATTR_GLYPH_NAME:
+ if (glyph->glyph_name) g_free(glyph->glyph_name);
+ glyph->glyph_name = g_strdup(value);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+g_warning("SP_ATTR_GLYPH_NAME: %s", value);
+ break;
+ case SP_ATTR_D:
+ if (glyph->d) g_free(glyph->d);
+ glyph->d = g_strdup(value);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+g_warning("SP_ATTR_D: %s", value);
break;
- case SP_ATTR_HORIZ_ORIGIN_Y:
- number = helperfns_read_number(value);
- if (number != glyph->horiz_origin_y){
- glyph->horiz_origin_y = number;
-g_warning("SP_ATTR_HORIZ_ORIGIN_Y: %f", number);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- }
+ case SP_ATTR_ORIENTATION:
+ if (glyph->orientation) g_free(glyph->orientation);
+ glyph->orientation = g_strdup(value);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+g_warning("SP_ATTR_ORIENTATION: %s", value);
+ break;
+ case SP_ATTR_ARABIC_FORM:
+ if (glyph->arabic_form) g_free(glyph->arabic_form);
+ glyph->arabic_form = g_strdup(value);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+g_warning("SP_ATTR_ARABIC_FORM: %s", value);
+ break;
+ case SP_ATTR_LANG:
+ if (glyph->lang) g_free(glyph->lang);
+ glyph->lang = g_strdup(value);
+g_warning("SP_ATTR_LANG: %s", value);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_HORIZ_ADV_X:
number = helperfns_read_number(value);
@@ -190,16 +210,24 @@ static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Node
repr = xml_doc->createElement("svg:glyph");
}
- sp_repr_set_svg_double(repr, "horiz-origin-x", glyph->horiz_origin_x);
- sp_repr_set_svg_double(repr, "horiz-origin-y", glyph->horiz_origin_y);
+ repr->setAttribute("unicode", glyph->unicode);
+ repr->setAttribute("glyph-name", glyph->glyph_name);
+ repr->setAttribute("d", glyph->d);
+ repr->setAttribute("orientation", glyph->orientation);
+ repr->setAttribute("arabic-form", glyph->arabic_form);
+ repr->setAttribute("lang", glyph->lang);
sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x);
sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x);
sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y);
sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y);
if (repr != SP_OBJECT_REPR(object)) {
- COPY_ATTR(repr, object->repr, "horiz-origin-x");
- COPY_ATTR(repr, object->repr, "horiz-origin-y");
+ COPY_ATTR(repr, object->repr, "unicode");
+ COPY_ATTR(repr, object->repr, "glyph-name");
+ COPY_ATTR(repr, object->repr, "d");
+ COPY_ATTR(repr, object->repr, "orientation");
+ COPY_ATTR(repr, object->repr, "arabic-form");
+ COPY_ATTR(repr, object->repr, "lang");
COPY_ATTR(repr, object->repr, "horiz-adv-x");
COPY_ATTR(repr, object->repr, "vert-origin-x");
COPY_ATTR(repr, object->repr, "vert-origin-y");
diff --git a/src/sp-glyph.h b/src/sp-glyph.h
--- /dev/null
+++ b/src/sp-glyph.h
@@ -0,0 +1,42 @@
+#ifndef __SP_GLYPH_H__
+#define __SP_GLYPH_H__
+
+/*
+ * SVG <glyph> element implementation
+ *
+ * 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_GLYPH (sp_glyph_get_type ())
+#define SP_GLYPH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_GLYPH, SPGlyph))
+#define SP_GLYPH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_GLYPH, SPGlyphClass))
+#define SP_IS_GLYPH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_GLYPH))
+#define SP_IS_GLYPH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_GLYPH))
+
+struct SPGlyph : public SPObject {
+ char* unicode;
+ char* glyph_name;
+ char* d;
+ char* orientation;
+ char* arabic_form;
+ char* lang;
+ double horiz_adv_x;
+ double vert_origin_x;
+ double vert_origin_y;
+ double vert_adv_y;
+};
+
+struct SPGlyphClass {
+ SPObjectClass parent_class;
+};
+
+GType sp_glyph_get_type (void);
+
+#endif //#ifndef __SP_GLYPH_H__
diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp
index 577ff1690f1d4ef26e2fd4723d46d7d263f4bd01..5a49c35aa33be50c0160264d83931fde7440a794 100644 (file)
--- a/src/sp-object-repr.cpp
+++ b/src/sp-object-repr.cpp
#include "sp-flowregion.h"
#include "sp-flowtext.h"
#include "sp-font.h"
+#include "sp-glyph.h"
#include "sp-style-elem.h"
#include "sp-switch.h"
#include "color-profile-fns.h"
{ "svg:flowRoot", SP_TYPE_FLOWTEXT },
{ "svg:flowSpan", SP_TYPE_FLOWTSPAN },
{ "svg:font", SP_TYPE_FONT },
+ { "svg:glyph", SP_TYPE_GLYPH },
{ "svg:g", SP_TYPE_GROUP },
{ "svg:feBlend", SP_TYPE_FEBLEND },
{ "svg:feColorMatrix", SP_TYPE_FECOLORMATRIX },