The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix text rendering

These changes was commited to the Birdfont repository Thu, 28 May 2015 13:58:43 +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>
Thu, 28 May 2015 13:58:43 +0000 (15:58 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 28 May 2015 14:00:12 +0000 (16:00 +0200)
commit b22c662ea976811e921092d4ea2f91649d7f8379
tree 4e2c48996035434f12ff307b7348b42ba56517f8
parent e66a96ab2d534448ac2ac4820a8f363a158d253f
Fix text rendering

libbirdfont/BirdFontFile.vala
libbirdfont/GlyphCollection.vala
libbirdfont/Renderer/CachedFont.vala
libbirdfont/Renderer/Text.vala
libbirdfont/SpinButton.vala
libbirdfont/Tool.vala
libbirdfont/VersionList.vala
--- a/libbirdfont/BirdFontFile.vala +++ b/libbirdfont/BirdFontFile.vala @@ -370,7 +370,7 @@ } 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 {
--- a/libbirdfont/GlyphCollection.vala +++ b/libbirdfont/GlyphCollection.vala @@ -22,7 +22,7 @@ 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;
--- a/libbirdfont/Renderer/CachedFont.vala +++ b/libbirdfont/Renderer/CachedFont.vala @@ -19,10 +19,25 @@ 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 {
--- a/libbirdfont/Renderer/Text.vala +++ b/libbirdfont/Renderer/Text.vala @@ -53,8 +53,8 @@ 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 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 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) {
--- a/libbirdfont/SpinButton.vala +++ b/libbirdfont/SpinButton.vala @@ -284,7 +284,6 @@ show_adjustmet_icon (); new_value_action (this); - // FIXME: delete redraw (); } int8 parse (string s) { @@ -370,7 +369,6 @@ } 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 @@ } text.widget_x = text_x; - text.widget_y = text_y; + text.widget_y = text_y + text.get_decender (); text.draw (cr); } }
--- a/libbirdfont/Tool.vala +++ b/libbirdfont/Tool.vala @@ -194,7 +194,7 @@ 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 @@ 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) {
--- a/libbirdfont/VersionList.vala +++ b/libbirdfont/VersionList.vala @@ -247,7 +247,7 @@ 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) => {