Clone in a terminal:
Commit 7ac9f3a
Johan Mattsson - 2014-11-28T17:57:40+00:00
7ac9f3a50d59f2c6f54a30bbb96e49e4c19aea0djohan.mattsson.m@gmail.com

Center label in background selection

Changed files (2)

Diff

diff --git a/libbirdfont/BackgroundSelectionTool.vala b/libbirdfont/BackgroundSelectionTool.valaindex 288d1b1..da9e3e6 100644--- a/libbirdfont/BackgroundSelectionTool.vala+++ b/libbirdfont/BackgroundSelectionTool.vala@@ -35,7 +35,7 @@ public class BackgroundSelectionTool : CutBackgroundTool { 			double x, y, w, h; 			BackgroundImage bg; 			Text label = new Text ();-			double tx, ty, font_height;+			double tx, ty, font_height, glyph_height; 			 			if (glyph.get_background_image () == null) { 				warning ("No image");@@ -72,9 +72,7 @@ public class BackgroundSelectionTool : CutBackgroundTool { 						label.set_text ((!) bs.assigned_glyph); 						label.set_font_size (font_height); 						tx = x  + w - label.get_width () / 2.0;-						ty = y + h;-						ty += label.get_height () / 2.0;-						ty -= label.get_decender (font_height);+						ty = y + h + label.get_acender () / 2.0 -  label.get_decender (); 						label.set_font_size (font_height); 						label.draw_at_baseline (cr, tx, ty); 					}diff --git a/libbirdfont/Renderer/Text.vala b/libbirdfont/Renderer/Text.valaindex 3b5b103..8228928 100644--- a/libbirdfont/Renderer/Text.vala+++ b/libbirdfont/Renderer/Text.vala@@ -218,7 +218,7 @@ public class Text : Widget { 		return font_size; 	} -	public double get_glyph_height () {+	public double get_acender () { 		double ratio = get_scale (); 		double max_height = 0; @@ -232,7 +232,7 @@ public class Text : Widget { 			} 		}); 		-		return max_height * ratio;+		return max_height * ratio - font.base_line * ratio; 	}	  	public override double get_width () {@@ -262,7 +262,7 @@ public class Text : Widget { 		return x; 	} -	public double get_decender (double font_size_in_pixels) {+	public double get_decender () { 		double ratio = get_scale (); 		double min_y = 0; 		double decender;@@ -277,7 +277,7 @@ public class Text : Widget { 			} 		}); 		-		decender = font.base_line - (min_y * ratio);+		decender = font.base_line * ratio - min_y * ratio; 		return decender > 0 ? decender : 0;  	}		 

Contact

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