The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Create lookups in arbitrary order

These changes was commited to the Birdfont repository Sat, 26 Sep 2015 20:33:04 +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>
Sat, 26 Sep 2015 20:33:04 +0000 (22:33 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 26 Sep 2015 20:33:04 +0000 (22:33 +0200)
commit f1863f60799a46b8336b8cb1e81b9be70e38d387
tree cb20d91e1f902c9e314f92c27122d3c119df6732
parent 251a6b8a045f932b6876616d0d49faad4d12900f
Create lookups in arbitrary order

libbirdfont/OpenFontFormat/CligFeature.vala
libbirdfont/OpenFontFormat/GsubTable.vala
libbirdfont/OpenFontFormat/Lookup.vala
libbirdfont/OpenFontFormat/Lookups.vala
--- a/libbirdfont/OpenFontFormat/CligFeature.vala +++ b/libbirdfont/OpenFontFormat/CligFeature.vala @@ -55,14 +55,14 @@ lookups.add_lookup(lookup); } - lookup = new Lookup (6, 0); + lookup = new Lookup (6, 0, Lookups.CHAINED_CONTEXT); foreach (FontData d in chain_data) { lookup.add_subtable (d); } lookups.add_lookup(lookup); } - lookup = new Lookup (4, 0); + lookup = new Lookup (4, 0, Lookups.LIGATURES); lookup.add_subtable (clig_subtable); lookups.add_lookup(lookup); }
--- a/libbirdfont/OpenFontFormat/GsubTable.vala +++ b/libbirdfont/OpenFontFormat/GsubTable.vala @@ -65,20 +65,25 @@ lookups.append (clig_feature.get_lookups ()); // FIXME: refactor clig_feature - uint16 feature_lookups = clig_feature.contextual.has_ligatures () ? 2 : 1; + uint16 feature_lookups = 1; + + if (clig_feature.contextual.has_ligatures ()) { + feature_lookups++; + } fd.add_ushort (0); // feature prameters (null) fd.add_ushort (feature_lookups); // number of lookups if (clig_feature.contextual.has_ligatures ()) { - fd.add_ushort ((uint16) lookups.tables.size - 2); // lookup chained_context (etc.) The chained context tables are listed here but the actual ligature table is only referenced in the context table - fd.add_ushort ((uint16) lookups.tables.size - 1); // lookup clig_subtable + // The chained context tables are listed here but the actual + // ligature table is only referenced in the context table + fd.add_ushort (lookups.find (Lookups.CHAINED_CONTEXT)); + fd.add_ushort (lookups.find (Lookups.LIGATURES)); } else { - fd.add_ushort (0); // lookup clig_subtable + fd.add_ushort (lookups.find (Lookups.LIGATURES)); // lookup clig_subtable } // lookup list - fd.append (lookups.genrate_lookup_list ()); // subtables
--- a/libbirdfont/OpenFontFormat/Lookup.vala +++ b/libbirdfont/OpenFontFormat/Lookup.vala @@ -19,11 +19,13 @@ public uint16 type; public uint16 flags; public Gee.ArrayList<FontData> subtables; + public int token; - public Lookup (uint16 type, uint16 flags) { + public Lookup (uint16 type, uint16 flags, int token = Lookups.NONE) { this.type = type; this.flags = flags; subtables = new Gee.ArrayList<FontData> (); + this.token = token; } public void add_subtable (FontData subtable) {
--- a/libbirdfont/OpenFontFormat/Lookups.vala +++ b/libbirdfont/OpenFontFormat/Lookups.vala @@ -20,6 +20,10 @@ public class Lookups : GLib.Object { public Gee.ArrayList<Lookup> tables = new Gee.ArrayList<Lookup> (); + + public static const int NONE = 0; + public static const int CHAINED_CONTEXT = 1; + public static const int LIGATURES = 1; public Lookups () { } @@ -30,6 +34,21 @@ */ public void add_lookup (Lookup lookup) { tables.add (lookup); + } + + /** Find the lookup index for a particular lookup. */ + public uint16 find (int token) { + uint16 index = 0; + foreach (Lookup lookup in tables) { + if (lookup.token == token) { + return index; + } + + index++; + } + + warning (@"No lookup has been created with token $(token)"); + return 0; } public void append (Lookups lookups) {