Commit 082afba
units per em
Changed files (3)
modifiedlibbirdfont/ImportSvg.valamodifiedlibbirdfont/SvgFont.valamodifiedlibbirdfont/load_svg_font.c
Diff
@@ -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;@@ -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); }@@ -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++) {