Clone in a terminal:
Commit 7f4f598
Johan Mattsson - 2015-12-22T18:14:09+00:00
7f4f598e53d3ee55b70e005c71d1cb966a5289ddjohan.mattsson.m@gmail.com

Show thumbnails in overview tab for color fonts

Changed files (3)

Diff

diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 9f42c13..5f1d2e3 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1864,9 +1864,8 @@ public class Glyph : FontDisplay { 		if (svg_drawing != null) { 			cmp.save (); 			cmp.scale (view_zoom, view_zoom);-			cmp.translate (xc () + svg_x - view_offset_x, yc () - svg_y - view_offset_y);-			Rsvg.Handle svg_handle = (!) svg_drawing;-			svg_handle.render_cairo (cmp);+			cmp.translate (-view_offset_x, -view_offset_y);+			draw_svg (cmp); 			cmp.restore (); 		} else { 			cmp.save ();@@ -1882,6 +1881,16 @@ public class Glyph : FontDisplay { 		cmp.restore (); 	} +	public void draw_svg (Context cr) {+		if (svg_drawing != null) {+			cr.save ();+			cr.translate (xc () + svg_x, yc () - svg_y);+			Rsvg.Handle svg_handle = (!) svg_drawing;+			svg_handle.render_cairo (cr);+			cr.restore ();+		}+	}+	 	private void zoom_in_at_point (double x, double y, double amount = 15) { 		int n = (int) (-amount); 		zoom_at_point (x, y, n);diff --git a/libbirdfont/OpenFontFormat/SvgTable.vala b/libbirdfont/OpenFontFormat/SvgTable.valaindex 79683a9..2a0d4e5 100644--- a/libbirdfont/OpenFontFormat/SvgTable.vala+++ b/libbirdfont/OpenFontFormat/SvgTable.vala@@ -25,7 +25,7 @@ public class SvgTable : OtfTable { 		id = "SVG "; 		entries = new Gee.ArrayList<SvgTableEntry> (); 	}-		+	 	public bool has_glyphs () { 		return glyphs_in_table > 0; 	}@@ -117,10 +117,9 @@ public class SvgTable : OtfTable { 		// number of units per em in this font and move the glyph 		// in to the em box 		Glyph glyph = glyphs.get_current ();-		//FIXME: DELETE double height = font.top_position - font.base_line; 		double scale = HeadTable.UNITS; 		double x = glyph.svg_x - glyph.left_limit;-		double y = -glyph.svg_y;+		double y = font.base_line - glyph.svg_y; 		svg.append (@"transform=\"scale($scale) translate($x, $y)\""); 		 		svg.append (">");diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex b9408e4..b48b8b0 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -108,10 +108,10 @@ public class OverViewItem : GLib.Object { 			cache = g.overview_thumbnail; 			return; 		}-		+ 		w = width; 		h = height;-		+ 		scale_box = width / DEFAULT_WIDTH;  		s = Screen.create_background_surface ((int) width, (int) height - 20);@@ -119,21 +119,33 @@ public class OverViewItem : GLib.Object { 		 		c.save (); 		g.boundaries (out x1, out y1, out x2, out y2);-	-		glyph_width = x2 - x1;-		glyph_height = y2 - y1;-		++		if (g.color_svg_data != null) {+			font = BirdFont.get_current_font ();+			glyph_width = g.right_limit - g.left_limit;+			glyph_height = font.top_position - font.bottom_position;+		} else {+			glyph_width = x2 - x1;+			glyph_height = y2 - y1;+		}+ 		c.save (); 		c.scale (glyph_scale * Screen.get_scale (), glyph_scale * Screen.get_scale ());  		g.add_help_lines ();+				+		if (g.color_svg_data != null) {+			gx = 10;+			gy = (h / glyph_scale) - 25 / glyph_scale;+			c.translate (gx - Glyph.xc () - g.get_lsb (), g.get_baseline () + gy - Glyph.yc ());+			g.draw_svg (c);+		} else {+			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 ());+			g.draw_paths (c, color);+		} 		-		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 ());-		-		g.draw_paths (c, color); 		c.restore (); 		 		cache = s;

Contact

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