Commit 20d05cf
Update boundaries in resize
Changed files (6)
modifiedlibbirdfont/EmbeddedSvg.valamodifiedlibbirdfont/OpenFontFormat/SvgTable.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/ResizeTool.valamodifiedlibsvgbird/Object.valamodifiedlibsvgbird/SvgTransforms.vala
Diff
@@ -110,7 +110,7 @@ public class EmbeddedSvg : SvgBird.Object { end += "?>".length; - xml = xml.substring (start, end);+ xml = xml.substring (0, start) + xml.substring (end); start = xml.index_of ("<?"); } @@ -75,7 +75,7 @@ public class SvgTable : OtfTable { svg.append (">"); svg.append ("\n\n"); - append_svg_glyph (svg, embedded.svg_data, glyphs);+ append_svg_glyph (svg, embedded, glyphs); svg.append ("</g>\n"); svg.append ("\n\n");@@ -122,14 +122,16 @@ public class SvgTable : OtfTable { return svg; } - void append_svg_glyph (StringBuilder svg, string svg_data, GlyphCollection glyphs) {+ void append_svg_glyph (StringBuilder svg, EmbeddedSvg embedded, GlyphCollection glyphs) { Gee.ArrayList<Tag> layer_content; Gee.ArrayList<Tag> svg_tags; Gee.ArrayList<Tag> meta; XmlParser xml; Tag svg_root_tag; Font font;+ string svg_data; + svg_data = embedded.get_transformed_svg_data (); font = OpenFontFormatWriter.get_current_font (); layer_content = new Gee.ArrayList<Tag> ();@@ -276,7 +278,6 @@ public class SvgTable : OtfTable { foreach (Path p in paths.paths) { p.add_hidden_double_points (); - int i = 0; EditPoint? n = null; EditPoint m;@@ -2796,6 +2796,8 @@ public class Path : GLib.Object { handle.independent_y = y; }+ + update_region_boundaries (); } } @@ -373,6 +373,7 @@ public class ResizeTool : Tool { x = selection_box_left - svg.x; y = selection_box_top + svg.y + selection_box_height; p.transforms.resize (ratio_x, ratio_y, x, y);+ glyph.layers.update_boundaries_for_object (); } else if (p is PathObject) { Path path = ((PathObject) p).get_path (); x = selection_box_center_x - selection_box_width / 2;@@ -397,8 +398,6 @@ public class ResizeTool : Tool { glyph.remove_lines (); glyph.add_help_lines (); }-- update_selection_box (); } public static void update_selection_box () {@@ -86,6 +86,8 @@ public abstract class Object : GLib.Object { public const double CANVAS_MAX = 100000; public const double CANVAS_MIN = -100000;++ Matrix boundary_matrix = Matrix.identity (); public Object () { }@@ -215,18 +217,16 @@ public abstract class Object : GLib.Object { context.save (); - if (has_stroke) { + context.set_matrix (Matrix.identity ());+ + if (has_stroke) { context.stroke_extents (out x0, out y0, out x1, out y1); } else {- context.path_extents (out x0, out y0, out x1, out y1);+ context.fill_extents (out x0, out y0, out x1, out y1); }- + context.restore ();- - Matrix m = context.get_matrix ();- m.transform_point (ref x0, ref y0);- m.transform_point (ref x1, ref y1);- + left = x0; top = y0; right = x1;@@ -235,7 +235,6 @@ public abstract class Object : GLib.Object { return boundaries_width != 0; } - // FIXME: store view matrix public virtual bool update_boundaries_for_object () { ImageSurface surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, 1, 1); Context context = new Cairo.Context (surface);@@ -21,8 +21,6 @@ public class SvgTransforms : GLib.Object { public Matrix size_matrix; public Gee.ArrayList<SvgTransform> transforms; - public double x = 0;- public double y = 0; public double rotation = 0; public double scale_x = 1; public double scale_y = 1;@@ -117,8 +115,8 @@ public class SvgTransforms : GLib.Object { transformation_matrix.multiply (transformation_matrix, part); } - transformation_matrix.multiply (transformation_matrix, rotation_matrix); transformation_matrix.multiply (transformation_matrix, size_matrix);+ transformation_matrix.multiply (transformation_matrix, rotation_matrix); return transformation_matrix; }@@ -136,10 +134,15 @@ public class SvgTransforms : GLib.Object { public string get_xml () { StringBuilder svg = new StringBuilder ();+ bool first = true; foreach (SvgTransform transform in transforms) {+ if (!first) {+ svg.append (" ");+ }+ svg.append (transform.get_xml ());- svg.append (";");+ first = false; } return svg.str;