Clone in a terminal:
Commit b22c662
Johan Mattsson - 2015-05-28T14:00:12+00:00
b22c662ea976811e921092d4ea2f91649d7f8379johan.mattsson.m@gmail.com

Fix text rendering

Changed files (7)

Diff

diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 0756152..e6b1b64 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -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 {diff --git a/libbirdfont/GlyphCollection.vala b/libbirdfont/GlyphCollection.valaindex d2c76b4..ebce161 100644--- a/libbirdfont/GlyphCollection.vala+++ b/libbirdfont/GlyphCollection.vala@@ -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;diff --git a/libbirdfont/Renderer/CachedFont.vala b/libbirdfont/Renderer/CachedFont.valaindex d291b96..0437a57 100644--- a/libbirdfont/Renderer/CachedFont.vala+++ b/libbirdfont/Renderer/CachedFont.vala@@ -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 {diff --git a/libbirdfont/Renderer/Text.vala b/libbirdfont/Renderer/Text.valaindex c1bf3b6..96f642a 100644--- a/libbirdfont/Renderer/Text.vala+++ b/libbirdfont/Renderer/Text.vala@@ -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) {diff --git a/libbirdfont/SpinButton.vala b/libbirdfont/SpinButton.valaindex d7bdf7f..65a29cb 100644--- a/libbirdfont/SpinButton.vala+++ b/libbirdfont/SpinButton.vala@@ -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); 		} 	}diff --git a/libbirdfont/Tool.vala b/libbirdfont/Tool.valaindex 7145d04..0ba6f92 100644--- a/libbirdfont/Tool.vala+++ b/libbirdfont/Tool.vala@@ -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) {diff --git a/libbirdfont/VersionList.vala b/libbirdfont/VersionList.valaindex 4fc11d4..3e140ee 100644--- a/libbirdfont/VersionList.vala+++ b/libbirdfont/VersionList.vala@@ -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) => {

Contact

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