The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix critical spacing bug

These changes was commited to the Birdfont repository Thu, 09 Oct 2014 12:55:20 +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>
Thu, 09 Oct 2014 12:55:20 +0000 (14:55 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 09 Oct 2014 12:55:20 +0000 (14:55 +0200)
commit 01fa8a83f881ad42fabdf36c78521c63892aef42
tree 43f26cc04172bbf700c39fa0897344a005e87350
parent e405ba588931eb7a1b5c7393261512af7abda584
Fix critical spacing bug

libbirdfont/OpenFontFormat/GlyfTable.vala
libbirdfont/OpenFontFormat/GposTable.vala
libbirdfont/OpenFontFormat/HmtxTable.vala
libbirdfont/OpenFontFormat/KernList.vala
--- a/libbirdfont/OpenFontFormat/GlyfTable.vala +++ b/libbirdfont/OpenFontFormat/GlyfTable.vala @@ -43,6 +43,7 @@ // sorted array of glyphs public Gee.ArrayList<GlyphCollection> glyphs; + public Gee.ArrayList<GlyfData> glyf_data; public uint number_of_unassigned_glyphs = 0; uint16 max_points = 0; @@ -53,6 +54,7 @@ loca_table = l; location_offsets = new Gee.ArrayList<uint32> (); glyphs = new Gee.ArrayList<GlyphCollection> (); + glyf_data = new Gee.ArrayList<GlyfData> (); } public int get_gid (string name) { @@ -209,6 +211,8 @@ g.remove_empty_paths (); glyf_data = g.get_ttf_data (); + + this.glyf_data.add (glyf_data); if (g.path_list.size == 0 || glyf_data.paths.size == 0 || glyf_data.get_ncontours () == 0) { // location_offsets will be equal to location_offset + 1 for
--- a/libbirdfont/OpenFontFormat/GposTable.vala +++ b/libbirdfont/OpenFontFormat/GposTable.vala @@ -33,7 +33,6 @@ this.glyf_table = glyf_table; this.pairs = new KernList (glyf_table); - printd ("Process GPOS\n");
--- a/libbirdfont/OpenFontFormat/HmtxTable.vala +++ b/libbirdfont/OpenFontFormat/HmtxTable.vala @@ -102,13 +102,14 @@ int16 rsb; int16 lsb; - int16 left_marker; - int16 right_marker; + int16 left_guide; + int16 right_guide; double xmin; double ymin; double xmax; double ymax; + int i; Glyph g; @@ -120,20 +121,24 @@ // advance and lsb nmetrics = 0; + i = 0; foreach (GlyphCollection gc in glyf_table.glyphs) { g = gc.get_current (); - g.boundaries (out xmin, out ymin, out xmax, out ymax); + + return_if_fail (0 <= i < glyf_table.glyf_data.size); + + GlyfData gd = glyf_table.glyf_data.get (i); - xmax = Math.rint (xmax * HeadTable.UNITS); - xmin = Math.rint (xmin * HeadTable.UNITS); + xmax = gd.bounding_box_xmax; + xmin = gd.bounding_box_xmin; - left_marker = (int16) Math.rint (g.left_limit * HeadTable.UNITS); - right_marker = (int16) Math.rint (g.right_limit * HeadTable.UNITS); + left_guide = (int16) Math.rint (g.left_limit * HeadTable.UNITS); + right_guide = (int16) Math.rint (g.right_limit * HeadTable.UNITS); - lsb = (int16) xmin - left_marker; - advance = right_marker - left_marker; + lsb = (int16) xmin; + advance = right_guide - left_guide; - extent = (int16) (lsb + xmax - xmin); + extent = (int16) xmax; rsb = (int16) Math.rint (advance - extent); fd.add_u16 (advance); @@ -163,6 +168,7 @@ advance_width[nmetrics] = (uint16) extent; nmetrics++; + i++; } // monospaced lsb ...
--- a/libbirdfont/OpenFontFormat/KernList.vala +++ b/libbirdfont/OpenFontFormat/KernList.vala @@ -62,7 +62,7 @@ num_pairs += kerning_pair.kerning.size; foreach (Kerning k in kerning_pair.kerning) { gid_right = (uint16) glyf_table.get_gid (k.get_glyph ().get_name ()); - current_pairs.pairs.add (new Kern (gid_left, gid_right, (int16) (k.val * HeadTable.UNITS))); + current_pairs.pairs.add (new Kern (gid_left, gid_right, (int16) Math.rint (k.val * HeadTable.UNITS))); } });