The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Better merging of 2x2 paths

These changes was commited to the Birdfont repository Mon, 24 Aug 2015 10:55: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
[Mon, 24 Aug 2015 10:55:12 +0000]

Updated Files

libbirdfont/OpenFontFormat/FontData.vala
libbirdfont/OpenFontFormat/NameTable.vala
libbirdfont/StrokeTool.vala
--- a/libbirdfont/OpenFontFormat/FontData.vala +++ b/libbirdfont/OpenFontFormat/FontData.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2012, 2013, 2014 Johan Mattsson + Copyright (C) 2012 2013 2014 2015 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
--- a/libbirdfont/OpenFontFormat/NameTable.vala +++ b/libbirdfont/OpenFontFormat/NameTable.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2012, 2013, 2014 Johan Mattsson + Copyright (C) 2012 2013 2014 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -279,7 +279,7 @@ } } - flat = merge (flat); + flat = merge (flat); bool has_split_point = false; foreach (Path p in flat.paths) { @@ -290,6 +290,40 @@ if (pp.points.size > 1) { pp.get_closest_point_on_path (lep, ep.x, ep.y, null, null); + + // add hidden double points to make sure that path does not change + // when new points are added to a 2x2 path. + if (lep.get_right_handle ().type == PointType.DOUBLE_CURVE) { + return_val_if_fail (lep.prev != null, r); + return_val_if_fail (lep.next != null, r); + + EditPoint before = lep.get_prev (); + EditPoint after = lep.get_next (); + EditPoint hidden = new EditPoint (0, 0, PointType.QUADRATIC); + hidden.get_right_handle ().type = PointType.QUADRATIC; + hidden.get_left_handle ().type = PointType.QUADRATIC; + + before.get_right_handle ().type = PointType.QUADRATIC; + after.get_left_handle ().type = PointType.QUADRATIC; + before.type = PointType.QUADRATIC; + after.type = PointType.QUADRATIC; + + double px = before.get_right_handle ().x + + (after.get_left_handle ().x - before.get_right_handle ().x) / 2.0; + double py = before.get_right_handle ().y + + (after.get_left_handle ().y - before.get_right_handle ().y) / 2.0; + hidden.independent_x = px; + hidden.independent_y = py; + + hidden.get_right_handle ().x = after.get_left_handle ().x; + hidden.get_right_handle ().y = after.get_left_handle ().y; + hidden.get_left_handle ().x = before.get_right_handle ().x; + hidden.get_left_handle ().y = before.get_right_handle ().y; + + pp.add_point_after (hidden, before); + + pp.get_closest_point_on_path (lep, ep.x, ep.y, null, null); + } if (Path.distance_to_point (ep, lep) < 0.1) { EditPoint lep2 = new EditPoint ();