The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Store transformation of embedded SVG files in BF format

These changes was commited to the Birdfont repository Mon, 27 Jun 2016 07:50:19 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 27 Jun 2016 07:50:19 +0000 (09:50 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 27 Jun 2016 07:50:19 +0000 (09:50 +0200)
commit affdf0024498517245ee1fc0516b00840d2f54e0
tree fc2781726a6ca5832c4d34177f6b06e486210502
parent 20d05cffd91a2e6f2994b62d25994f4f37675890
Store transformation of embedded SVG files in BF format

libbirdfont/BirdFontFile.vala
libsvgbird/Object.vala
libsvgbird/SvgFile.vala
--- a/libbirdfont/BirdFontFile.vala +++ b/libbirdfont/BirdFontFile.vala @@ -26,7 +26,7 @@ Font font; public static const int FORMAT_MAJOR = 2; - public static const int FORMAT_MINOR = 2; + public static const int FORMAT_MINOR = 3; public static const int MIN_FORMAT_MAJOR = 0; public static const int MIN_FORMAT_MINOR = 0; @@ -462,8 +462,9 @@ if (xml.validate ()) { os.put_string (@"<embedded "); os.put_string (@"type=\"svg\" "); - os.put_string (@"x=\"$(round (svg.x))\""); - os.put_string (@"y=\"$(round (svg.y))\""); + os.put_string (@"x=\"$(round (svg.x))\" "); + os.put_string (@"y=\"$(round (svg.y))\" "); + os.put_string (@"transform=\"$(svg.transforms.get_xml ())\""); os.put_string (@">\n"); Tag tag = xml.get_root_tag (); @@ -982,7 +983,7 @@ } font.format_major = int.parse (v[0]); - font.format_major = int.parse (v[1]); + font.format_minor = int.parse (v[1]); } public void parse_images (Tag tag) { @@ -1498,6 +1499,7 @@ string type = ""; double x = 0; double y = 0; + string transform = ""; foreach (Attribute attribute in tag.get_attributes ()) { if (attribute.get_name () == "x") { @@ -1510,11 +1512,16 @@ if (attribute.get_name () == "type") { type = attribute.get_content (); + } + + if (attribute.get_name () == "transform") { + transform = attribute.get_content (); } } if (type == "svg") { EmbeddedSvg svg = SvgParser.parse_embedded_svg_data (tag.get_content ()); + svg.transforms = SvgFile.parse_transform (transform); svg.x = x; svg.y = y; layer.add_object (svg);
--- a/libsvgbird/Object.vala +++ b/libsvgbird/Object.vala @@ -86,8 +86,6 @@ public const double CANVAS_MAX = 100000; public const double CANVAS_MIN = -100000; - - Matrix boundary_matrix = Matrix.identity (); public Object () { }
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -490,7 +490,7 @@ } // FIXME: reverse order? - public SvgTransforms parse_transform (string transforms) { + public static SvgTransforms parse_transform (string transforms) { string[] functions; string transform = transforms; SvgTransforms transform_functions; @@ -535,7 +535,7 @@ return transform_functions; } - private SvgTransform matrix (string function) { + private static SvgTransform matrix (string function) { string parameters = get_transform_parameters (function); string[] p = parameters.split (" "); SvgTransform transform = new SvgTransform (); @@ -588,7 +588,7 @@ return n; } - private SvgTransform scale (string function) { + private static SvgTransform scale (string function) { string parameters = get_transform_parameters (function); string[] p = parameters.split (" "); SvgTransform transform = new SvgTransform (); @@ -605,7 +605,7 @@ return transform; } - private SvgTransform translate (string function) { + private static SvgTransform translate (string function) { string parameters = get_transform_parameters (function); string[] p = parameters.split (" "); SvgTransform transform = new SvgTransform (); @@ -622,7 +622,7 @@ return transform; } - private string get_transform_parameters (string function) { + private static string get_transform_parameters (string function) { int i; string param = "";