Clone in a terminal:
Commit ef23d05
Johan Mattsson - 2015-11-07T11:16:47+00:00
ef23d058788043f0bbf89857588471f241e0fd1ajohan.mattsson.m@gmail.com

Draw filled open paths This commit moves recalculate_linear_handles to the Path class in order to set handle position for end points.

Changed files (13)

Diff

diff --git a/libbirdfont/BezierTool.vala b/libbirdfont/BezierTool.valaindex 0fb8ec3..2b16765 100644--- a/libbirdfont/BezierTool.vala+++ b/libbirdfont/BezierTool.vala@@ -163,7 +163,7 @@ public class BezierTool : Tool { 			current_point = current_path.add (px, py); 			current_path.hide_end_handle = true; 			current_point.get_left_handle ().convert_to_line ();-			current_point.recalculate_linear_handles ();+			current_path.recalculate_linear_handles_for_point (current_point); 			set_point_type (); 			corner_node = false; 			state = MOVE_POINT;@@ -172,7 +172,7 @@ public class BezierTool : Tool { 				current_point = current_path.add (px, py); 				current_path.hide_end_handle = true; 				current_point.get_left_handle ().convert_to_line ();-				current_point.recalculate_linear_handles ();+				current_path.recalculate_linear_handles_for_point (current_point); 				set_point_type (); 				g.clear_active_paths (); 				g.add_active_path (null, current_path);@@ -188,7 +188,7 @@ public class BezierTool : Tool { 			current_path.hide_end_handle = true; 			current_point = current_path.add (px, py); 			current_point.get_left_handle ().convert_to_line ();-			current_point.recalculate_linear_handles ();+			current_path.recalculate_linear_handles_for_point (current_point); 			g.add_path (current_path); 			 			set_point_type ();@@ -279,7 +279,7 @@ public class BezierTool : Tool { 			current_point = current_path.add (px, py); 			current_path.hide_end_handle = true; 			current_point.get_left_handle ().convert_to_line ();-			current_point.recalculate_linear_handles ();+			current_path.recalculate_linear_handles_for_point (current_point); 			set_point_type (); 			g.clear_active_paths (); 			g.add_active_path (null, current_path);@@ -336,7 +336,7 @@ public class BezierTool : Tool { 			current_point.x = px; 			current_point.y = py; 			current_path.hide_end_handle = true;-			current_point.recalculate_linear_handles ();+			current_path.recalculate_linear_handles_for_point (current_point); 			current_path.reset_stroke ();  			if (current_point.type == PointType.QUADRATIC) {@@ -400,8 +400,8 @@ public class BezierTool : Tool { 			p = current_path.points.get (s - 2); 			p.get_right_handle ().convert_to_line (); 			current_point.get_left_handle ().convert_to_line ();-			p.recalculate_linear_handles ();-			current_point.recalculate_linear_handles ();+			current_path.recalculate_linear_handles_for_point (p);+			current_path.recalculate_linear_handles_for_point (current_point); 			current_path.reset_stroke (); 			GlyphCanvas.redraw (); 			diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 501e798..ad43656 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -1427,7 +1427,7 @@ class BirdFontFile : GLib.Object { 		ep.get_right_handle ().type = PointType.LINE_DOUBLE_CURVE; 		ep.get_left_handle ().type = PointType.LINE_DOUBLE_CURVE; 		ep.type = PointType.LINE_DOUBLE_CURVE;-		ep.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep); 	}  	private static void cubic_line (Path path, string px, string py) {@@ -1437,7 +1437,7 @@ class BirdFontFile : GLib.Object { 		ep = path.points.get (path.points.size - 1); 		ep.get_right_handle ().type = PointType.LINE_CUBIC; 		ep.type = PointType.LINE_CUBIC;-		ep.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep); 	}  	private static void quadratic (Path path, string px0, string py0, string px1, string py1) {@@ -1454,7 +1454,7 @@ class BirdFontFile : GLib.Object { 		} 		 		ep1 = path.points.get (path.points.size - 1);-		ep1.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep1); 		ep1.get_right_handle ().type = PointType.QUADRATIC; 		ep1.get_right_handle ().move_to_coordinate (x0, y0);	 		ep1.type = PointType.QUADRATIC;@@ -1462,7 +1462,7 @@ class BirdFontFile : GLib.Object { 		path.add (x1, y1);  		ep2 = path.points.get (path.points.size - 1);-		ep2.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep2); 		ep2.get_left_handle ().type = PointType.QUADRATIC; 		ep2.get_left_handle ().move_to_coordinate (x0, y0); 		ep2.type = PointType.QUADRATIC;@@ -1493,11 +1493,11 @@ class BirdFontFile : GLib.Object { 		ly = ep1.y + ((y2 - ep1.y) / 3); 						 		ep1.get_right_handle ().move_to_coordinate (lx, ly);-		ep1.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep1); 		 		// set curve handles 		ep1 = path.points.get (path.points.size - 1);-		ep1.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep1); 		ep1.get_right_handle ().type = PointType.CUBIC; 		ep1.get_right_handle ().move_to_coordinate (x0, y0);				 		ep1.type = PointType.CUBIC;@@ -1505,12 +1505,12 @@ class BirdFontFile : GLib.Object { 		path.add (x2, y2); 						 		ep2 = path.points.get (path.points.size - 1);-		ep2.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep2); 		ep2.get_left_handle ().type = PointType.CUBIC; 		ep2.get_left_handle ().move_to_coordinate (x1, y1); 		ep2.type = PointType.CUBIC; 		-		ep1.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep2); 	} 	 	/** Two quadratic off curve points. */@@ -1539,24 +1539,22 @@ class BirdFontFile : GLib.Object { 		ly = ep1.y + ((y2 - ep1.y) / 4); 						 		ep1.get_right_handle ().move_to_coordinate (lx, ly);-		ep1.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep1); 		 		// set curve handles 		ep1 = path.points.get (path.points.size - 1);-		ep1.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep1); 		ep1.get_right_handle ().type = PointType.DOUBLE_CURVE; 		ep1.get_right_handle ().move_to_coordinate (x0, y0);				 		ep1.type = PointType.DOUBLE_CURVE; 		-		path.add (x2, y2);-						-		ep2 = path.points.get (path.points.size - 1);-		ep2.recalculate_linear_handles ();+		ep2 = path.add (x2, y2);+		path.recalculate_linear_handles_for_point (ep2); 		ep2.get_left_handle ().type = PointType.DOUBLE_CURVE; 		ep2.get_left_handle ().move_to_coordinate (x1, y1); 		ep2.type = PointType.DOUBLE_CURVE; 		-		ep1.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep1); 	} 	 	public static void close (Path path) {diff --git a/libbirdfont/EditPoint.vala b/libbirdfont/EditPoint.valaindex 0dad575..307ae13 100644--- a/libbirdfont/EditPoint.vala+++ b/libbirdfont/EditPoint.vala@@ -253,120 +253,6 @@ public class EditPoint : GLib.Object { 		}		 	} 		-	/** Set bezier points for linear paths. */-	public void recalculate_linear_handles () {-		unowned EditPointHandle h;-		unowned EditPoint n;-		double nx, ny;--		return_if_fail (!is_null (right_handle) && !is_null (left_handle));--		if (prev == null && next != null) {-			// FIXME: prev = get_next ().last ();-		}--		// left handle-		if (prev != null) {-			n = get_prev ();-			h = get_left_handle ();-		-			return_if_fail (!is_null (n) && !is_null (h));-			-			if (h.type == PointType.LINE_CUBIC) {-				nx = x + ((n.x - x) / 3);-				ny = y + ((n.y - y) / 3);-				h.move_to_coordinate (nx, ny);-			}--			if (h.type == PointType.LINE_DOUBLE_CURVE) {-				nx = x + ((n.x - x) / 4);-				ny = y + ((n.y - y) / 4);-				h.move_to_coordinate (nx, ny);-			}--			if (h.type == PointType.LINE_QUADRATIC) {-				nx = x + ((n.x - x) / 2);-				ny = y + ((n.y - y) / 2);-				h.move_to_coordinate (nx, ny);-			}-												-			// the other side-			h = n.get_right_handle ();-			return_if_fail (!is_null (h) && !is_null (h));-				-			if (h.type == PointType.LINE_DOUBLE_CURVE) {-				nx = n.x + ((x - n.x) / 4);-				ny = n.y + ((y - n.y) / 4);	-				h.move_to_coordinate (nx, ny);-			}-					-			if (h.type == PointType.LINE_CUBIC) {-				nx = n.x + ((x - n.x) / 3);-				ny = n.y + ((y - n.y) / 3);	-				h.move_to_coordinate (nx, ny);-			}--			if (h.type == PointType.LINE_QUADRATIC) {-				nx = n.x + ((x - n.x) / 2);-				ny = n.y + ((y - n.y) / 2);	-				h.move_to_coordinate (nx, ny);-			}-		}--		// right handle-		if (next != null) {-			n = get_next ();-			h = get_right_handle ();-			-			return_if_fail (!is_null (n) && !is_null (h));-			-			if (h.type == PointType.LINE_CUBIC) {-				nx = x + ((n.x - x) / 3);-				ny = y + ((n.y - y) / 3);-				-				h.move_to_coordinate (nx, ny);-			}--			if (h.type == PointType.LINE_DOUBLE_CURVE) {-				nx = x + ((n.x - x) / 4);-				ny = y + ((n.y - y) / 4);-				-				h.move_to_coordinate (nx, ny);-			}--			if (h.type == PointType.LINE_QUADRATIC) {-				nx = x + ((n.x - x) / 2);-				ny = y + ((n.y - y) / 2);-				-				h.move_to_coordinate (nx, ny);-			}--			h = n.get_left_handle ();-			return_if_fail (!is_null (h));-			-			if (h.type == PointType.LINE_CUBIC) {-				nx = n.x + ((x - n.x) / 3);-				ny = n.y + ((y - n.y) / 3);--				h.move_to_coordinate (nx, ny);-			}-			-			if (h.type == PointType.LINE_DOUBLE_CURVE) {-				nx = n.x + ((x - n.x) / 4);-				ny = n.y + ((y - n.y) / 4);--				h.move_to_coordinate (nx, ny);-			}--			if (h.type == PointType.LINE_QUADRATIC) {-				nx = n.x + ((x - n.x) / 2);-				ny = n.y + ((y - n.y) / 2);-				-				h.move_to_coordinate (nx, ny);-			}-		}-	}-	 	public bool is_clockwise () { 		return get_direction () >= 0; 	}diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex bdff97e..be58fff 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1599,7 +1599,8 @@ public class Glyph : FontDisplay { 	public void draw_paths (Context cr, Color? c = null) { 		PathList stroke; 		Color color;-+		bool open;+		 		cr.save (); 		cr.new_path (); 		foreach (Path p in get_visible_paths ()) {@@ -1615,7 +1616,18 @@ public class Glyph : FontDisplay { 				stroke = p.get_stroke_fast (); 				draw_path_list (stroke, cr, color); 			} else {+				open = p.is_open ();+				+				if (open) {+					p.close ();+					p.recalculate_linear_handles ();+				}+				 				p.draw_path (cr, this, color);+				+				if (open) {+					p.reopen ();+				} 			} 		} 		cr.fill ();diff --git a/libbirdfont/OpenFontFormat/GlyfTable.vala b/libbirdfont/OpenFontFormat/GlyfTable.valaindex 8e33a07..255c193 100644--- a/libbirdfont/OpenFontFormat/GlyfTable.vala+++ b/libbirdfont/OpenFontFormat/GlyfTable.vala@@ -650,7 +650,7 @@ public class GlyfTable : OtfTable { 						edit_point.get_left_handle ().set_point_type (PointType.NONE); 						edit_point.get_left_handle ().length = 0; 					} else {-						edit_point.recalculate_linear_handles ();+						path.recalculate_linear_handles_for_point (edit_point); 					} 					 					prev_is_curve = false;diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex c70da1b..f4ef052 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -200,7 +200,7 @@ public class OverViewItem : GLib.Object { 		Surface s; 		Context c; 		Color color = Color.black ();-+		 		w = width; 		h = height; 		@@ -228,7 +228,7 @@ public class OverViewItem : GLib.Object { 			gy = (h / glyph_scale) - 25 / glyph_scale; 			 			c.translate (gx - Glyph.xc () - g.get_lsb (), g.get_baseline () + gy - Glyph.yc ());-						+			 			g.draw_paths (c, color); 			c.restore (); 		} else {diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex a26ed77..9bc16a4 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -1010,12 +1010,6 @@ public class Path : GLib.Object { 		return p; 	} -	public void recalculate_linear_handles () {-		foreach (EditPoint e in points) {-			e.recalculate_linear_handles ();-		}-	}- 	public void close () { 		open = false; 		edit = false;@@ -1023,8 +1017,8 @@ public class Path : GLib.Object { 		create_list (); 		 		if (points.size > 2) {-			points.get (0).recalculate_linear_handles ();-			points.get (points.size - 1).recalculate_linear_handles ();+			recalculate_linear_handles_for_point (get_last_point ());+			recalculate_linear_handles_for_point (get_first_point ()); 		} 	} 	@@ -1379,9 +1373,7 @@ public class Path : GLib.Object { 		} 		 		create_list ();-		foreach (EditPoint p in points) {-			p.recalculate_linear_handles ();-		}+		recalculate_linear_handles (); 	} 			 	/** Get a point on the this path closest to x and y coordinates.@@ -2512,6 +2504,128 @@ public class Path : GLib.Object { 		start.get_right_handle ().move_to_coordinate (x1, y1); 		end.get_left_handle ().move_to_coordinate (x2, y2); 	}+	+	public void recalculate_linear_handles () {+		foreach (EditPoint e in points) {+			recalculate_linear_handles_for_point (e);+		}+	}+		+	/** Set bezier points for linear paths. */+	public void recalculate_linear_handles_for_point (EditPoint ep) {+		EditPointHandle h;+		EditPoint n;+		double nx, ny;++		return_if_fail (!is_null (ep.right_handle) && !is_null (ep.left_handle));++		// left handle+		if (ep.prev != null) {+			n = ep.get_prev ();+			h = ep.get_left_handle ();+		} else {+			n = get_last_point ();+			h = ep.get_left_handle ();+		}+		+		return_if_fail (!is_null (n) && !is_null (h));+		+		if (h.type == PointType.LINE_CUBIC) {+			nx = ep.x + ((n.x - ep.x) / 3);+			ny = ep.y + ((n.y - ep.y) / 3);+			h.move_to_coordinate (nx, ny);+		}++		if (h.type == PointType.LINE_DOUBLE_CURVE) {+			nx = ep.x + ((n.x - ep.x) / 4);+			ny = ep.y + ((n.y - ep.y) / 4);+			h.move_to_coordinate (nx, ny);+		}++		if (h.type == PointType.LINE_QUADRATIC) {+			nx = ep.x + ((n.x - ep.x) / 2);+			ny = ep.y + ((n.y - ep.y) / 2);+			h.move_to_coordinate (nx, ny);+		}+											+		// the other side+		h = n.get_right_handle ();+		return_if_fail (!is_null (h) && !is_null (h));+			+		if (h.type == PointType.LINE_DOUBLE_CURVE) {+			nx = n.x + ((ep.x - n.x) / 4);+			ny = n.y + ((ep.y - n.y) / 4);	+			h.move_to_coordinate (nx, ny);+		}+				+		if (h.type == PointType.LINE_CUBIC) {+			nx = n.x + ((ep.x - n.x) / 3);+			ny = n.y + ((ep.y - n.y) / 3);	+			h.move_to_coordinate (nx, ny);+		}++		if (h.type == PointType.LINE_QUADRATIC) {+			nx = n.x + ((ep.x - n.x) / 2);+			ny = n.y + ((ep.y - n.y) / 2);	+			h.move_to_coordinate (nx, ny);+		}++		// right handle+		if (ep.next != null) {+			n = ep.get_next ();+			h = ep.get_right_handle ();+		} else {+			n = get_first_point ();+			h = ep.get_right_handle ();+		}+		+		return_if_fail (!is_null (n) && !is_null (h));+		+		if (h.type == PointType.LINE_CUBIC) {+			nx = ep.x + ((n.x - ep.x) / 3);+			ny = ep.y + ((n.y - ep.y) / 3);+			+			h.move_to_coordinate (nx, ny);+		}++		if (h.type == PointType.LINE_DOUBLE_CURVE) {+			nx = ep.x + ((n.x - ep.x) / 4);+			ny = ep.y + ((n.y - ep.y) / 4);+			+			h.move_to_coordinate (nx, ny);+		}++		if (h.type == PointType.LINE_QUADRATIC) {+			nx = ep.x + ((n.x - ep.x) / 2);+			ny = ep.y + ((n.y - ep.y) / 2);+			+			h.move_to_coordinate (nx, ny);+		}++		h = n.get_left_handle ();+		return_if_fail (!is_null (h));+		+		if (h.type == PointType.LINE_CUBIC) {+			nx = n.x + ((ep.x - n.x) / 3);+			ny = n.y + ((ep.y - n.y) / 3);++			h.move_to_coordinate (nx, ny);+		}+		+		if (h.type == PointType.LINE_DOUBLE_CURVE) {+			nx = n.x + ((ep.x - n.x) / 4);+			ny = n.y + ((ep.y - n.y) / 4);++			h.move_to_coordinate (nx, ny);+		}++		if (h.type == PointType.LINE_QUADRATIC) {+			nx = n.x + ((ep.x - n.x) / 2);+			ny = n.y + ((ep.y - n.y) / 2);+			+			h.move_to_coordinate (nx, ny);+		}+	} }  }diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex e9f9efb..bb7b495 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -905,7 +905,7 @@ public class PenTool : Tool { 					} 					 					selected.path.reset_stroke ();-					selected.point.recalculate_linear_handles ();+					selected.path.recalculate_linear_handles_for_point(selected.point); 					selected.path.update_region_boundaries (); 				} 			} else if (GridTool.has_ttf_grid ()) {@@ -939,7 +939,7 @@ public class PenTool : Tool { 					} 					 					selected.path.reset_stroke ();-					selected.point.recalculate_linear_handles ();+					selected.path.recalculate_linear_handles_for_point(selected.point); 					selected.path.update_region_boundaries (); 				} 			} else {@@ -970,7 +970,7 @@ public class PenTool : Tool { 							selected.point.y + delta_coordinate_y); 					} 					-					selected.point.recalculate_linear_handles ();+					selected.path.recalculate_linear_handles_for_point(selected.point); 					selected.path.reset_stroke (); 					selected.path.update_region_boundaries (); 				}@@ -1346,9 +1346,9 @@ public class PenTool : Tool { 			 		path.points.get (0).left_handle.type =  			path.points.get (path.points.size - 1).left_handle.type;--		path.points.get (0).recalculate_linear_handles ();-		path.points.get (path.points.size - 1).recalculate_linear_handles ();+			+		path.recalculate_linear_handles_for_point (path.points.get (0));+		path.recalculate_linear_handles_for_point (path.points.get (path.points.size - 1)); 		 		// force the connected handle to move 		path.points.get (0).set_position (@@ -1360,12 +1360,12 @@ public class PenTool : Tool {  		if (last_segment_is_line) { 			path.get_first_point ().get_left_handle ().convert_to_line ();-			path.get_first_point ().recalculate_linear_handles ();+			path.recalculate_linear_handles_for_point (path.get_first_point ()); 		}  		if (first_segment_is_line) { 			path.get_first_point ().get_right_handle ().convert_to_line ();-			path.get_first_point ().recalculate_linear_handles ();+			path.recalculate_linear_handles_for_point (path.get_first_point ()); 		} 	}	 	@@ -1895,7 +1895,7 @@ public class PenTool : Tool { 	static void set_default_handle_positions_on_path (Path path) { 		foreach (EditPoint e in path.points) { 			if (!e.tie_handles && !e.reflective_point) {-				e.recalculate_linear_handles ();+				path.recalculate_linear_handles_for_point (e); 			} 		} 	}@@ -2226,28 +2226,28 @@ public class PenTool : Tool { 			if (keyval == Key.UP) { 				foreach (PointSelection e in selected_points) { 					e.point.set_position (e.point.x, e.point.y + Glyph.ivz ());-					e.point.recalculate_linear_handles ();+					e.path.recalculate_linear_handles_for_point (e.point); 				} 			} 			 			if (keyval == Key.DOWN) { 				foreach (PointSelection e in selected_points) { 					e.point.set_position (e.point.x, e.point.y - Glyph.ivz ());-					e.point.recalculate_linear_handles ();+					e.path.recalculate_linear_handles_for_point (e.point); 				} 			}  			if (keyval == Key.LEFT) { 				foreach (PointSelection e in selected_points) { 					e.point.set_position (e.point.x - Glyph.ivz (), e.point.y);-					e.point.recalculate_linear_handles ();+					e.path.recalculate_linear_handles_for_point (e.point); 				} 			}  			if (keyval == Key.RIGHT) { 				foreach (PointSelection e in selected_points) { 					e.point.set_position (e.point.x + Glyph.ivz (), e.point.y);-					e.point.recalculate_linear_handles ();+					e.path.recalculate_linear_handles_for_point (e.point); 				} 			} 			@@ -2292,7 +2292,7 @@ public class PenTool : Tool { 		ep.set_reflective_handles (false); 		 		if (ep.next == null) {-			// FIXME: write a new function for this case+			// FIXME: write a new method for this case 			// warning ("Next is null."); 		} @@ -2362,7 +2362,7 @@ public class PenTool : Tool { 			 		} 						-		ep.recalculate_linear_handles ();+		//FIXME: ep.recalculate_linear_handles (); 	} 	 	public static void convert_segment_to_line () {@@ -2377,6 +2377,10 @@ public class PenTool : Tool { 				convert_point_to_line (p.point, false); 			} 		}++		foreach (PointSelection p in selected_points) {+			p.path.recalculate_linear_handles_for_point (p.point);+		} 	} 	 	public static bool is_line (PointType t) {@@ -2482,7 +2486,7 @@ public class PenTool : Tool { 		// process connected handle 		if (point_type == PointType.QUADRATIC) { 			first.set_position (first.x, first.y);-			first.recalculate_linear_handles ();+			// FIXME: linear handles 		} 	} 	@@ -2521,6 +2525,7 @@ public class PenTool : Tool { 			}  			convert_point_type (e, DrawingTools.point_type);+			ps.path.recalculate_linear_handles_for_point (ps.point); 		} 		 		if (reset_selected) {diff --git a/libbirdfont/RectangleTool.vala b/libbirdfont/RectangleTool.valaindex fb29113..c5dd065 100644--- a/libbirdfont/RectangleTool.vala+++ b/libbirdfont/RectangleTool.vala@@ -81,7 +81,7 @@ public class RectangleTool : Tool { 			g.add_path (rectangle); 			 			foreach (EditPoint e in rectangle.points) {-				e.recalculate_linear_handles ();+				rectangle.recalculate_linear_handles_for_point (e); 			} 			 			rectangle.reset_stroke ();diff --git a/libbirdfont/StrokeTool.vala b/libbirdfont/StrokeTool.valaindex 5d2167e..ce111e1 100644--- a/libbirdfont/StrokeTool.vala+++ b/libbirdfont/StrokeTool.vala@@ -1042,7 +1042,7 @@ public class StrokeTool : GLib.Object { 	 					last = added_segment.get_last_point (); 					last.right_handle = ep.get_right_handle ().copy ();-					last.recalculate_linear_handles ();+					added_segment.recalculate_linear_handles_for_point (last); 						 					simplified.append_path (added_segment); @@ -1051,7 +1051,7 @@ public class StrokeTool : GLib.Object { 					if (added_segment.points.size > 0) { 						if (ep_start.get_right_handle ().is_line ()) { 							first = added_segment.get_first_point ();-							first.recalculate_linear_handles ();+							simplified.recalculate_linear_handles_for_point (first); 						} 					} 					@@ -1189,7 +1189,7 @@ public class StrokeTool : GLib.Object { 		nend = cap.add (end.x, end.y); 				 		for (int i = 0; i < cap.points.size; i++) {-			cap.points.get (i).recalculate_linear_handles ();+			cap.recalculate_linear_handles_for_point (cap.points.get (i)); 		} 		 		int size = cap.points.size;@@ -1220,7 +1220,7 @@ public class StrokeTool : GLib.Object { 		stroke2.delete_first_point ();  		last.convert_to_line ();-		last.recalculate_linear_handles ();+		stroke1.recalculate_linear_handles_for_point (last); 		 		last.next = stroke1.add_point (stroke2.get_first_point ()).get_link_item (); 		stroke2.delete_first_point ();@@ -1418,8 +1418,8 @@ public class StrokeTool : GLib.Object { 				cutoff2 = stroked.add_point (cutoff2); 			} 			-			cutoff1.recalculate_linear_handles ();-			cutoff2.recalculate_linear_handles ();+			stroked.recalculate_linear_handles_for_point (cutoff1);+			stroked.recalculate_linear_handles_for_point (cutoff2);  			// self intersection 			if (!d1 && !d2) { @@ -1755,15 +1755,15 @@ public class StrokeTool : GLib.Object { 		PenTool.convert_point_to_line (ep2, true); 		PenTool.convert_point_to_line (ep3, true); 		-		ep1.recalculate_linear_handles ();-		ep2.recalculate_linear_handles ();-		ep3.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (ep1);+		path.recalculate_linear_handles_for_point (ep2);+		path.recalculate_linear_handles_for_point (ep3); 		 		d =  Path.distance_to_point (prev, next); 		prev.get_right_handle ().length *= Path.distance_to_point (prev, ep1) / d; 		next.get_left_handle ().length *= Path.distance_to_point (ep3, next) / d; 		-		next.recalculate_linear_handles ();+		path.recalculate_linear_handles_for_point (next); 		 		return ep2; 	}diff --git a/libbirdfont/SvgParser.vala b/libbirdfont/SvgParser.valaindex f24184a..82554a8 100644--- a/libbirdfont/SvgParser.vala+++ b/libbirdfont/SvgParser.vala@@ -1817,7 +1817,7 @@ public class SvgParser { 		}  		foreach (EditPoint e in smooth_points) {-			e.recalculate_linear_handles ();+			path.recalculate_linear_handles_for_point (e); 		} 		 		for (int i = 0; i < 3; i++) {@@ -1890,7 +1890,7 @@ public class SvgParser { 					return_val_if_fail (path.points.size != 0, path_list); 					ep = path.points.get (path.points.size - 1); 					ep.get_right_handle ().set_point_type (PointType.LINE_CUBIC);-					ep.recalculate_linear_handles ();+					path.recalculate_linear_handles_for_point (ep); 				} else { 					warning ("Unexpected type: %s", (!) b[first_index].type.to_string ()); 				}@@ -1965,7 +1965,7 @@ public class SvgParser { 		}  		foreach (EditPoint e in smooth_points) {-			e.recalculate_linear_handles ();+			path.recalculate_linear_handles_for_point (e); 		} 		 		for (int i = 0; i < 3; i++) {diff --git a/libbirdfont/Task.vala b/libbirdfont/Task.valaindex 0804f1e..bd40dfb 100644--- a/libbirdfont/Task.vala+++ b/libbirdfont/Task.vala@@ -43,7 +43,6 @@ public class Task : GLib.Object { 	}  	public void cancel () {-		print("Cancel task.\n"); 		lock (cancelled) {			 			if (unlikely (!cancelable)) { 				warning ("Task is not cancelable.");@@ -70,7 +69,6 @@ public class Task : GLib.Object { 		} 		 		task ();-		print("Task finished.\n"); 	}  	public void* perform_task() {diff --git a/libbirdfont/TrackTool.vala b/libbirdfont/TrackTool.valaindex c1e504b..e02ac4e 100644--- a/libbirdfont/TrackTool.vala+++ b/libbirdfont/TrackTool.vala@@ -475,7 +475,7 @@ public class TrackTool : Tool { 		p.point.set_tie_handle (false); 		p.point.get_left_handle ().convert_to_line (); 		p.point.get_right_handle ().convert_to_line ();-		p.point.recalculate_linear_handles ();+		p.path.recalculate_linear_handles_for_point (p.point); 		last_update = get_current_time (); 		MainWindow.get_current_glyph ().update_view (); 	}@@ -582,7 +582,7 @@ public class TrackTool : Tool { 				previous = average.get_prev (); 				previous.type = DrawingTools.point_type; 				PenTool.convert_point_to_line (previous, true);-				previous.recalculate_linear_handles ();+				p.recalculate_linear_handles_for_point (previous); 				previous.process_tied_handle (); 				previous.set_tie_handle (false); 			}

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112