Commit f1863f6
Create lookups in arbitrary order
Changed files (4)
modifiedlibbirdfont/OpenFontFormat/CligFeature.valamodifiedlibbirdfont/OpenFontFormat/GsubTable.valamodifiedlibbirdfont/OpenFontFormat/Lookup.valamodifiedlibbirdfont/OpenFontFormat/Lookups.vala
Diff
@@ -55,14 +55,14 @@ public class CligFeature : GLib.Object { 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); }@@ -65,20 +65,25 @@ public class GsubTable : OtfTable { 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@@ -19,11 +19,13 @@ public class Lookup : GLib.Object { 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) {@@ -21,6 +21,10 @@ namespace BirdFont { 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 () { } @@ -32,6 +36,21 @@ public class Lookups : GLib.Object { 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) { foreach (Lookup lookup in lookups.tables) { tables.add (lookup);