Clone in a terminal:
Commit 5af849d
Johan Mattsson - 2014-03-23T17:48:31+00:00
5af849d1a83520742efb889f7d00a82678cdf83djohan.mattsson.m@gmail.com

Faster overview and kerning code

Changed files (5)

Diff

diff --git a/libbirdfont/EditPointHandle.vala b/libbirdfont/EditPointHandle.valaindex 3db4a5d..4087014 100644--- a/libbirdfont/EditPointHandle.vala+++ b/libbirdfont/EditPointHandle.vala@@ -159,7 +159,6 @@ public class EditPointHandle  { 		if (unlikely(c == 0)) { 			angle = 0; // FIXME: this should be a different point type without line handles 			length = 0;-			warning ("Too short handle."); 			return; 		} 		diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex c971650..27075fd 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1335,6 +1335,24 @@ public class Glyph : FontDisplay { 		cr.stroke ();		 	} 	+	/** Draw filled paths. */+	public void draw_paths (Context cr) {+		PathList stroke;+		+		cr.save ();+		cr.new_path ();+		foreach (unowned Path p in path_list) {+			if (p.stroke > 0) {+				stroke = StrokeTool.get_stroke (p, p.stroke);+				draw_path_list (stroke, cr, Color.black ());+			} else {+				p.draw_path (cr, Color.black ());+			}+		}+		cr.fill ();+		cr.restore ();+	}+	 	public void draw_path (Context cr) { 		if (is_open () && Path.fill_open_path) { 			cr.save ();@@ -1850,6 +1868,17 @@ public class Glyph : FontDisplay { 		} 	} 	+	/** @return left side bearing */+	public double get_lsb () {+		return get_line ("left").pos;+	}++	/** @return bottom line */+	public double get_baseline () {+		Font font = BirdFont.get_current_font ();+		return font.base_line;+	}+	 	void draw_background_glyph (WidgetAllocation allocation, Context cr) { 		double left, baseline, current_left; 		Glyph g;diff --git a/libbirdfont/KerningDisplay.vala b/libbirdfont/KerningDisplay.valaindex 9397c8c..0a53381 100644--- a/libbirdfont/KerningDisplay.vala+++ b/libbirdfont/KerningDisplay.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012 Johan Mattsson+    Copyright (C) 2012, 2014 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 @@ -156,7 +156,11 @@ public class KerningDisplay : FontDisplay { 					 					// TODO: set font size 					// cr.scale (KerningTools.font_size, KerningTools.font_size);-					Svg.draw_svg_path (cr, glyph.get_svg_data (), x + kern, y);+					cr.save ();+					glyph.add_help_lines ();+					cr.translate (kern + x - glyph.get_lsb () - Glyph.xc (), glyph.get_baseline () + y  - Glyph.yc ());+					glyph.draw_paths (cr);+					cr.restore (); 					 					w = glyph.get_width (); 				}diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex 860e064..9009f7c 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012 Johan Mattsson+    Copyright (C) 2012, 2014 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 @@ -140,8 +140,13 @@ public class OverViewItem : GLib.Object { 			Surface s = new Surface.similar (cr.get_target (), Content.COLOR_ALPHA, (int) w, (int) h - 20); 			Context c = new Context (s); 			-			c.scale (scale, scale);				-			Svg.draw_svg_path (c, g.get_svg_data (), gx, gy);+			c.save ();+			c.scale (scale, scale);	+			+			g.add_help_lines ();+			c.translate (gx - g.get_lsb () - Glyph.xc (), g.get_baseline () + gy - Glyph.yc ());+			g.draw_paths (c);+			c.restore (); 			 			cr.save (); 			cr.set_source_surface (s, x, y - h);diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex 00b8bf1..60a9eb7 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -318,7 +318,7 @@ public class Path { 		cr.set_source_rgba (line_color_r, line_color_g, line_color_b, line_color_a); 		cr.set_line_width (stroke_width / g.view_zoom); 		-		cr.line_to (xa, ya); // this point makes sense only if it is the first or last position, the other points are meaningless don't export them+		cr.line_to (xa, ya); // this point makes sense only if it is in the first or last position  		if (t == PointType.QUADRATIC || t == PointType.LINE_QUADRATIC || t == PointType.DOUBLE_CURVE || u == PointType.QUADRATIC || u == PointType.LINE_QUADRATIC || u == PointType.DOUBLE_CURVE) { 			cr.curve_to ((xa + 2 * xb) / 3, (ya + 2 * yb) / 3, (xd + 2 * xb) / 3, (yd + 2 * yb) / 3, xd, yd);		

Contact

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