Commit 7f4f598
Show thumbnails in overview tab for color fonts
Changed files (3)
modifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/OpenFontFormat/SvgTable.valamodifiedlibbirdfont/OverViewItem.vala
Diff
@@ -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);@@ -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 (">");@@ -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;