The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Set minimum stroke with to 0.02

These changes was commited to the Birdfont repository Sat, 07 Nov 2015 12:42:33 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sat, 07 Nov 2015 12:42:33 +0000]

Updated Files

libbirdfont/BirdFontFile.vala
libbirdfont/DrawingTools.vala
libbirdfont/Glyph.vala
libbirdfont/Path.vala
libbirdfont/PenTool.vala
libbirdfont/StrokeTool.vala
libbirdfont/Svg.vala
libbirdfont/TestCases.vala
--- a/libbirdfont/BirdFontFile.vala +++ b/libbirdfont/BirdFontFile.vala @@ -1400,7 +1400,7 @@ foreach (Attribute attr in tag.get_attributes ()) { if (attr.get_name () == "stroke") { - path.set_stroke (double.parse (attr.get_content ())); + path.stroke = double.parse (attr.get_content ()); } if (attr.get_name () == "skew") {
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -806,6 +806,7 @@ // add stroke to path add_stroke = new Tool ("apply_stroke", t_("Apply stroke")); + add_stroke.select_action.connect ((self) => { Font f; Glyph g = MainWindow.get_current_glyph (); @@ -856,7 +857,7 @@ || bezier_tool.is_selected (); StrokeTool.stroke_width = object_stroke.get_value (); - + if (tool && StrokeTool.add_stroke) { foreach (Path p in g.active_paths) { p.stroke = StrokeTool.stroke_width;
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -214,7 +214,7 @@ foreach (Path p in get_visible_paths ()) { if (p.stroke > 0) { - stroke = p.get_stroke (); + stroke = p.get_completed_stroke (); foreach (Path stroke_part in stroke.paths) { pc = new PointConverter (stroke_part); pl.add (pc.get_quadratic_path ());
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -51,7 +51,22 @@ public double ymin = Glyph.CANVAS_MAX; /** Stroke width */ - public double stroke = 0; + public double stroke { + get { + return path_stroke_width; + } + + set { + if (0 < value < 0.1) { + path_stroke_width = 0.2; + } else { + path_stroke_width = value; + } + } + } + + private double path_stroke_width = 0; + public LineCap line_cap = LineCap.BUTT; public PathList? full_stroke = null; PathList? fast_stroke = null; @@ -156,10 +171,6 @@ public bool empty () { return points.size == 0; - } - - public void set_stroke (double width) { - stroke = width; } public void draw_boundaries (Context cr) { @@ -2456,7 +2467,7 @@ } } - public PathList get_stroke () { + public PathList get_completed_stroke () { if (full_stroke == null) { StrokeTool s = new StrokeTool (); full_stroke = s.get_stroke (this, stroke);
--- a/libbirdfont/PenTool.vala +++ b/libbirdfont/PenTool.vala @@ -1846,7 +1846,7 @@ np.add (xt, yt); if (DrawingTools.pen_tool.is_selected ()) { - np.set_stroke (PenTool.path_stroke_width); + np.stroke = PenTool.path_stroke_width; } PenTool.active_path = np;
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -53,7 +53,7 @@ foreach (Path p in g.active_paths) { if (p.stroke > 0) { - paths.append (p.get_stroke ()); + paths.append (p.get_completed_stroke ()); } } @@ -138,7 +138,7 @@ if (p.stroke == 0) { o.add (p); } else { - o.append (p.get_stroke ()); + o.append (p.get_completed_stroke ()); } }
--- a/libbirdfont/Svg.vala +++ b/libbirdfont/Svg.vala @@ -27,7 +27,7 @@ if (p.stroke == 0) { write_path_as_glyph (p, svg, g); } else { - stroke_list = p.get_stroke (); + stroke_list = p.get_completed_stroke (); write_paths_as_glyph (stroke_list, svg, g); } }
--- a/libbirdfont/TestCases.vala +++ b/libbirdfont/TestCases.vala @@ -173,7 +173,7 @@ glyph = MainWindow.get_current_glyph (); for (int i = 0; i < 5; i++) { foreach (Path p in glyph.get_all_paths ()) { - p.set_stroke (i / 100.0); + p.stroke = (i / 100.0); glyph.update_view (); Tool.yield (); }