Commit b22c662
Fix text rendering
Changed files (7)
modifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/GlyphCollection.valamodifiedlibbirdfont/Renderer/CachedFont.valamodifiedlibbirdfont/Renderer/Text.valamodifiedlibbirdfont/SpinButton.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdfont/VersionList.vala
Diff
@@ -370,7 +370,7 @@ class BirdFontFile : GLib.Object { } public void write_selected (GlyphCollection gc, DataOutputStream os) throws GLib.Error {- os.put_string (@"\t<selected id=\"$(gc.selected)\"/>\n");+ os.put_string (@"\t<selected id=\"$(gc.get_current ().version_id)\"/>\n"); } public void write_glyph_collection (GlyphCollection gc, DataOutputStream os) throws GLib.Error {@@ -22,7 +22,7 @@ public class GlyphCollection : GLib.Object { string name; bool unassigned = false; public Gee.ArrayList<Glyph> glyphs = new Gee.ArrayList<Glyph> ();- public int selected = 0;+ int selected; public GlyphCollection (unichar unicode_character, string name) { this.unicode_character = unicode_character;@@ -19,10 +19,25 @@ namespace BirdFont { public class CachedFont : GLib.Object { public Font? font; - // FIXME: move fallback glyphs in to fond boundaries- public double top_limit = 84;+ public double top_limit {+ get {+ return _top_limit;+ }+ + set { _top_limit = value; }+ }++ public double bottom_limit {+ get {+ return _bottom_limit;+ }+ + set { _bottom_limit = value; }+ }+ public double base_line = 0;- public double bottom_limit = -27;+ double _top_limit = 92.77; // FIXME: load before first glyph+ double _bottom_limit = -24.4; FallbackFont fallback_font { get {@@ -53,8 +53,8 @@ public class Text : Widget { font_cache = FontCache.get_default_cache (); cached_font = font_cache.get_fallback (); - set_font_size (size); set_text (text);+ set_font_size (size); } public void use_cache (bool cache) {@@ -68,11 +68,14 @@ public class Text : Widget { public bool load_font (string font_file) { File path; File f;+ FontCache fc; f = File.new_for_path (font_file); path = (f.query_exists ()) ? f : SearchPaths.find_file (null, font_file); - cached_font = FontCache.get_default_cache ().get_font ((!) path.get_path ());+ fc = FontCache.get_default_cache ();+ cached_font = fc.get_font ((!) path.get_path ());+ gs = generate_glyphs (); return cached_font.font != null; }@@ -80,6 +83,10 @@ public class Text : Widget { public void set_font_size (double height_in_pixels) { font_size = height_in_pixels; sidebearing_extent = 0;+ + if (gs == null) { // ensure height is loaded for the font+ gs = generate_glyphs ();+ } } public void set_font_cache (FontCache font_cache) {@@ -284,7 +284,6 @@ public class SpinButton : Tool { show_adjustmet_icon (); new_value_action (this);- // FIXME: delete redraw (); } int8 parse (string s) {@@ -370,7 +369,6 @@ public class SpinButton : Tool { } show_adjustmet_icon ();- // FIXME: delete redraw (); } public void set_value_round (double v, bool check_boundaries = true, bool emit_signal = true) {@@ -479,7 +477,7 @@ public class SpinButton : Tool { } text.widget_x = text_x;- text.widget_y = text_y;+ text.widget_y = text_y + text.get_decender (); text.draw (cr); } }@@ -194,7 +194,7 @@ public class Tool : Widget { icon_font = new Text ((!) name); found = icon_font.load_font (icon_file); icon_font.use_cache (true);- icon_font.set_font_size (35 * Toolbox.get_scale ());+ icon_font.set_font_size (40 * Toolbox.get_scale ()); if (!found) { warning (@"Icon font for toolbox was not found. ($(icon_file))");@@ -298,7 +298,7 @@ public class Tool : Widget { cr.stroke (); iconx = bgx + 1 + (w - 1) / 2 - icon_font.get_sidebearing_extent () / 2;- icony = bgy + 1 + (h - 1)/ 2 - icon_font.get_height () / 2;+ icony = bgy - 1 + (h - 1) / 2 - icon_font.get_height () / 2; if (icon_color == "") { if (!selected) {@@ -247,7 +247,7 @@ public class VersionList : GLib.Object { v = new_version.version_id; glyphs.add (new_version); - ma = add_item (t_("Version") + @" $(v - 1)");+ ma = add_item (t_("Version") + @" $(v + 1)"); ma.index = (int) glyphs.size - 1; ma.action.connect ((self) => {