Clone in a terminal:
Commit f1863f6
Johan Mattsson - 2015-09-26T20:33:04+00:00
f1863f60799a46b8336b8cb1e81b9be70e38d387johan.mattsson.m@gmail.com

Create lookups in arbitrary order

Changed files (4)

Diff

diff --git a/libbirdfont/OpenFontFormat/CligFeature.vala b/libbirdfont/OpenFontFormat/CligFeature.valaindex c8d6f82..5b0394b 100644--- a/libbirdfont/OpenFontFormat/CligFeature.vala+++ b/libbirdfont/OpenFontFormat/CligFeature.vala@@ -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); 	}diff --git a/libbirdfont/OpenFontFormat/GsubTable.vala b/libbirdfont/OpenFontFormat/GsubTable.valaindex 7067df9..6532d07 100644--- a/libbirdfont/OpenFontFormat/GsubTable.vala+++ b/libbirdfont/OpenFontFormat/GsubTable.vala@@ -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 ()); 		 		// subtablesdiff --git a/libbirdfont/OpenFontFormat/Lookup.vala b/libbirdfont/OpenFontFormat/Lookup.valaindex f31761d..39bb0e9 100644--- a/libbirdfont/OpenFontFormat/Lookup.vala+++ b/libbirdfont/OpenFontFormat/Lookup.vala@@ -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) {diff --git a/libbirdfont/OpenFontFormat/Lookups.vala b/libbirdfont/OpenFontFormat/Lookups.valaindex 85bf560..0168e44 100644--- a/libbirdfont/OpenFontFormat/Lookups.vala+++ b/libbirdfont/OpenFontFormat/Lookups.vala@@ -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);

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112