From baf104b879e4f98e96b7be5a3719fdca868ccf68 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Wed, 25 May 2011 22:44:55 -0300 Subject: Saving curve description in d attribute of svg:glyph instead of svg:path elements as childnodes of svg:glyph because this is compatible with current fontforge svg loader (bzr r10223) --- share/extensions/layers2svgfont.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/share/extensions/layers2svgfont.py b/share/extensions/layers2svgfont.py index 49f81852c..6c11d9c5f 100644 --- a/share/extensions/layers2svgfont.py +++ b/share/extensions/layers2svgfont.py @@ -93,16 +93,34 @@ class Layers2SVGFont(inkex.Effect): glyph = self.get_or_create_glyph(font, unicode_char) glyph.set("unicode", unicode_char) + ############################ + #Option 1: + # Using clone (svg:use) as childnode of svg:glyph + #use = self.get_or_create(glyph, inkex.addNS('use', 'svg')) #use.set(inkex.addNS('href', 'xlink'), "#"+group.get("id")) #TODO: This code creates nodes but they do not render on svg fonts dialog. why? - paths = group.findall(inkex.addNS('path', 'svg')) + ############################ + #Option 2: + # Using svg:paths as childnodes of svg:glyph + + #paths = group.findall(inkex.addNS('path', 'svg')) + #for p in paths: + # d = p.get("d") + # d = self.flip_cordinate_system(d, units_per_em, baseline) + # path = inkex.etree.SubElement(glyph, inkex.addNS('path', 'svg')) + # path.set("d", d) + + ############################ + #Option 3: + # Using curve description in d attribute of svg:glyph + + paths = group.findall(inkex.addNS('path', 'svg')) + d = "" for p in paths: - path = inkex.etree.SubElement(glyph, inkex.addNS('path', 'svg')) - d = p.get("d") - d = self.flip_cordinate_system(d, units_per_em, baseline) - path.set("d", d) + d += " " + self.flip_cordinate_system(p.get("d"), units_per_em, baseline) + glyph.set("d", d) if __name__ == '__main__': e = Layers2SVGFont() -- cgit v1.2.3