The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix Illustrator paths

These changes was commited to the Birdfont repository Thu, 07 Jul 2016 14:14:10 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Thu, 07 Jul 2016 14:14:10 +0000]

Updated Files

libbirdfont/Path.vala
libsvgbird/SvgFile.vala
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -2262,16 +2262,25 @@ } remove_deleted_points (); - + + // remove tripple points for (int i = 0; i < points.size + 1; i++) { EditPoint ep = points.get (i % points.size); - n = points.get ((i + 1) % points.size); + EditPoint next = points.get ((i + 1) % points.size); EditPoint previous = points.get ((i - 1 + points.size) % points.size); - if (Path.distance_to_point (n, ep) < t && Path.distance_to_point (previous, ep) < t) { + if (Path.distance_to_point (next, ep) < t && Path.distance_to_point (previous, ep) < t) { points.remove (ep); i--; - } else if (Path.distance_to_point (n, ep) < t) { + } + } + + // remove points on points + for (int i = 0; i < points.size + 1; i++) { + EditPoint ep = points.get (i % points.size); + n = points.get ((i + 1) % points.size); + + if (Path.distance_to_point (n, ep) < t) { remove.add (ep); } }
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -801,6 +801,7 @@ // all instructions are padded for (int i = 0; i < points_size; i++) { + print (@"$(bezier_points[i])\n"); // FIXME: add more types if (bezier_points[i].type == 'M') { if (i == 0) { @@ -878,10 +879,17 @@ if (p.point_data.size > 8) { Points illustrator_points = new Points (); - illustrator_points.x = p.point_data.get_double (p.point_data.size - 3); - illustrator_points.y = p.point_data.get_double (p.point_data.size - 2); - + if (p.point_data.get_point_type (p.point_data.size - 8) == POINT_CUBIC) { + illustrator_points.x = p.point_data.get_double (p.point_data.size - 3); + illustrator_points.y = p.point_data.get_double (p.point_data.size - 2); + } else { + illustrator_points.x = p.point_data.get_double (p.point_data.size - 7); + illustrator_points.y = p.point_data.get_double (p.point_data.size - 6); + } + int start = p.point_data.get_point_type (0) == POINT_CUBIC ? 8 : 0; + + start = 0; for (int i = start; i < p.point_data.size; i += 1) { illustrator_points.point_data.add (p.point_data.get_double (i));