Clone in a terminal:
Commit 48f8a76
Johan Mattsson - 2017-08-25T15:10:25+00:00
48f8a76f34b8c3628869844ed3cd1d9f65a9a1c0johan.mattsson.m@gmail.com

Use fixed size glyphs in overview

Changed files (3)

Diff

diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 4caae7a..319b895 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -531,6 +531,8 @@ public class Glyph : FontDisplay { 		base_line.position_updated.connect ((pos) => { 				Font f = BirdFont.get_current_font (); 				f.base_line = pos;+				OverView o = MainWindow.get_overview ();+				o.reset_cache (); 			});  		double bp = BirdFont.get_current_font ().bottom_position;diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex 02861ff..189ecfe 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -141,6 +141,12 @@ public class OverView : FontDisplay { 		} 	} +	public void reset_cache () {+		foreach (OverViewItem i in visible_items) {+			i.clear_cache ();+		}+	}+ 	public Glyph? get_selected_glyph () { 		if (selected_items.size == 0) { 			return null;@@ -641,9 +647,7 @@ public class OverView : FontDisplay { 				selected_index = selected_items.index_of ((!) glyphs); 				selected_item = (selected_index != -1); 			}-			-			item.adjust_scale ();-			+						 			selected_item |= (i == selected); 			item.selected = selected_item; 			diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex cbd3b18..dbfda83 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -118,8 +118,8 @@ public class OverViewItem : GLib.Object { 		 		w = width; 		h = height;-		-		scale_box = width / DEFAULT_WIDTH;++		scale_box = (height / DEFAULT_HEIGHT) * 0.75;  		s = Screen.create_background_surface ((int) width, (int) height - 20); 		c = new Context (s);@@ -131,15 +131,15 @@ public class OverViewItem : GLib.Object { 		glyph_height = y2 - y1; 		 		c.save ();-		c.scale (glyph_scale * Screen.get_scale (), glyph_scale * Screen.get_scale ());+		c.scale (scale_box * Screen.get_scale (), scale_box * Screen.get_scale ());  		g.add_help_lines (); 		-		gx = ((w / glyph_scale) - glyph_width) / 2 - g.get_left_side_bearing ();-		gy = (h / glyph_scale) - 25 / glyph_scale;-		-		c.translate (gx - Glyph.xc () - g.get_lsb (), g.get_baseline () + gy - Glyph.yc ());-		+		gx = ((w / scale_box) - glyph_width) / 2 - g.get_left_side_bearing ();+		gy = h / scale_box + g.get_baseline () - 20 / scale_box - 20;++		c.translate (gx - Glyph.xc () - g.get_lsb (), gy - Glyph.yc ());+ 		g.draw_paths (c, color); 		c.restore (); 		@@ -165,8 +165,6 @@ public class OverViewItem : GLib.Object { 		h = height; 		 		scale_box = width / DEFAULT_WIDTH;-		adjust_scale ();- 		s = Screen.create_background_surface ((int) width, (int) height - 20); 		c = new Context (s); 		@@ -297,33 +295,6 @@ public class OverViewItem : GLib.Object { 		draw_menu (cr); 	} -	public void adjust_scale () {-		double x1, x2, y1, y2, glyph_width, glyph_height, scale, gx;-		Glyph g;-		Font font;-		-		if (glyphs != null) {-			font = BirdFont.get_current_font ();-			g = ((!) glyphs).get_current ();-			g.boundaries (out x1, out y1, out x2, out y2);-		-			glyph_width = x2 - x1;-			glyph_height = y2 - y1;--			if (glyph_scale == 1) {-				// caption height is 20-				glyph_scale = (height - 20) / (font.top_limit - font.bottom_limit);	-			}-			-			scale = glyph_scale;			-			gx = ((width / scale) - glyph_width) / 2;-		-			if (gx < 0) {-				glyph_scale = 1 + 2 * gx / width;-			}-		}-	}- 	private void draw_thumbnail (Context cr, double x, double y) {		 		if (cache != null) { 			cr.save ();

Contact

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