index 6d7006f577a89e1df10445bcefb59399d136ac39..b3d0e8cbae681ec12985c36e1cd2fb6ce7998a65 100644 (file)
--- a/src/sp-glyph-kerning.cpp
+++ b/src/sp-glyph-kerning.cpp
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef ENABLE_SVG_FONTS
#define __SP_ANCHOR_C__
/*
#define __SP_ANCHOR_C__
/*
#include "document.h"
#include "helper-fns.h"
#include "document.h"
#include "helper-fns.h"
+#include <string>
static void sp_glyph_kerning_class_init(SPGlyphKerningClass *gc);
static void sp_glyph_kerning_init(SPGlyphKerning *glyph);
static void sp_glyph_kerning_class_init(SPGlyphKerningClass *gc);
static void sp_glyph_kerning_init(SPGlyphKerning *glyph);
static void sp_glyph_kerning_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
static void sp_glyph_kerning_release(SPObject *object);
static void sp_glyph_kerning_set(SPObject *object, unsigned int key, const gchar *value);
static void sp_glyph_kerning_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
static void sp_glyph_kerning_release(SPObject *object);
static void sp_glyph_kerning_set(SPObject *object, unsigned int key, const gchar *value);
-static Inkscape::XML::Node *sp_glyph_kerning_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_glyph_kerning_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void sp_glyph_kerning_update(SPObject *object, SPCtx *ctx, guint flags);
static SPObjectClass *parent_class;
static void sp_glyph_kerning_update(SPObject *object, SPCtx *ctx, guint flags);
static SPObjectClass *parent_class;
}
}
}
}
+GlyphNames::GlyphNames(const gchar* value){
+ if (value) this->names = strdup(value);
+}
+
+GlyphNames::~GlyphNames(){
+ if (this->names) g_free(this->names);
+}
+
+bool GlyphNames::contains(gchar* name){
+ if (!(this->names) || !name) return false;
+ std::istringstream is(this->names);
+ std::string str;
+ std::string s(name);
+ while (is >> str){
+ if (str == s) return true;
+ }
+ return false;
+}
+
static void sp_glyph_kerning_set(SPObject *object, unsigned int key, const gchar *value)
{
SPGlyphKerning * glyphkern = (SPGlyphKerning*) object; //even if it is a VKern this will work. I did it this way just to avoind warnings.
static void sp_glyph_kerning_set(SPObject *object, unsigned int key, const gchar *value)
{
SPGlyphKerning * glyphkern = (SPGlyphKerning*) object; //even if it is a VKern this will work. I did it this way just to avoind warnings.
@@ -129,26 +154,26 @@ static void sp_glyph_kerning_set(SPObject *object, unsigned int key, const gchar
switch (key) {
case SP_ATTR_U1:
switch (key) {
case SP_ATTR_U1:
- if (glyphkern->u1) g_free(glyphkern->u1);
- glyphkern->u1 = g_strdup(value);//todo:
+ if (glyphkern->u1) delete glyphkern->u1;
+ glyphkern->u1 = new UnicodeRange(value);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
g_warning("<%s>: SP_ATTR_U1: %s", tag, value);
break;
case SP_ATTR_U2:
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
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:
+ if (glyphkern->u2) delete glyphkern->u2;
+ glyphkern->u2 = new UnicodeRange(value);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
g_warning("<%s>: SP_ATTR_U2: %s", tag, value);
break;
case SP_ATTR_G1:
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
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:
+ if (glyphkern->g1) delete glyphkern->g1;
+ glyphkern->g1 = new GlyphNames(value);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
g_warning("<%s>: SP_ATTR_G1: %s", tag, value);
break;
case SP_ATTR_G2:
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
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:
+ if (glyphkern->g2) delete glyphkern->g2;
+ glyphkern->g2 = new GlyphNames(value);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
g_warning("<%s>: SP_ATTR_G2: %s", tag, value);
break;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
g_warning("<%s>: SP_ATTR_G2: %s", tag, value);
break;
#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
-static Inkscape::XML::Node *sp_glyph_kerning_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+static Inkscape::XML::Node *sp_glyph_kerning_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
// SPGlyphKerning *glyph = SP_GLYPH_KERNING(object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
{
// SPGlyphKerning *glyph = SP_GLYPH_KERNING(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:glyphkerning");//fix this!
}
repr = xml_doc->createElement("svg:glyphkerning");//fix this!
}
@@ -224,12 +248,12 @@ static Inkscape::XML::Node *sp_glyph_kerning_write(SPObject *object, Inkscape::X
}
if (((SPObjectClass *) (parent_class))->write) {
}
if (((SPObjectClass *) (parent_class))->write) {
- ((SPObjectClass *) (parent_class))->write(object, repr, flags);
+ ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
}
return repr;
}
}
return repr;
}
-
+#endif //#ifdef ENABLE_SVG_FONTS
/*
Local Variables:
mode:c++
/*
Local Variables:
mode:c++