Clone in a terminal:
Commit 20d05cf
Johan Mattsson - 2016-06-27T07:21:12+00:00
20d05cffd91a2e6f2994b62d25994f4f37675890johan.mattsson.m@gmail.com

Update boundaries in resize

Changed files (6)

Diff

diff --git a/libbirdfont/EmbeddedSvg.vala b/libbirdfont/EmbeddedSvg.valaindex c7aa09a..75bc334 100644--- a/libbirdfont/EmbeddedSvg.vala+++ b/libbirdfont/EmbeddedSvg.vala@@ -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 ("<?"); 		} 		diff --git a/libbirdfont/OpenFontFormat/SvgTable.vala b/libbirdfont/OpenFontFormat/SvgTable.valaindex 84f5837..30706b7 100644--- a/libbirdfont/OpenFontFormat/SvgTable.vala+++ b/libbirdfont/OpenFontFormat/SvgTable.vala@@ -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;diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex 8df549c..14e4cd1 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -2796,6 +2796,8 @@ public class Path : GLib.Object { 			handle.independent_y = y;  		}+		+		update_region_boundaries (); 	} } diff --git a/libbirdfont/ResizeTool.vala b/libbirdfont/ResizeTool.valaindex a20edbf..aeffcc9 100644--- a/libbirdfont/ResizeTool.vala+++ b/libbirdfont/ResizeTool.vala@@ -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 () {diff --git a/libsvgbird/Object.vala b/libsvgbird/Object.valaindex 1e6e814..a75379e 100644--- a/libsvgbird/Object.vala+++ b/libsvgbird/Object.vala@@ -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);diff --git a/libsvgbird/SvgTransforms.vala b/libsvgbird/SvgTransforms.valaindex 520d87c..354d154 100644--- a/libsvgbird/SvgTransforms.vala+++ b/libsvgbird/SvgTransforms.vala@@ -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;

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112