Clone in a terminal:
Commit 552ce58
Johan Mattsson - 2016-06-03T08:56:49+00:00
552ce585166fa9879f99c4ff8383d588c834caa6johan.mattsson.m@gmail.com

Merge branch '2.x' of github.com:johanmattssonm/birdfont into 2.x

Changed files (5)

Diff

diff --git a/libbirdfont/EditPointHandle.vala b/libbirdfont/EditPointHandle.valaindex f550122..efc5cf0 100644--- a/libbirdfont/EditPointHandle.vala+++ b/libbirdfont/EditPointHandle.vala@@ -49,7 +49,9 @@ public class EditPointHandle : GLib.Object {  			if (parent.reflective_point) { 				parent.process_symmetrical_handles ();-			}	+			}+			+			process_connected_handle (); 		} 	} @@ -75,6 +77,8 @@ public class EditPointHandle : GLib.Object { 			if (parent.reflective_point) { 				parent.process_symmetrical_handles (); 			}+			+			process_connected_handle (); 		} 	} @@ -289,16 +293,18 @@ public class EditPointHandle : GLib.Object { 			if (!is_left_handle ()) { 				if (parent.next != null) { 					h = parent.get_next ().get_left_handle ();+					h.parent.set_reflective_handles (false); 					h.parent.set_tie_handle (false); 					h.type = PointType.QUADRATIC;-					h.move_to_coordinate_internal (px (), py ());+					h.move_to_coordinate_internal (x, y); 				} 			} else { 				if (parent.prev != null) { 					h = parent.get_prev ().get_right_handle ();+					h.parent.set_reflective_handles (false); 					h.parent.set_tie_handle (false); 					h.type = PointType.QUADRATIC;-					h.move_to_coordinate_internal (px (), py ());+					h.move_to_coordinate_internal (x, y); 				} 			} 		}diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex 5582f2e..6f99f49 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -1316,7 +1316,7 @@ public class OverView : FontDisplay { 				} 				 				if (!is_null (i.version_menu)) {-					update = !i.version_menu.menu_visible;+					update = !((!)i).version_menu.menu_visible; 				} else { 					update = true; 				}diff --git a/libbirdfont/Renderer/FallbackFont.vala b/libbirdfont/Renderer/FallbackFont.valaindex 8235765..c696b4d 100644--- a/libbirdfont/Renderer/FallbackFont.vala+++ b/libbirdfont/Renderer/FallbackFont.vala@@ -109,7 +109,6 @@ public class FallbackFont : GLib.Object { 	}  	public void init_font_config () {-		print("init_font_config\n"); 		FcConfig* config; 		 #if MACdiff --git a/libbirdfont/StrokeTool.vala b/libbirdfont/StrokeTool.valaindex 2996b38..6476018 100644--- a/libbirdfont/StrokeTool.vala+++ b/libbirdfont/StrokeTool.vala@@ -1071,7 +1071,7 @@ public class StrokeTool : GLib.Object { 		return simplified; 	} 	-	Path fit_bezier_path (Path p, int start, int stop, double error) {+	public static Path fit_bezier_path (Path p, int start, int stop, double error) { 		int index, size; 		Path simplified; 		double[] lines;diff --git a/libbirdfont/TrackTool.vala b/libbirdfont/TrackTool.valaindex fc0c28a..bf6ab75 100644--- a/libbirdfont/TrackTool.vala+++ b/libbirdfont/TrackTool.vala@@ -1,5 +1,5 @@ /*-	Copyright (C) 2014 2015 Johan Mattsson+	Copyright (C) 2014 2015 2016 Johan Mattsson  	This library is free software; you can redistribute it and/or modify  	it under the terms of the GNU Lesser General Public License as @@ -97,16 +97,20 @@ public class TrackTool : Tool { 				 				if (join_paths) { 					ps = get_path_with_end_point (x, y);+					 					if (unlikely (ps == null)) { 						warning ("No end point."); 						return; 					}+					 					end_point = (!) ps;+ 					if (end_point.is_first ()) { 						end_point.path.reverse (); 					}+					+					Path path = end_point.path;					 					glyph.set_active_path (end_point.path);-					add_corner (x, y); 				} else { 					p = new Path (); 					glyph.add_path (p);@@ -150,11 +154,11 @@ public class TrackTool : Tool { 					 					if (p.points.size > 1) { 						previous = p.points.get (p.points.size - 1);-						previous.type = DrawingTools.point_type;+						previous.type = PointType.CUBIC; 						previous.set_tie_handle (false);  						previous = p.points.get (0);-						previous.type = DrawingTools.point_type;+						previous.type = PointType.CUBIC; 						previous.set_tie_handle (false); 					} 				}@@ -166,6 +170,7 @@ public class TrackTool : Tool { 							 				foreach (Path path in g.active_paths) { 					convert_hidden_points (path);+					path.update_region_boundaries (); 				} 				 				g.clear_active_paths ();@@ -221,8 +226,8 @@ public class TrackTool : Tool { 		foreach (EditPoint e in p.points) { 			if (e.type == PointType.HIDDEN) { 				e.type = DrawingTools.point_type;-				e.get_right_handle ().type = DrawingTools.point_type;-				e.get_left_handle ().type = DrawingTools.point_type;+				e.get_right_handle ().type = PointType.CUBIC;+				e.get_left_handle ().type = PointType.CUBIC; 			} 		} 	}@@ -292,16 +297,15 @@ public class TrackTool : Tool { 			return; 		} +		EditPoint last_point = p.get_last_point ();+		EditPointHandle handle = last_point.get_right_handle ();+		handle.convert_to_line ();+		p.recalculate_linear_handles ();++		PenTool.convert_point_type (p.get_last_point (), PointType.CUBIC);+		PenTool.convert_point_type (p.get_first_point (), PointType.CUBIC);+ 		p.create_list ();-		-		if (DrawingTools.get_selected_point_type () == PointType.QUADRATIC) {-			foreach (EditPoint e in p.points) {-				if (e.tie_handles) {-					e.convert_to_curve ();-					e.process_tied_handle ();							-				}-			}-		}  		if (PenTool.is_counter_path (p)) { 			p.force_direction (Direction.COUNTER_CLOCKWISE);@@ -334,10 +338,8 @@ public class TrackTool : Tool { 		 		merged.append_path (b.path); 		-		g = MainWindow.get_current_glyph ();-		+		g = MainWindow.get_current_glyph ();		 		g.add_path (merged);-		 		a.delete_last_point (); 		 		update_corner_handle (a.get_last_point (), b.path.get_first_point ());@@ -349,7 +351,7 @@ public class TrackTool : Tool { 		merged.update_region_boundaries (); 		merged.recalculate_linear_handles (); 		merged.reopen ();-		+ 		return merged; 	} @@ -405,13 +407,25 @@ public class TrackTool : Tool { 		 		p = glyph.active_paths.get (glyph.active_paths.size - 1); 		p.reopen ();++		EditPoint last_point = new EditPoint ();+		+		if (p.points.size > 0) {+			last_point = p.get_last_point ();+		}+		 		px = Glyph.path_coordinate_x (x); 		py = Glyph.path_coordinate_y (y);-		new_point = p.add (px, py);+		+		new_point = new EditPoint (px, py, PointType.CUBIC);+		p.add_point (new_point); 		added_points++;  		PenTool.convert_point_to_line (new_point, false); 		new_point.set_point_type (PointType.HIDDEN);+		p.recalculate_linear_handles_for_point (new_point);++		last_point.get_right_handle ().length = 0.000001;		 		 		if (p.points.size > 1) { 			glyph.redraw_segment (new_point, new_point.get_prev ());@@ -453,29 +467,28 @@ public class TrackTool : Tool { 			update_cycles = 0; 		} 		-		if (update_cycles > 4) { // cycles of 100 ms+		if (update_cycles > 0.7 * 10) { // delay in time 			convert_points_to_line ();-			last_update  = get_current_time ();+			last_update = get_current_time (); 			add_corner (last_x, last_y); 			added_points = 0; 			update_cycles = 0; 		} 			-		if (added_points > 25 / samples_per_point) {-			last_update  = get_current_time ();+		if (added_points > 80 / samples_per_point) {+			last_update = get_current_time (); 			convert_points_to_line (); 		} 	} 	 	/** Add a sharp corner instead of a smooth curve. */-	void add_corner (int px, int py) {-		PointSelection p;-		delete_last_points_at (px, py);-		p = PenTool.add_new_edit_point (px, py);-		p.point.set_tie_handle (false);-		p.point.get_left_handle ().convert_to_line ();-		p.point.get_right_handle ().convert_to_line ();-		p.path.recalculate_linear_handles_for_point (p.point);+	void add_corner (double px, double py) {+		EditPoint p;+		p = new EditPoint (px, py, PointType.CUBIC);+		p.set_tie_handle (false);+		p.get_left_handle ().convert_to_line ();+		p.get_right_handle ().convert_to_line ();+		get_active_path ().recalculate_linear_handles_for_point (p); 		last_update = get_current_time (); 		MainWindow.get_current_glyph ().update_view (); 	}@@ -492,8 +505,7 @@ public class TrackTool : Tool { 	} 	 	/** Delete all points close to the pixel at x,y. */-	void delete_last_points_at (int x, int y) {-		double px, py;+	void delete_last_points_at (double px, double py) { 		Path p; 					 		p = get_active_path ();@@ -503,9 +515,6 @@ public class TrackTool : Tool { 			return; 		} -		px = Glyph.path_coordinate_x (x);-		py = Glyph.path_coordinate_y (y);- 		while (p.points.size > 0 && is_close (p.points.get (p.points.size - 1), px, py)) { 			p.delete_last_point (); 		}@@ -552,42 +561,22 @@ public class TrackTool : Tool { 		sum_x = 0; 		sum_y = 0; 		-		last_point = p.points.get (p.points.size - 1);+		int start = p.points.size - 1 - added_points;+		int stop = p.points.size - 1; 		-		for (int i = 0; i < added_points; i++) {-			ep = p.delete_last_point ();-			sum_x += ep.x;-			sum_y += ep.y;			-			points.add (ep);-		}+		EditPoint end = p.points.get (stop); 		-		nx = sum_x / added_points;-		ny = sum_y / added_points;--		px = Glyph.reverse_path_coordinate_x (nx);-		py = Glyph.reverse_path_coordinate_y (ny);-		average = PenTool.add_new_edit_point (px, py).point;-		average.type = PointType.HIDDEN;+		Path segment = StrokeTool.fit_bezier_path (p, start, stop, 5.0 / samples_per_point); 		-		// tie handles for all points except for the end points-		average.set_tie_handle (p.points.size > 1); +		for (int i = 0; i < added_points; i++) {+			p.delete_last_point ();+		}		 		-		if (unlikely (p.points.size == 0)) {-			warning ("No points.");-			return;-		}+		p.append_path (segment);+		p.remove_points_on_points ();+		+		add_corner (end.x, end.y); 		-		if (average.prev != null && average.get_prev ().tie_handles) {-			if (p.points.size > 2) {-				previous = average.get_prev ();-				previous.type = DrawingTools.point_type;-				PenTool.convert_point_to_line (previous, true);-				p.recalculate_linear_handles_for_point (previous);-				previous.process_tied_handle ();-				previous.set_tie_handle (false);-			}-		}- 		added_points = 0; 		last_update = get_current_time (); 		glyph.update_view ();

Contact

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