Clone in a terminal:
Commit 082afba
Johan Mattsson - 2013-02-15T21:25:47+00:00
082afba3a2504892d92e2484595e06e27c44715bjohan.mattsson.m@gmail.com

units per em

Changed files (3)

Diff

diff --git a/libbirdfont/ImportSvg.vala b/libbirdfont/ImportSvg.valaindex 02bf355..7e4ff8e 100644--- a/libbirdfont/ImportSvg.vala+++ b/libbirdfont/ImportSvg.vala@@ -665,14 +665,14 @@ public class ImportSvg { 		}  		Path path = new Path ();-		++		// resize all points+		for (int i = 0; i < pi; i++) {+			p[i] *= units;+		}+					 		// move and resize 		if (svg_glyph) {-			// resize all points-			for (int i = 0; i < pi; i++) {-				p[i] *= units;-			}-			 			// move only y  			for (int i = 0; i < pi; i += 2) { 				p[i] += glyph.left_limit;diff --git a/libbirdfont/SvgFont.vala b/libbirdfont/SvgFont.valaindex 14b05cf..85c115a 100644--- a/libbirdfont/SvgFont.vala+++ b/libbirdfont/SvgFont.vala@@ -21,7 +21,7 @@ namespace BirdFont {  class SvgFont : GLib.Object { 	Font font;-	double units = 1;+	double units = 1; // 1000 is default in svg spec. 	double font_advance = 0; 	 	public SvgFont (Font f) {@@ -184,7 +184,12 @@ class SvgFont : GLib.Object { 			if (attr_name == "units-per-em") { 				units = 100.0 / double.parse (attr_content); 			}	-						+		}++		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {+			attr_name = prop->name;+			attr_content = prop->children->content;+					 			if (attr_name == "ascent") { 				top_limit = -double.parse (attr_content); 			}diff --git a/libbirdfont/load_svg_font.c b/libbirdfont/load_svg_font.cindex 8326f97..eceb79d 100644--- a/libbirdfont/load_svg_font.c+++ b/libbirdfont/load_svg_font.c@@ -78,7 +78,7 @@ void create_contour (FT_Vector* points, char* flags, int* length, FT_Vector** ne 	prev_is_curve = is_quadratic (points, len - 1, len); 	 	if (is_quadratic (flags, 0, len)) {-		printf ("WARNING: path begins at off curve point.");+		printf ("WARNING: path begins at off curve point.\n"); 	}   	// FIXME: What if first and last point is off curve?@@ -244,6 +244,7 @@ GString* get_svg_font (FT_Face face, int* err) { 	FT_Error error; 	FT_Long i; 	FT_ULong charcode;+	double units_per_em;  	*err = OK; 	@@ -253,7 +254,9 @@ GString* get_svg_font (FT_Face face, int* err) { 	g_string_append (svg, "<defs>\n"); 	g_string_append_printf (svg, "<font id=\"%s\" horiz-adv-x=\"250\">\n", face->family_name); -	g_string_printf (font_element, "<font-face units-per-em=\"%d\" ascent=\"%d\" descent=\"%d\" />\n", (int) face->units_per_EM, (int) face->ascender, (int) face->descender);	+	units_per_em = face->units_per_EM;+	units_per_em *= 10.0 / 3.0; 	// TODO: find out why size is different in svg fonts+	g_string_printf (font_element, "<font-face units-per-em=\"%f\" ascent=\"%d\" descent=\"%d\" />\n", units_per_em, (int) face->ascender, (int) face->descender);	 	g_string_append (svg, font_element->str); 	 	for (i = 0; i < face->num_glyphs; i++) {

Contact

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