The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Sort coverage table for ligatures

These changes was commited to the Birdfont repository Tue, 18 Aug 2015 22:46:39 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Tue, 18 Aug 2015 22:46:39 +0000]

Updated Files

libbirdfont/OpenFontFormat/LigatureCollection.vala
libbirdfont/OpenFontFormat/LigatureSet.vala
--- a/libbirdfont/OpenFontFormat/LigatureCollection.vala +++ b/libbirdfont/OpenFontFormat/LigatureCollection.vala @@ -100,7 +100,14 @@ lig_set = new LigatureSet (glyf_table); lig_set.add (new Ligature (l, characters)); ligature_sets.add (lig_set); - } + } + + // make sure coverage table is sorted otherwise will substitution not work + ligature_sets.sort ((a, b) => { + LigatureSet la = (LigatureSet) a; + LigatureSet lb = (LigatureSet) b; + return Posix.strcmp (la.get_coverage_char (), lb.get_coverage_char ()); + }); } public FontData get_font_data (GlyfTable glyf_table) throws GLib.Error { @@ -115,7 +122,7 @@ table_start = (uint16) fd.length_with_padding (); fd.add_ushort (1); // format identifier - fd.add_ushort (6 + (uint16) 2 * ligature_sets.size); // offset to coverage + fd.add_ushort (6 + (uint16) (2 * ligature_sets.size)); // offset to coverage fd.add_ushort ((uint16) ligature_sets.size); // number of ligature set tables // array of offsets to ligature sets
--- a/libbirdfont/OpenFontFormat/LigatureSet.vala +++ b/libbirdfont/OpenFontFormat/LigatureSet.vala @@ -101,7 +101,7 @@ fd.add_ushort ((uint16) gid); // number of components including the coverage glyph - fd.add_ushort ((uint16) parts.length); + fd.add_ushort ((uint16) parts.length); foreach (string p in parts) { if (p.has_prefix ("U+") || p.has_prefix ("u+")) {