The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Stroke in SVG export

These changes was commited to the Birdfont repository Tue, 12 May 2015 12:21:59 +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, 12 May 2015 12:21:59 +0000 (14:21 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 12 May 2015 12:21:59 +0000 (14:21 +0200)
commit 5983cebd826f35465861e356dc202afae3498769
tree e4a86cb44a3b28148362ba71be784ff08f13f5ef
parent e5b2e118fbc5c31ca6cab5fdb864507157e864f8
Stroke in SVG export

libbirdfont/ExportTool.vala
libbirdfont/Svg.vala
--- a/libbirdfont/ExportTool.vala +++ b/libbirdfont/ExportTool.vala @@ -91,24 +91,57 @@ string glyph_svg; StringBuilder s; string name; + int id = 0; + name = glyph.get_name (); - + + Gee.ArrayList<Path> pl; + s = new StringBuilder (); glyph_svg = ""; + + pl = only_selected_paths ? glyph.active_paths : glyph.path_list; + foreach (Path p in pl) { + if (p.stroke > 0) { + s.append (@"<path "); + s.append (@"style=\""); + s.append (@"fill:none;"); + s.append (@"stroke:#000000;"); + s.append (@"stroke-width:$(p.stroke)px;"); + + if (p.line_cap == LineCap.ROUND) { + s.append (@"stroke-linecap:round;"); + } else if (p.line_cap == LineCap.SQUARE) { + s.append (@"stroke-linecap:square;"); + } + + s.append (@"\" "); + + s.append (@"d=\"$(Svg.to_svg_path (p, glyph))\" id=\"path_$(name)_$(id)\" />\n"); + id++; + } + } if (only_selected_paths) { foreach (Path p in glyph.active_paths) { - glyph_svg += Svg.to_svg_path (p, glyph); + if (p.stroke == 0) { + glyph_svg += Svg.to_svg_path (p, glyph); + } } } else { foreach (Path p in glyph.path_list) { - glyph_svg += Svg.to_svg_path (p, glyph); + if (p.stroke == 0) { + glyph_svg += Svg.to_svg_path (p, glyph); + } } } - s.append (@"<path "); - s.append (@"style=\"fill:#000000;stroke-width:0px\" "); - s.append (@"d=\"$(glyph_svg)\" id=\"path_$(name)\" />\n"); + if (glyph_svg != "") { + s.append (@"<path "); + s.append (@"style=\"fill:#000000;stroke-width:0px\" "); + s.append (@"d=\"$(glyph_svg)\" id=\"path_$(name)_$(id)\" />\n"); + id++; + } return s.str; }
--- a/libbirdfont/Svg.vala +++ b/libbirdfont/Svg.vala @@ -83,7 +83,9 @@ m = p.points.get (0); add_abs_next ((!) n, m, svg, g, do_glyph); - close_path (svg); + if (!p.is_open ()) { + close_path (svg); + } } private static void add_abs_next (EditPoint start, EditPoint end, StringBuilder svg, Glyph g, bool do_glyph) {