The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Show thumbnails in overview tab for color fonts

These changes was commited to the Birdfont repository Tue, 22 Dec 2015 15:54:46 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 22 Dec 2015 15:54:46 +0000 (16:54 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 22 Dec 2015 18:14:09 +0000 (19:14 +0100)
commit 7f4f598e53d3ee55b70e005c71d1cb966a5289dd
tree 41bf6f45c19c94dc1ece47e8db82f308e70b90a6
parent 8b6bbcc204b53544cca04d14a45181c9f0c57e6c
Show thumbnails in overview tab for color fonts

libbirdfont/Glyph.vala
libbirdfont/OpenFontFormat/SvgTable.vala
libbirdfont/OverViewItem.vala
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -1864,9 +1864,8 @@ 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 @@ 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);
--- a/libbirdfont/OpenFontFormat/SvgTable.vala +++ b/libbirdfont/OpenFontFormat/SvgTable.vala @@ -25,7 +25,7 @@ id = "SVG "; entries = new Gee.ArrayList<SvgTableEntry> (); } - + public bool has_glyphs () { return glyphs_in_table > 0; } @@ -117,10 +117,9 @@ // 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 (">");
--- a/libbirdfont/OverViewItem.vala +++ b/libbirdfont/OverViewItem.vala @@ -108,10 +108,10 @@ 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 @@ 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;