Commit 5af849d
Faster overview and kerning code
Changed files (5)
modifiedlibbirdfont/EditPointHandle.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/KerningDisplay.valamodifiedlibbirdfont/OverViewItem.valamodifiedlibbirdfont/Path.vala
Diff
@@ -159,7 +159,6 @@ public class EditPointHandle { if (unlikely(c == 0)) { angle = 0; // FIXME: this should be a different point type without line handles length = 0;- warning ("Too short handle."); return; } @@ -1335,6 +1335,24 @@ public class Glyph : FontDisplay { cr.stroke (); } + /** Draw filled paths. */+ public void draw_paths (Context cr) {+ PathList stroke;+ + cr.save ();+ cr.new_path ();+ foreach (unowned Path p in path_list) {+ if (p.stroke > 0) {+ stroke = StrokeTool.get_stroke (p, p.stroke);+ draw_path_list (stroke, cr, Color.black ());+ } else {+ p.draw_path (cr, Color.black ());+ }+ }+ cr.fill ();+ cr.restore ();+ }+ public void draw_path (Context cr) { if (is_open () && Path.fill_open_path) { cr.save ();@@ -1850,6 +1868,17 @@ public class Glyph : FontDisplay { } } + /** @return left side bearing */+ public double get_lsb () {+ return get_line ("left").pos;+ }++ /** @return bottom line */+ public double get_baseline () {+ Font font = BirdFont.get_current_font ();+ return font.base_line;+ }+ void draw_background_glyph (WidgetAllocation allocation, Context cr) { double left, baseline, current_left; Glyph g;@@ -1,5 +1,5 @@ /*- Copyright (C) 2012 Johan Mattsson+ Copyright (C) 2012, 2014 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -156,7 +156,11 @@ public class KerningDisplay : FontDisplay { // TODO: set font size // cr.scale (KerningTools.font_size, KerningTools.font_size);- Svg.draw_svg_path (cr, glyph.get_svg_data (), x + kern, y);+ cr.save ();+ glyph.add_help_lines ();+ cr.translate (kern + x - glyph.get_lsb () - Glyph.xc (), glyph.get_baseline () + y - Glyph.yc ());+ glyph.draw_paths (cr);+ cr.restore (); w = glyph.get_width (); }@@ -1,5 +1,5 @@ /*- Copyright (C) 2012 Johan Mattsson+ Copyright (C) 2012, 2014 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -140,8 +140,13 @@ public class OverViewItem : GLib.Object { Surface s = new Surface.similar (cr.get_target (), Content.COLOR_ALPHA, (int) w, (int) h - 20); Context c = new Context (s); - c.scale (scale, scale); - Svg.draw_svg_path (c, g.get_svg_data (), gx, gy);+ c.save ();+ c.scale (scale, scale); + + g.add_help_lines ();+ c.translate (gx - g.get_lsb () - Glyph.xc (), g.get_baseline () + gy - Glyph.yc ());+ g.draw_paths (c);+ c.restore (); cr.save (); cr.set_source_surface (s, x, y - h);@@ -318,7 +318,7 @@ public class Path { cr.set_source_rgba (line_color_r, line_color_g, line_color_b, line_color_a); cr.set_line_width (stroke_width / g.view_zoom); - cr.line_to (xa, ya); // this point makes sense only if it is the first or last position, the other points are meaningless don't export them+ cr.line_to (xa, ya); // this point makes sense only if it is in the first or last position if (t == PointType.QUADRATIC || t == PointType.LINE_QUADRATIC || t == PointType.DOUBLE_CURVE || u == PointType.QUADRATIC || u == PointType.LINE_QUADRATIC || u == PointType.DOUBLE_CURVE) { cr.curve_to ((xa + 2 * xb) / 3, (ya + 2 * yb) / 3, (xd + 2 * xb) / 3, (yd + 2 * yb) / 3, xd, yd);