Clone in a terminal:
Commit 7ad9813
Johan Mattsson - 2015-03-05T19:17:53+00:00
7ad9813d80e8849839331fcfab42671ec7dc0a73johan.mattsson.m@gmail.com

Show side bearing metrics in edit view

Changed files (2)

Diff

diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 1312ffe..6956269 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -444,15 +444,27 @@ public class Glyph : FontDisplay { 							 		Line left_line = new Line ("left", left_limit, true); 		left_line.position_updated.connect ((pos) => {+			double x1, y1, x2, y2;+			 			left_limit = pos; 			update_other_spacing_classes ();+			+			boundaries (out x1, out y1, out x2, out y2);+			left_line.set_metrics (x1 - pos); 		});+		left_line.position_updated (left_limit); 		 		Line right_line = new Line ("right", right_limit, true); 		right_line.position_updated.connect ((pos) => {+			double x1, y1, x2, y2;+			 			right_limit = pos; 			update_other_spacing_classes ();+			+			boundaries (out x1, out y1, out x2, out y2);+			right_line.set_metrics (pos - x2); 		});+		right_line.position_updated (right_limit); 		 		// lists of lines are sorted and lines are added only if  		// they are relevant for a particular glyph.diff --git a/libbirdfont/Line.vala b/libbirdfont/Line.valaindex cc109a5..5fe2e3e 100644--- a/libbirdfont/Line.vala+++ b/libbirdfont/Line.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012 2014 Johan Mattsson+    Copyright (C) 2012 2014 2015 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 @@ -25,6 +25,7 @@ public class Line : GLib.Object { 	 	string label; 	bool vertical;+	string metrics; 	 	public double pos; 	@@ -48,6 +49,7 @@ public class Line : GLib.Object { 		this.pos = position; 		 		dashed = false;+		metrics = ""; 		 		r = 0.7; 		g = 0.7;@@ -69,6 +71,25 @@ public class Line : GLib.Object { 		return l; 	} 	+	public void set_metrics (double m) {+		string t = @"$m";+		string s = "";+		+		int i;+		unichar c;+		+		i = 0;+		while (t.get_next_char (ref i, out c)) {+			s = s + (!) c.to_string ();+			+			if (i >= 5) {+				break;+			}+		}+		+		metrics = s;+	}+	 	public void set_visible (bool v) { 		visible = v; 	}@@ -268,6 +289,7 @@ public class Line : GLib.Object { 		Glyph g = MainWindow.get_current_glyph (); 		double p, h, w; 		double size = (active) ? 8 : 5;+		Text glyph_metrics; 		 		if (!visible) { 			return;@@ -304,6 +326,12 @@ public class Line : GLib.Object { 				cr.line_to (p + size, h); 				cr.close_path(); 				cr.fill ();+				+				glyph_metrics = new Text (metrics, 17);+				glyph_metrics.set_source_rgba (72 / 255.0, 72 / 255.0, 72 / 255.0, 1);+				glyph_metrics.widget_x = p + 10;+				glyph_metrics.widget_y = h - 25;+				glyph_metrics.draw (cr); 			} 			 		} else {@@ -344,6 +372,8 @@ public class Line : GLib.Object { 		cr.restore (); 	} +	+ }  }

Contact

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