The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Update boundaries in resize

These changes was commited to the Birdfont repository Mon, 27 Jun 2016 07:21:12 +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:21:12 +0000 (09:21 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 27 Jun 2016 07:21:12 +0000 (09:21 +0200)
commit 20d05cffd91a2e6f2994b62d25994f4f37675890
tree 497b2d3d17d9d76f3ca5f31e402fbb2ab3796c07
parent eb62a544ad92a4fee096cfec3a205b9664a1aaac
Update boundaries in resize

libbirdfont/EmbeddedSvg.vala
libbirdfont/OpenFontFormat/SvgTable.vala
libbirdfont/Path.vala
libbirdfont/ResizeTool.vala
libsvgbird/Object.vala
libsvgbird/SvgTransforms.vala
--- a/libbirdfont/EmbeddedSvg.vala +++ b/libbirdfont/EmbeddedSvg.vala @@ -110,7 +110,7 @@ end += "?>".length; - xml = xml.substring (start, end); + xml = xml.substring (0, start) + xml.substring (end); start = xml.index_of ("<?"); }
--- a/libbirdfont/OpenFontFormat/SvgTable.vala +++ b/libbirdfont/OpenFontFormat/SvgTable.vala @@ -75,7 +75,7 @@ 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 @@ 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> (); @@ -275,7 +277,6 @@ foreach (Path p in paths.paths) { p.add_hidden_double_points (); - int i = 0; EditPoint? n = null;
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -2796,8 +2796,10 @@ handle.independent_y = y; } + + update_region_boundaries (); } } }
--- a/libbirdfont/ResizeTool.vala +++ b/libbirdfont/ResizeTool.vala @@ -373,6 +373,7 @@ 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 @@ glyph.remove_lines (); glyph.add_help_lines (); } - - update_selection_box (); } public static void update_selection_box () {
--- a/libsvgbird/Object.vala +++ b/libsvgbird/Object.vala @@ -86,6 +86,8 @@ public const double CANVAS_MAX = 100000; public const double CANVAS_MIN = -100000; + + Matrix boundary_matrix = Matrix.identity (); public Object () { } @@ -215,18 +217,16 @@ 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 @@ 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);
--- a/libsvgbird/SvgTransforms.vala +++ b/libsvgbird/SvgTransforms.vala @@ -21,8 +21,6 @@ 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 @@ 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 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;