Clone in a terminal:
Commit 0ae563f
Johan Mattsson - 2015-05-25T07:08:55+00:00
0ae563fe07f5df2eef49d1b92c1552dc0adde6e1johan.mattsson.m@gmail.com

Use empty character as .notdef and fix text alignment in spin button

Changed files (2)

Diff

diff --git a/libbirdfont/Renderer/Text.vala b/libbirdfont/Renderer/Text.valaindex 7e54998..fe85ad1 100644--- a/libbirdfont/Renderer/Text.vala+++ b/libbirdfont/Renderer/Text.vala@@ -178,7 +178,7 @@ public class Text : Widget { 				g = cached_font.get_glyph_by_name (glyph_names.get (i)); 			} 			-			glyph = (g == null) ? cached_font.get_not_def_character ().get_current () : (!) g;+			glyph = (g == null) ? new Glyph ("") : (!) g; 			iter (glyph, kern, i + 1 == word_with_ligatures.glyph.size);			 			prev = g; 			wi++;@@ -301,9 +301,6 @@ public class Text : Widget { 	public override void draw (Context cr) { 		double descender = cached_font.bottom_limit + cached_font.base_line; 		double y = widget_y + get_height () + get_scale () * descender;-			-		cached_font.get_glyph_by_name ((!) text.get_char (0).to_string ());-		 		draw_at_baseline (cr, widget_x, y); 	} 	diff --git a/libbirdfont/SpinButton.vala b/libbirdfont/SpinButton.valaindex e46d301..d7bdf7f 100644--- a/libbirdfont/SpinButton.vala+++ b/libbirdfont/SpinButton.vala@@ -449,14 +449,10 @@ public class SpinButton : Tool { 	 	public override void draw (Context cr) { 		double scale = Toolbox.get_scale ();-		-		double xt = x + w / 2;-		double yt = y;--		double text_x = -13 * scale;-		double text_y = 7 * scale;--		Text text = new Text (get_short_display_value (), 15);+		double text_height = 14 * scale;+		Text text = new Text (get_short_display_value (), text_height);+		double text_x = x + (w - text.get_sidebearing_extent ()) / 2;+		double text_y = y + (h - text_height) / 2;  		if (!show_icon_tool_icon || waiting_for_icon_switch) { 			if (is_selected ()) {@@ -482,8 +478,8 @@ public class SpinButton : Tool { 				Theme.text_color (text, "Tool Foreground"); 			} 			-			text.widget_x = xt + text_x;-			text.widget_y = yt + text_y;+			text.widget_x = text_x;+			text.widget_y = text_y; 			text.draw (cr); 		} 	}

Contact

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