Clone in a terminal:
Commit b7f0355
Johan Mattsson - 2015-03-19T14:27:37+00:00
b7f0355d119685cdd76db97aa214d1b716b14281johan.mattsson.m@gmail.com

Thread safety and better text in kerning range

Changed files (3)

Diff

diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 37c8c62..303b5a3 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -923,13 +923,13 @@ class BirdFontFile : GLib.Object { 			} 			 			if (range_left.get_length () > 1) {-				kerning_range = new KerningRange ();+				kerning_range = new KerningRange (font); 				kerning_range.set_ranges (range_left.get_all_ranges ()); 				KerningTools.add_unique_class (kerning_range); 			}  			if (range_right.get_length () > 1) {-				kerning_range = new KerningRange ();+				kerning_range = new KerningRange (font); 				kerning_range.set_ranges (range_right.get_all_ranges ()); 				KerningTools.add_unique_class (kerning_range); 			}diff --git a/libbirdfont/KerningRange.vala b/libbirdfont/KerningRange.valaindex c4bbec7..82c6b6f 100644--- a/libbirdfont/KerningRange.vala+++ b/libbirdfont/KerningRange.vala@@ -22,9 +22,13 @@ public class KerningRange : Tool { 	public string ranges = ""; 	public GlyphRange glyph_range;  	bool malformed = false;+	Font font; 	-	public KerningRange (string? name = null, string tip = "") {+	public KerningRange (Font f, string? name = null, string tip = "") { 		base (null , tip);++		font = f;+		 		glyph_range = new GlyphRange ();  		 		if (name != null) {@@ -57,7 +61,6 @@ public class KerningRange : Tool { 	 	public void set_ranges (string r) { 		GlyphRange glyph_range = new GlyphRange ();-		Font font = BirdFont.get_current_font (); 		SpacingData spacing = font.get_spacing (); 		string new_range; 		string ch;@@ -90,7 +93,6 @@ public class KerningRange : Tool { 	} 		 	private void set_one_range (string r) throws MarkupError {-		Font f = BirdFont.get_current_font (); 		GlyphRange old = new GlyphRange (); 		 		old.parse_ranges (ranges);@@ -103,7 +105,7 @@ public class KerningRange : Tool { 		glyph_range.parse_ranges (r); 		glyph_range.set_class (true); -		f.spacing.kerning_classes.update_range (old, glyph_range);+		font.spacing.kerning_classes.update_range (old, glyph_range); 	} 	 	public void update_kerning_classes () {@@ -132,19 +134,21 @@ public class KerningRange : Tool { 	 	public override void draw (Context cr) { 		double xt, yt;+		Text label_text;  		xt = x + 5; 		yt = y + 10; 		 		cr.save (); 	-		// FIXME: use color to indicate error-		Theme.color (cr, "Foreground 1");+		label_text = new Text ();+		label_text.set_text (name);+		Theme.text_color (label_text, "Foreground 2");+		label_text.set_font_size (18);+		label_text.widget_x = x;+		label_text.widget_y = y;+		label_text.draw (cr); 		-		cr.set_font_size (10);-		cr.select_font_face ("Cantarell", FontSlant.NORMAL, FontWeight.NORMAL);-		cr.move_to (xt, yt);-		cr.show_text (name); 		cr.restore (); 	} }diff --git a/libbirdfont/KerningTools.vala b/libbirdfont/KerningTools.valaindex 5690e9d..1006225 100644--- a/libbirdfont/KerningTools.vala+++ b/libbirdfont/KerningTools.vala@@ -54,7 +54,10 @@ public class KerningTools : ToolCollection  { 		 		Tool new_kerning_class = new Tool ("kerning_class", t_("Create new kerning class.")); 		new_kerning_class.select_action.connect ((self) => {-			classes.add_tool (new KerningRange (@"Kerning class $(++next_class)"));+			Font font = BirdFont.get_current_font ();+			string label = t_("Kerning class");+			KerningRange kr = new KerningRange (font, @"$label $(++next_class)");+			classes.add_tool (kr); 			Toolbox.redraw_tool_box (); 		}); 		kerning_tools.add_tool (new_kerning_class);@@ -131,7 +134,8 @@ public class KerningTools : ToolCollection  { 	} 	 	public static void update_kerning_classes () {-		KerningClasses k = BirdFont.get_current_font ().get_kerning_classes ();+		Font font = BirdFont.get_current_font ();+		KerningClasses k = font.get_kerning_classes (); 		KerningRange kr; 		GlyphRange r; 		int i;@@ -141,14 +145,14 @@ public class KerningTools : ToolCollection  { 		for (i = 0; i < k.classes_first.size; i++) { 			r = k.classes_first.get (i); 			if (r.is_class ()) {-				kr = new KerningRange ();+				kr = new KerningRange (font); 				kr.set_ranges (r.get_all_ranges ()); 				add_unique_class (kr); 			} 			 			r = k.classes_last.get (i); 			if (r.is_class ()) {-				kr = new KerningRange ();+				kr = new KerningRange (font); 				kr.set_ranges (r.get_all_ranges ()); 				add_unique_class (kr); 			}

Contact

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