The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Move imported SVG files to the em box in OpenType SVG table

These changes was commited to the Birdfont repository Sun, 20 Dec 2015 16:58:21 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sun, 20 Dec 2015 16:58:21 +0000]

Updated Files

libbirdfont/OpenFontFormat/SvgTable.vala
libbirdfont/OpenFontFormat/SvgTableEntry.vala
--- a/libbirdfont/OpenFontFormat/SvgTable.vala +++ b/libbirdfont/OpenFontFormat/SvgTable.vala @@ -62,6 +62,9 @@ Gee.ArrayList<Tag> meta; XmlParser xml; Tag svg_root_tag; + Font font; + + font = OpenFontFormatWriter.get_current_font (); layer_content = new Gee.ArrayList<Tag> (); svg_tags = new Gee.ArrayList<Tag> (); @@ -106,7 +109,15 @@ svg.append ("\""); svg.append ("glyph"); svg.append (@"$glyph_id"); - svg.append ("\""); + svg.append ("\" "); + + // scale the internal coordinates from 100 units per em to the + // number of units per em in this font and move the glyph + // in to the em box + double height = -1 * (font.top_position - font.base_line); + double scale = HeadTable.UNITS; + svg.append (@"transform=\"scale($scale) translate(0, $height)\""); + svg.append (">"); svg.append ("\n\n"); @@ -131,9 +142,12 @@ svg.append ("<"); svg.append (tag.get_name ()); + + svg.append (" "); + append_tag_attributes (svg, tag); if (content == "") { - svg.append ("/"); + svg.append (" /"); } svg.append (">");
--- a/libbirdfont/OpenFontFormat/SvgTableEntry.vala +++ b/libbirdfont/OpenFontFormat/SvgTableEntry.vala @@ -19,7 +19,6 @@ public uint16 glyph_id; public SvgTableEntry (uint16 gid, string svg) { - print (svg); glyph_id = gid; data = new FontData (); data.add_str (svg);