Commit 217f1cf
Store line cap in bf fonts
Changed files (3)
modifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/SvgParser.valamodifiedlibbirdfont/SvgStyle.vala
Diff
@@ -389,7 +389,22 @@ class BirdFontFile : GLib.Object { foreach (Path p in g.path_list) { data = get_point_data (p); if (data != "") {- os.put_string (@"\t\t<path stroke=\"$(double_to_string (p.stroke))\" skew=\"$(double_to_string (p.skew))\" data=\"$(data)\" />\n");+ os.put_string (@"\t\t<path ");+ os.put_string (@"stroke=\"$(double_to_string (p.stroke))\" ");+ + if (p.line_cap != LineCap.BUTT) {+ if (p.line_cap == LineCap.ROUND) {+ os.put_string (@"cap=\"round\" ");+ } else if (p.line_cap == LineCap.SQUARE) {+ os.put_string (@"cap=\"square\" ");+ }+ }+ + if (p.skew != 0) {+ os.put_string (@"skew=\"$(double_to_string (p.skew))\" ");+ }+ + os.put_string (@"data=\"$(data)\" />\n"); } } write_glyph_background (g, os);@@ -1211,7 +1226,15 @@ class BirdFontFile : GLib.Object { if (attr.get_name () == "skew") { path.skew = double.parse (attr.get_content ());- } + }+ + if (attr.get_name () == "cap") {+ if (attr.get_content () == "round") {+ path.line_cap = LineCap.ROUND;+ } else if (attr.get_content () == "square") {+ path.line_cap = LineCap.SQUARE;+ }+ } } return path; @@ -456,12 +456,13 @@ public class SvgParser { } } - foreach (Path p1 in pl.paths.paths) {- p1.stroke = style.get_stroke_width ();- p1.reset_stroke ();- p1.update_region_boundaries ();+ foreach (Path p in path_list.paths) {+ p.stroke = style.get_stroke_width ();+ p.line_cap = style.get_line_cap ();+ p.reset_stroke ();+ p.update_region_boundaries (); }- + // assume the even odd rule is applied and convert the path // to a path using the non-zero rule int inside_count;@@ -25,6 +25,24 @@ public class SvgStyle { style = new Gee.HashMap<string, string> (); } + public LineCap get_line_cap () {+ string l;+ + if (!style.has_key ("stroke-linecap")) {+ return LineCap.BUTT;+ }+ + l = style.get ("stroke-linecap");+ + if (l == "round") {+ return LineCap.ROUND;+ } else if (l == "square") {+ return LineCap.SQUARE;+ }+ + return LineCap.BUTT; + }+ public double get_stroke_width () { if (!style.has_key ("stroke-width")) { return 0;