The Birdfont Source Code


All Repositories / birdfont.git / commit – 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
author Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 18 Aug 2015 22:46:39 +0000 (00:46 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 18 Aug 2015 22:46:39 +0000 (00:46 +0200)
commit 673024ba0c219fcaad6f968915344367a77407ea
tree 6bb448e0e24010e94172c5d4f5d9d33b882d43ba
parent a4addcb14ab64e9a455a46ba5d1b39aaa11f5f90
Sort coverage table for ligatures

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+")) {