Commit 982c80b
Transform paths in SVG to BF conversion
Changed files (4)
modifiedlibbirdfont/EmbeddedSvg.valamodifiedlibbirdfont/SvgParser.valamodifiedlibsvgbird/SvgFile.valamodifiedlibsvgbird/SvgTransforms.vala
Diff
@@ -90,7 +90,7 @@ public class EmbeddedSvg : SvgBird.Object { svg.append ("""<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">"""); svg.append ("\n"); - string transforms = transforms.get_xml ();+ string transforms = drawing.transforms.get_xml (); if (transforms != "") { svg.append ("<g");@@ -162,6 +162,7 @@ public class SvgParser { // parse the file if (!has_format) {+ parser.set_format (SvgFormat.ILLUSTRATOR); warn_if_test ("No format identifier found in SVG parser.\n"); } @@ -226,7 +227,6 @@ public class SvgParser { } foreach (XmlElement t in tag) {- if (t.get_name () == "g") { parse_layer (t, pl); }@@ -269,13 +269,11 @@ public class SvgParser { } PathList paths = LayerUtils.get_all_paths (pl);- ViewBox? box = SvgFile.parse_view_box (tag);+ if (box != null) { ViewBox view_box = (!) box;- Cairo.Matrix matrix = Cairo.Matrix.identity ();- Cairo.Matrix view_box_matrix = view_box.get_matrix (width, height);- view_box_matrix.multiply (view_box_matrix, matrix);+ Matrix view_box_matrix = view_box.get_matrix (width, height); SvgTransform t = new SvgTransform.for_matrix (view_box_matrix); SvgTransforms transforms = new SvgTransforms (); transforms.add (t);@@ -347,14 +345,7 @@ public class SvgParser { } } - PathList paths = new PathList ();- - foreach (SvgBird.Object object in pl.objects) {- if (object is Path) {- paths.add ((Path) object);- }- }- + PathList paths = LayerUtils.get_all_paths (pl); SvgTransforms transforms = SvgFile.get_transform (tag.get_attributes ()); transform_paths (transforms, paths); }@@ -101,8 +101,14 @@ public class SvgFile : GLib.Object { bool slice = true; bool preserve_aspect_ratio = true; + if (tag.get_name () != "svg") {+ warning (@"viewBox is not the svg tag: $(tag.get_name ())");+ return null;+ }+ foreach (Attribute attribute in tag.get_attributes ()) { if (attribute.get_name () == "viewBox") {+ print (@"$(attribute.get_name ()): $(attribute.get_content ())\n"); parameters = attribute.get_content (); } @@ -123,6 +129,7 @@ public class SvgFile : GLib.Object { } } + print (@"parameters: $parameters\n"); arguments = parameters.replace (",", " "); while (arguments.index_of (" ") > -1) {@@ -131,8 +138,9 @@ public class SvgFile : GLib.Object { string[] view_box_parameters = arguments.split (" "); - if (view_box_parameters.length != 4) {+ if (unlikely (view_box_parameters.length != 4)) { warning ("Expecting four arguments in view box.");+ warning (@"Content: $arguments ($parameters)"); return null; } @@ -134,6 +134,10 @@ public class SvgTransforms : GLib.Object { return copy_transforms; } + public void insert (int position, SvgTransform transform) {+ transforms.insert (position, transform);+ }+ public void add (SvgTransform transform) { transforms.add (transform); }