Clone in a terminal:
Commit e63f654
Johan Mattsson - 2014-11-11T13:03:22+00:00
e63f6540e510d0959c77fdf6782de17a0fb05aedjohan.mattsson.m@gmail.com

Add label to assigned backgrounds

Changed files (10)

Diff

diff --git a/graphics/tools_and_buttons.svg b/graphics/tools_and_buttons.svgindex 5514f5c..34a2f3f 100644--- a/graphics/tools_and_buttons.svg+++ b/graphics/tools_and_buttons.svg@@ -1523,9 +1523,9 @@      borderopacity="1.0"      inkscape:pageopacity="0.0"      inkscape:pageshadow="2"-     inkscape:zoom="4.4432529"-     inkscape:cx="411.21063"-     inkscape:cy="248.2595"+     inkscape:zoom="1.4142136"+     inkscape:cx="339.37669"+     inkscape:cy="151.28469"      inkscape:current-layer="layer1"      inkscape:document-units="px"      showgrid="false"@@ -5450,25 +5450,25 @@        inkscape:export-ydpi="319.88824"        inkscape:export-xdpi="319.88824"        inkscape:export-filename="/home/johan/birdfont/icons/scale_background.png"-       y="547.02863"+       y="551.02863"        x="291.72751"        height="7.524229"        width="7.4313707"        id="rect4423-3-4"        style="fill:none;stroke:#656a73;stroke-width:0.80000001;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     <rect-       style="fill:none;stroke:#656a73;stroke-width:0.8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"+       style="fill:none;stroke:#656a73;stroke-width:0.80000001;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"        id="rect5580"        width="14.58137"        height="12.174229"        x="291.70929"-       y="542.41284"+       y="546.41284"        inkscape:export-filename="/home/johan/birdfont/icons/scale_background.png"        inkscape:export-xdpi="319.88824"        inkscape:export-ydpi="319.88824" />     <path        style="fill:none;stroke:#656a73;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"-       d="m 332.99807,547.42258 1.84771,-1.84772 -2.41624,-2.41624 9.13198,0 0,9.48731 -2.18528,-2.18528 -1.51015,1.58122 2.13588,2.20079 -9.38461,0.002 0,-9.02539 z"+       d="m 332.99807,551.42258 1.84771,-1.84772 -2.41624,-2.41624 9.13198,0 0,9.48731 -2.18528,-2.18528 -1.51015,1.58122 2.13588,2.20079 -9.38461,0.002 0,-9.02539 z"        id="path4060-1-5"        inkscape:connector-curvature="0"        sodipodi:nodetypes="ccccccccccc"@@ -5476,62 +5476,196 @@        inkscape:export-xdpi="319.88824"        inkscape:export-ydpi="319.88824" />     <rect-       style="opacity:0.71193417000000003;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000000999999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"+       style="opacity:0.71193417;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"        id="rect5600"        width="7.5620122"        height="8.1921797"        x="366.7576"-       y="545.13068"+       y="549.13068"        inkscape:export-filename="/home/johan/birdfont/icons/auto_trace_resolution.png"        inkscape:export-xdpi="319"        inkscape:export-ydpi="319" />     <rect-       style="opacity:0.71193417000000003;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000000999999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"+       style="opacity:0.71193417;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"        id="rect5606"        width="3.0634775"        height="3.1430483"        x="375.93243"-       y="545.12207"+       y="549.12207"        inkscape:export-filename="/home/johan/birdfont/icons/auto_trace_resolution.png"        inkscape:export-xdpi="319"        inkscape:export-ydpi="319" />     <rect-       style="opacity:0.71193417000000003;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000000999999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"+       style="opacity:0.71193417;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"        id="rect5606-0"        width="3.0634775"        height="3.1430483"        x="380.3685"-       y="545.10217"+       y="549.10217"        inkscape:export-filename="/home/johan/birdfont/icons/auto_trace_resolution.png"        inkscape:export-xdpi="319"        inkscape:export-ydpi="319" />     <rect-       style="opacity:0.71193417000000003;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000000999999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"+       style="opacity:0.71193417;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"        id="rect5606-0-2"        width="3.0634775"        height="3.1430483"        x="380.36853"-       y="550.15491"+       y="554.15491"        inkscape:export-filename="/home/johan/birdfont/icons/auto_trace_resolution.png"        inkscape:export-xdpi="319"        inkscape:export-ydpi="319" />     <rect-       style="opacity:0.71193417000000003;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000000999999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"+       style="opacity:0.71193417;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000001;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"        id="rect5606-0-7"        width="3.0634775"        height="3.1430483"        x="375.91254"-       y="550.1947"+       y="554.1947"        inkscape:export-filename="/home/johan/birdfont/icons/auto_trace_resolution.png"        inkscape:export-xdpi="319"        inkscape:export-ydpi="319" />     <path        style="fill:#000000;fill-opacity:0;stroke:#656a73;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"-       d="m 406.78643,542.63457 -2.15625,2.25 4.1875,3.96875 -4.1875,3.96875 2.15625,2.25 4.28125,-4.0625 4.3125,4.0625 2.125,-2.25 -4.1875,-3.96875 4.1875,-3.96875 -2.125,-2.25 -4.3125,4.0625 -4.28125,-4.0625 z"+       d="m 406.78643,546.63457 -2.15625,2.25 4.1875,3.96875 -4.1875,3.96875 2.15625,2.25 4.28125,-4.0625 4.3125,4.0625 2.125,-2.25 -4.1875,-3.96875 4.1875,-3.96875 -2.125,-2.25 -4.3125,4.0625 -4.28125,-4.0625 z"        id="rect3375-3"        inkscape:connector-curvature="0"        inkscape:export-filename="/home/johan/birdfont/icons/delete_background.png"        inkscape:export-xdpi="319"        inkscape:export-ydpi="319" />+    <rect+       style="opacity:0.98000004;color:#000000;fill:#ed4300;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"+       id="rect3770"+       width="14.322752"+       height="12.342386"+       x="392.47171"+       y="37.097404" />+    <g+       id="g4386-2"+       transform="translate(279.05816,441.43622)"+       style="stroke:#858585"+       inkscape:export-filename="/home/johan/birdfont/icons/union_paths.png"+       inkscape:export-xdpi="319.88824"+       inkscape:export-ydpi="319.88824">+      <path+         inkscape:connector-curvature="0"+         id="path4325-1"+         d="m 24.121545,137.00393 c -2.790541,0 -5.0625,2.27196 -5.0625,5.0625 0,0.28366 0.04882,0.57283 0.09375,0.84375 -0.213093,-0.0254 -0.43631,-0.0312 -0.65625,-0.0312 -2.997324,0 -5.4375,2.44018 -5.4375,5.4375 0,2.99732 2.440176,5.40625 5.4375,5.40625 2.997324,0 5.4375,-2.40893 5.4375,-5.40625 0,-0.41889 -0.06642,-0.82711 -0.15625,-1.21875 0.111215,0.007 0.230685,0.0312 0.34375,0.0312 2.790541,0 5.0625,-2.27196 5.0625,-5.0625 0,-2.79054 -2.271959,-5.0625 -5.0625,-5.0625 z"+         style="fill:#e6e6e6;fill-opacity:1;stroke:#858585;stroke-width:0.80000001;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />+      <path+         inkscape:connector-curvature="0"+         id="path4334-6"+         d="m 20.201005,143.05025 1.002199,0.26853"+         style="fill:none;stroke:#858585;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />+      <path+         style="fill:none;stroke:#858585;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"+         d="m 23.149414,144.92095 0.334337,0.98221"+         id="path4338-5-9"+         inkscape:connector-curvature="0" />+      <path+         style="fill:none;stroke:#858585;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"+         d="m 21.809082,143.65195 0.803947,0.65589"+         id="path4338-5-4-0"+         inkscape:connector-curvature="0" />+    </g>+    <path+       style="fill:#858585;stroke:#858585;stroke-width:0.20579898;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"+       d="m 367.8232,580.82361 0,7.13575 18.61499,0 z"+       id="path4441-46"+       inkscape:connector-curvature="0"+       inkscape:export-filename="/home/johan/birdfont/icons/flip_vertical.png"+       inkscape:export-xdpi="319.88824"+       inkscape:export-ydpi="319.88824" />+    <path+       inkscape:connector-curvature="0"+       id="path4443-7"+       d="m 368.08547,596.98785 0,-6.93467 18.09045,0 z"+       style="fill:#ffffff;fill-opacity:1;stroke:#858585;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"+       inkscape:export-filename="/home/johan/birdfont/icons/flip_vertical.png"+       inkscape:export-xdpi="319.88824"+       inkscape:export-ydpi="319.88824" />+    <path+       style="fill:#858585;stroke:#858585;stroke-width:0.20966497;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"+       d="m 403.09063,597.30038 7.26979,0 0,-18.96467 z"+       id="path4441-4-2"+       inkscape:connector-curvature="0"+       inkscape:export-filename="/home/johan/birdfont/icons/flip_horizontal.png"+       inkscape:export-xdpi="319.88824"+       inkscape:export-ydpi="319.88824" />+    <path+       inkscape:connector-curvature="0"+       id="path4443-1-6"+       d="m 419.32189,596.86327 -6.93467,0 0,-18.09045 z"+       style="fill:#ffffff;fill-opacity:1;stroke:#858585;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"+       inkscape:export-filename="/home/johan/birdfont/icons/flip_horizontal.png"+       inkscape:export-xdpi="319.88824"+       inkscape:export-ydpi="319.88824" />+    <g+       id="g4487-4"+       transform="translate(320.85735,569.79799)"+       inkscape:export-filename="/home/johan/birdfont/icons/move_layer.png"+       inkscape:export-xdpi="319.88824"+       inkscape:export-ydpi="319.88824"+       style="fill:#858585;stroke:#858585">+      <path+         inkscape:connector-curvature="0"+         id="path4473-1"+         d="m 7.4681623,26.422633 21.7356957,0"+         style="fill:#858585;stroke:#858585;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />+      <path+         sodipodi:nodetypes="cc"+         inkscape:connector-curvature="0"+         id="path4477-6"+         d="m 17.224359,22.409889 11.645104,0"+         style="fill:#858585;stroke:#858585;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />+      <path+         sodipodi:nodetypes="cc"+         inkscape:connector-curvature="0"+         id="path4479-5"+         d="m 11.964066,11.524675 0.157635,8.263051"+         style="fill:#858585;stroke:#858585;stroke-width:1.20732284px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />+      <path+         sodipodi:nodetypes="cccc"+         inkscape:connector-curvature="0"+         id="path4485-7"+         d="m 9.9685112,20.19145 1.9278198,3.339083 1.905931,-3.30117 z"+         style="fill:#858585;stroke:#858585;stroke-width:1.20732284px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />+    </g>+    <g+       id="g5409"+       inkscape:export-filename="/home/johan/birdfont/icons/select_background.png"+       inkscape:export-xdpi="319"+       inkscape:export-ydpi="319">+      <rect+         inkscape:export-ydpi="319.88824"+         inkscape:export-xdpi="319.88824"+         inkscape:export-filename="/home/johan/birdfont/icons/rectangle.png"+         y="546.9646"+         x="434.1958"+         height="11.286502"+         width="16.043371"+         id="rect4999-4-5"+         style="fill:none;stroke:#656a73;stroke-width:0.95943475;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />+      <path+         transform="translate(-0.12464139,-1.620338)"+         d="m 453.04888,560.29639 a 2.045305,2.045305 0 1 1 -4.09061,0 2.045305,2.045305 0 1 1 4.09061,0 z"+         sodipodi:ry="2.045305"+         sodipodi:rx="2.045305"+         sodipodi:cy="560.29639"+         sodipodi:cx="451.00357"+         id="path5389"+         style="opacity:0.98000003999999996;color:#000000;fill:#656a73;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"+         sodipodi:type="arc" />+      <rect+         inkscape:export-ydpi="319.88824"+         inkscape:export-xdpi="319.88824"+         inkscape:export-filename="/home/johan/birdfont/icons/rectangle.png"+         y="544.76648"+         x="431.87128"+         height="15.457257"+         width="20.71269"+         id="rect4999-4-5-4"+         style="fill:none;stroke:none;stroke-width:1.27577007000000009;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />+    </g>   </g> </svg>diff --git a/libbirdfont/BackgroundImage.vala b/libbirdfont/BackgroundImage.valaindex 2c12641..9723fc4 100644--- a/libbirdfont/BackgroundImage.vala+++ b/libbirdfont/BackgroundImage.vala@@ -1346,10 +1346,16 @@ public class BackgroundImage { 		return false; 	} 	-	public void center_in_glyph () {-		Glyph g = MainWindow.get_current_glyph ();+	public void center_in_glyph (Glyph? glyph = null) {+		Glyph g; 		Font f = BirdFont.get_current_font (); 		+		if (glyph != null) {+			g = (!) glyph;+		} else {+			g = MainWindow.get_current_glyph ();+		}+		 		img_middle_x = g.left_limit + (g.right_limit - g.left_limit) / 2; 		img_middle_y = f.bottom_position + (f.top_position - f.bottom_position) / 2; 	}diff --git a/libbirdfont/BackgroundSelectionTool.vala b/libbirdfont/BackgroundSelectionTool.valaindex 75dbf56..a937020 100644--- a/libbirdfont/BackgroundSelectionTool.vala+++ b/libbirdfont/BackgroundSelectionTool.vala@@ -34,6 +34,9 @@ public class BackgroundSelectionTool : CutBackgroundTool { 		draw_action.connect ((self, cr, glyph) => { 			double x, y, w, h; 			BackgroundImage bg;+			Text label = new Text ();+			GlyphCollection g;+			double tx, ty, font_height; 			 			if (glyph.get_background_image () == null) { 				warning ("No image");@@ -50,13 +53,34 @@ public class BackgroundSelectionTool : CutBackgroundTool { 				 				cr.save (); 				cr.set_line_width (2.0);-				cr.set_source_rgba (237 / 255.0, 67 / 255.0, 0, 1);+				+				if (bs.assigned_glyph != null) {+					cr.set_source_rgba (237 / 255.0, 67 / 255.0, 0, 1);+				} else {+					cr.set_source_rgba (132 / 255.0, 132 / 255.0, 132 / 255.0, 1);+				}+				 				cr.rectangle (x, y, w, h); 				cr.stroke ();-+				 				cr.arc (x + w, y + h, 9.0, 0, 2 * PI); 				cr.fill (); 				+				if (bs.assigned_glyph != null) {+					g = (!) bs.assigned_glyph;+					+					if (label.has_character (g.get_name ())) {+						font_height = 18;+						cr.set_source_rgba (1, 1, 1, 1);+						label.set_text (g.get_name ());+						tx = x  + w - label.get_width (font_height) / 2.0;+						ty = y + h;+						ty += label.get_height (font_height) / 2.0;+						ty -= label.get_decender (font_height);+						label.draw (cr, tx, ty, font_height);+					}+				}+				 				cr.restore (); 			} 		});diff --git a/libbirdfont/BackgroundTools.vala b/libbirdfont/BackgroundTools.valaindex 507eb3c..a305744 100644--- a/libbirdfont/BackgroundTools.vala+++ b/libbirdfont/BackgroundTools.vala@@ -68,15 +68,25 @@ public class BackgroundTools : ToolCollection  {  	public void add_part (BackgroundSelection selection) { 		BackgroundPartLabel label;-		label = new BackgroundPartLabel (selection, t_("No Glyph Selected"));+		label = new BackgroundPartLabel (selection, t_("Select Glyph")); 		label.select_action.connect ((t) => { 			BackgroundPartLabel bpl = (BackgroundPartLabel) t; 			GlyphSelection gs = new GlyphSelection ();-+			 			gs.selected_glyph.connect ((gc) => {+				GlyphCollection pgc;+				+				if (bpl.selection.assigned_glyph != null) {+					pgc = (!) bpl.selection.assigned_glyph;+					pgc.get_current ().set_background_image (null);+				}		+				 				bpl.selection.assigned_glyph = gc; 				bpl.label = gc.get_name ();+				gc.get_current ().set_background_image (bpl.selection.image);+				bpl.selection.image.center_in_glyph (gc.get_current ()); 				set_default_canvas ();+				ZoomTool.zoom_full_background_image (); 			}); 			 			if (!bpl.deleted) {diff --git a/libbirdfont/Expander.vala b/libbirdfont/Expander.valaindex 4e425a0..3281bb2 100644--- a/libbirdfont/Expander.vala+++ b/libbirdfont/Expander.vala@@ -221,7 +221,7 @@ public class Expander : GLib.Object { 				title = new Text (); 				title.set_text ((!) headline); 				cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1);-				title.draw (cr, x, yt + HEADLINE_MARGIN - 7, 14);+				title.draw (cr, x, yt + HEADLINE_MARGIN + 7, 14); 			} else if (draw_separator) {		 				cr.save (); 				cr.set_line_width (0.5);diff --git a/libbirdfont/Font.vala b/libbirdfont/Font.valaindex 21bfe72..9ed5073 100644--- a/libbirdfont/Font.vala+++ b/libbirdfont/Font.vala@@ -511,9 +511,9 @@ public class Font : GLib.Object { 		return ((!)gc).get_current (); 	} 		-	public Glyph? get_glyph (string unicode) {+	public Glyph? get_glyph (string name) { 		GlyphCollection? gc = null;-		gc = glyph_cache.get (unicode);+		gc = glyph_name.get (name);  		if (gc == null || ((!)gc).length () == 0) { 			return null;diff --git a/libbirdfont/FontName.vala b/libbirdfont/FontName.valaindex f311925..7821e78 100644--- a/libbirdfont/FontName.vala+++ b/libbirdfont/FontName.vala@@ -50,7 +50,7 @@ public class FontName : Tool { 		} 		 		cr.set_source_rgba (234 / 255.0, 77 / 255.0, 26 / 255.0, 1);-		font_name.draw (cr, x, y - 10 / Toolbox.get_scale (), text_height);+		font_name.draw (cr, x, y + 13 * Toolbox.get_scale (), text_height); 		cr.restore (); 	} }diff --git a/libbirdfont/LabelTool.vala b/libbirdfont/LabelTool.valaindex 5a080cb..63f21a0 100644--- a/libbirdfont/LabelTool.vala+++ b/libbirdfont/LabelTool.vala@@ -47,7 +47,7 @@ public class LabelTool : Tool { 	} 	 	public override void draw (Context cr) {-		Text font_name, glyph_count;+		Text label_text, glyph_count; 		double text_height; 		double scale, bgx, bgy; 		double center_x, center_y;@@ -63,8 +63,8 @@ public class LabelTool : Tool { 		 		// tab label 		cr.save ();-		font_name = new Text ();-		font_name.set_text (label);+		label_text = new Text ();+		label_text.set_text (label); 		text_height = 18;  		if (is_selected ()) {@@ -73,7 +73,7 @@ public class LabelTool : Tool { 			cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1); 		} 		-		font_name.draw (cr, x + 14, y - 4.5, text_height);+		label_text.draw (cr, x + 14, y + h - 1.5, text_height); 		cr.restore ();  		// glyph count@@ -93,7 +93,7 @@ public class LabelTool : Tool { 			text_height = 12 / scale; 			 			center_x = bgx + ((!) counter_background).get_width () / 2.0  - glyph_count.get_extent (text_height) / 2.0;-			center_y = bgy + ((!) counter_background).get_height () / 2.0 - text_height / 2.0 - 3 / scale;;+			center_y = bgy + ((!) counter_background).get_height () / 2.0 + 4 / scale; 			 			if (is_selected ()) { 				cr.set_source_rgba (1, 1, 1, 1);diff --git a/libbirdfont/Renderer/Text.vala b/libbirdfont/Renderer/Text.valaindex 7ac3c36..4368418 100644--- a/libbirdfont/Renderer/Text.vala+++ b/libbirdfont/Renderer/Text.vala@@ -71,6 +71,11 @@ public class Text { 		}	 	} +	/** @param character a string with a single glyph or the name of the glyph if it is a ligature. */+	public bool has_character (string character) {+		return font.has_glyph (character);+	}+ 	public void iterate (Iterator iter) { 		Glyph glyph; 		double w, kern;@@ -119,7 +124,7 @@ public class Text { 		} 	} -	// FIXME: some fonts does not have on curve extrema+	// FIXME: some fonts doesn't have on curve extrema 	public double get_extent (double font_size_in_pixels) { 		double x = 0; 		double ratio = font_size_in_pixels / get_row_height ();@@ -141,7 +146,70 @@ public class Text { 		 		return x; 	}-	++	public double get_height (double font_size_in_pixels) {+		double ratio = font_size_in_pixels / get_row_height ();+		double max_y = 0;++		iterate ((glyph, kerning, last) => {+			double x1, y1, x2, y2;+			double y;+			glyph.boundaries (out x1, out y1, out x2, out y2);+			y = Math.fmax (y1, y2) - Math.fmin (y1, y2) ;+			if (y > max_y) {+				max_y = y;+			}+		});+		+		return max_y * ratio;+	}	++	public double get_width (double font_size_in_pixels) {+		double x = 0;+		double ratio = font_size_in_pixels / get_row_height ();+		bool first = true;+		+		iterate ((glyph, kerning, last) => {+			double x1, y1, x2, y2;+			double lsb;+			+			glyph.add_help_lines ();+			lsb = glyph.left_limit;+			+			if (first) {+				glyph.boundaries (out x1, out y1, out x2, out y2);+				x += (glyph.get_width () + kerning - Math.fmin (x1, x2)) * ratio;+				first = false;+			} else if (!last) {+				x += (glyph.get_width () + kerning) * ratio;+			} else {+				glyph.boundaries (out x1, out y1, out x2, out y2);+				x += (x2 - lsb) * ratio;+			}+		});+		+		return x;+	}++	public double get_decender (double font_size_in_pixels) {+		double ratio = font_size_in_pixels / get_row_height ();+		double min_y = 0;+		double decender;+		+		iterate ((glyph, kerning, last) => {+			double x1, y1, x2, y2;+			double y;+			glyph.boundaries (out x1, out y1, out x2, out y2);+			y = Math.fmin (y1, y2);+			if (y < min_y) {+				min_y = y;+			}+		});+		+		decender = font.base_line - (min_y * ratio);+		return decender > 0 ? decender : 0; +	}		+ 	public bool load_font (string file) { 		Font? f = font_cache.get_font (file); 		@@ -151,7 +219,7 @@ public class Text { 		 		return f != null; 	}-	+		 	public void draw (Context cr, double px, double py, double font_size_in_pixels) { 		double x, y; 		double row_height, ratio;@@ -161,7 +229,7 @@ public class Text { 		 		cr.save (); -		y = ratio * (get_row_height () + font.base_line) + py;+		y = py; 		x = px; 					 		iterate ((glyph, kerning, last) => {@@ -192,7 +260,8 @@ public class Text { 	void draw_path (Context cr, Path path, double lsb, double x, double y, double scale) { 		EditPoint e, prev; 		double xa, ya, xb, yb, xc, yc, xd, yd;-			+		double by;+		 		if (path.points.size > 0) {  			prev = path.points.get (0);@@ -200,18 +269,19 @@ public class Text { 			ya = y - prev.y * scale; 			cr.move_to (xa, ya); 			+			by = (y - font.base_line * scale); 			for (int i = 1; i < path.points.size; i++) { 				e = path.points.get (i).copy (); 				PenTool.convert_point_segment_type (prev, e, PointType.CUBIC); 				 				xb = (prev.get_right_handle ().x - lsb) * scale + x;-				yb = y - prev.get_right_handle ().y * scale;+				yb = by - prev.get_right_handle ().y * scale;  				xc = (e.get_left_handle ().x - lsb) * scale + x;-				yc = y - e.get_left_handle ().y * scale;+				yc = by - e.get_left_handle ().y * scale; 					 				xd = (e.x - lsb) * scale + x;-				yd = y - e.y * scale;+				yd = by - e.y * scale; 				 				cr.curve_to (xb, yb, xc, yc, xd, yd); 				cr.line_to (xd, yd);@@ -223,13 +293,13 @@ public class Text { 			e = path.points.get (0); 			 			xb = (prev.get_right_handle ().x - lsb) * scale + x;-			yb = y - prev.get_right_handle ().y * scale;+			yb = by - prev.get_right_handle ().y * scale;  			xc = (e.get_left_handle ().x - lsb) * scale + x;-			yc = y - e.get_left_handle ().y * scale;+			yc = by - e.get_left_handle ().y * scale; 				 			xd = (e.x - lsb) * scale + x;-			yd = y - e.y * scale;+			yd = by - e.y * scale; 			 			cr.curve_to (xb, yb, xc, yc, xd, yd); 		}diff --git a/libbirdfont/TabBar.vala b/libbirdfont/TabBar.valaindex 31f6013..a527fba 100644--- a/libbirdfont/TabBar.vala+++ b/libbirdfont/TabBar.vala@@ -729,7 +729,7 @@ public class TabBar : GLib.Object { 			text_height = 16 / scale; 			text_width = label.get_extent (text_height); 			center_x = tab_width / 2.0 - text_width / 2.0;-			center_y = tab_height / 2.0 - 12 / scale;+			center_y = tab_height / 2.0 + 4 / scale; 			 			if (tab_index == selected) { 				cr.set_source_rgba (40 / 255.0, 57 / 255.0, 65 / 255.0, 1);

Contact

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