The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix orentation in stroke

These changes was commited to the Birdfont repository Fri, 17 Apr 2015 09:43:35 +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>
Fri, 17 Apr 2015 09:43:35 +0000 (11:43 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 17 Apr 2015 09:43:35 +0000 (11:43 +0200)
commit d723427bc5bd104e356a5674a6a800357d9a1064
tree 83e05e2e52ef30a10d799ac0933ce836de787643
parent b17872bb2c252168a8044fc5dc8fc49f25784576
Fix orentation in stroke

libbirdfont/StrokeTool.vala
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -1399,9 +1399,11 @@ foreach (Path p in r.paths) { c = counters (r, p); // FIXME: this needs improvements - print (@"$c $(p.is_clockwise ()) $(p.points.size)\n"); if (c % 2 == 0) { - if (!p.is_clockwise ()) { + + if (c == 0) { + p.force_direction (Direction.CLOCKWISE); + } else if (!p.is_clockwise ()) { remove.add (p); } @@ -1455,7 +1457,6 @@ } if (inside) { - print (@"Match $(path.points.size) with $(p.points.size)\n"); inside_count++; } } @@ -1561,7 +1562,6 @@ s = 0; foreach (EditPoint e in original_path1.points) { - print (@"insides: (e, original_path1): $(insides (e, original_path1)) $(e.x),$(e.y)\n"); if (!is_inside (e, original_path2) && insides (e, original_path1) == 1) { // FIXME: later as well break; @@ -1576,7 +1576,6 @@ original_path2 = t; s = 0; foreach (EditPoint e in original_path1.points) { - print (@"insides2: (e, original_path1): $(insides (e, original_path1))\n"); if (!is_inside (e, original_path2)) { break; } @@ -2024,6 +2023,7 @@ int size, i, added_points; double step = 0.5; bool open = path.is_open (); + bool flat; path.add_hidden_double_points (); @@ -2047,12 +2047,16 @@ end.tie_handles = false; end.deleted = true; } - - if (unlikely (added_points > 4)) { + + flat = is_flat (start.x, start.y, px, py, end.x, end.y, 0.05 * stroke_width) + && ((px - start.x) > 0) == ((start.get_right_handle ().x - start.x) > 0) + && ((py - start.y) > 0) == ((start.get_right_handle ().y - start.y) > 0); + + if (unlikely (added_points > 20)) { warning ("More than four points added in stroke."); added_points = 0; i++; - } else if (!is_flat (start.x, start.y, px, py, end.x, end.y, 0.05 * stroke_width) + } else if (!flat && Path.distance (start.x, px, start.y, py) > 0.1 * stroke_width && Path.distance (end.x, px, end.y, py) > 0.1 * stroke_width) { new_point = new EditPoint (px, py);