The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix corners in stroke simplification

These changes was commited to the Birdfont repository Sun, 04 Oct 2015 07:52:09 +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>
Sun, 04 Oct 2015 07:52:09 +0000 (09:52 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 04 Oct 2015 07:52:09 +0000 (09:52 +0200)
commit 70046340b752909062a9bfeee5848ef30a25f778
tree 47c9059963828e88a82a8beae66bf119f702b488
parent abe1885c7fe2881e56761f5703859e97139514cf
Fix corners in stroke simplification

libbirdfont/StrokeTool.vala
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -934,7 +934,7 @@ int start, stop; int j; EditPointHandle last_handle; - + last_handle = new EditPointHandle.empty (); segment_last = new EditPoint (); @@ -1023,8 +1023,8 @@ first.recalculate_linear_handles (); } } - - last_handle = last.get_left_handle (); + + last_handle = last.get_left_handle (); } else { warning ("No points in segment."); } @@ -1038,11 +1038,20 @@ simplified.recalculate_linear_handles (); simplified.close (); remove_single_point_intersections (simplified); - + first = simplified.get_first_point (); first.left_handle.angle = last_handle.angle; first.left_handle.length = last_handle.length; - first.recalculate_linear_handles (); + + double left = first.get_left_handle ().angle; + double right = first.get_right_handle ().angle; + + if (fabs (right - left) < 0.001) { + first.get_left_handle ().convert_to_line (); + first.recalculate_linear_handles (); + } + + simplified.remove_points_on_points (); return simplified; }