Clone in a terminal:
Commit 217f1cf
Johan Mattsson - 2015-05-12T07:39:34+00:00
217f1cf95036d0d6bdfe95ee3c5e75c148556de7johan.mattsson.m@gmail.com

Store line cap in bf fonts

Changed files (3)

Diff

diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 2d7001c..bfe5260 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -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;	diff --git a/libbirdfont/SvgParser.vala b/libbirdfont/SvgParser.valaindex 4fb6eb7..352debc 100644--- a/libbirdfont/SvgParser.vala+++ b/libbirdfont/SvgParser.vala@@ -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;diff --git a/libbirdfont/SvgStyle.vala b/libbirdfont/SvgStyle.valaindex 9c1d601..a1aac05 100644--- a/libbirdfont/SvgStyle.vala+++ b/libbirdfont/SvgStyle.vala@@ -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;

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112