The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix quadratic double points for open paths

These changes was commited to the Birdfont repository Sun, 12 Apr 2015 22:06:57 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sun, 12 Apr 2015 22:06:57 +0000]

Updated Files

libbirdfont/DrawingTools.vala
libbirdfont/Path.vala
libbirdfont/PenTool.vala
libbirdfont/StrokeTool.vala
libbirdfont/SvgParser.vala
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -250,7 +250,7 @@ convert_points = new Tool ("convert_point", t_("Convert selected points")); convert_points.select_action.connect ((self) => { PenTool.convert_point_types (); - MainWindow.get_current_glyph ().update_view (); + GlyphCanvas.redraw (); update_type_selection (); }); convert_points.set_persistent (false);
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -1135,13 +1135,14 @@ Gee.ArrayList<EditPoint> middle_points = new Gee.ArrayList<EditPoint> (); Gee.ArrayList<EditPoint> first_points = new Gee.ArrayList<EditPoint> (); - first = points.get (points.size - 1); + first = is_open () ? points.get (0) : points.get (points.size - 1); foreach (EditPoint next in points) { left = first.get_right_handle ().type; right = next.get_left_handle ().type; - if (right == PointType.DOUBLE_CURVE || left == PointType.DOUBLE_CURVE) { + if (next != first && (right == PointType.DOUBLE_CURVE || left == PointType.DOUBLE_CURVE)) { + first.get_right_handle ().type = PointType.QUADRATIC; // half way between handles
--- a/libbirdfont/PenTool.vala +++ b/libbirdfont/PenTool.vala @@ -2102,6 +2102,7 @@ foreach (PointSelection ps in selected_points) { e = ps.point; + // convert segments not control points if (e.next == null || !e.get_next ().is_selected ()) { continue;
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -339,15 +339,12 @@ first = merged.get_first_point (); last_counter = merged.get_last_point (); - if (first.type == PointType.QUADRATIC) { - first.get_left_handle ().convert_to_line (); - first.recalculate_linear_handles (); - } + + first.get_left_handle ().convert_to_line (); + first.recalculate_linear_handles (); - if (last_counter.type == PointType.QUADRATIC) { - last_counter.get_right_handle ().convert_to_line (); - last_counter.recalculate_linear_handles (); - } + last_counter.get_right_handle ().convert_to_line (); + last_counter.recalculate_linear_handles (); first.color = Color.pink (); last_counter.color = Color.yellow (); @@ -1905,6 +1902,8 @@ int size, i, added_points; double step = 0.51; bool open = path.is_open (); + + print (@"open: $open\n"); size = open ? path.points.size - 1 : path.points.size; @@ -1912,7 +1911,7 @@ i = 0; added_points = 0; - while (i < path.points.size) { + while (i < size) { start = path.points.get (i); end = path.points.get ((i + 1) % path.points.size);
--- a/libbirdfont/SvgParser.vala +++ b/libbirdfont/SvgParser.vala @@ -487,7 +487,8 @@ if (!StrokeTool.is_flat (x1, y1, x2, y2, x3, y3, 1) && step_end - step / 2.0 > step_start && step_end - step / 2.0 > 0.1 - && step > 0.05) { + && step > 0.05 + && Path.distance_to_point (start, end) > 1) { step /= 2.0;