The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

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

These changes was commited to the Birdfont repository Mon, 25 May 2015 07:08:17 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 25 May 2015 07:08:17 +0000 (09:08 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 25 May 2015 07:08:55 +0000 (09:08 +0200)
commit 0ae563fe07f5df2eef49d1b92c1552dc0adde6e1
tree d13bfe55e459bb3eed5af0b3bafe8b2eaefbd62f
parent 479c884a242f1a8cbfad7a0bc53ec9a5db0fa521
Use empty character as .notdef and fix text alignment in spin button

libbirdfont/Renderer/Text.vala
libbirdfont/SpinButton.vala
--- a/libbirdfont/Renderer/Text.vala +++ b/libbirdfont/Renderer/Text.vala @@ -178,7 +178,7 @@ 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 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); }
--- a/libbirdfont/SpinButton.vala +++ b/libbirdfont/SpinButton.vala @@ -449,14 +449,10 @@ 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 @@ 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); } }