Commit 893948d
Fix backtrack sequence for contextual ligatures Generate contextual substitutions compatible with the currents version of Harfbuzz.
Changed files (3)
modifiedlibbirdfont/Font.valamodifiedlibbirdfont/OpenFontFormat/ContextualLigature.valamodifiedlibbirdfont/OpenFontFormat/LigatureSet.vala
Diff
@@ -944,6 +944,14 @@ public class Font : GLib.Object { * @return glyph names */ public Gee.ArrayList<string> get_names (string glyphs) {+ return get_names_order (glyphs, false);+ }++ public Gee.ArrayList<string> get_names_in_reverse_order (string glyphs) {+ return get_names_order (glyphs, true);+ }+ + public Gee.ArrayList<string> get_names_order (string glyphs, bool reverse) { Gee.ArrayList<string> names = new Gee.ArrayList<string> (); string[] parts = glyphs.strip ().split (" "); @@ -966,7 +974,11 @@ public class Font : GLib.Object { } if (p != "") {- names.add (p);+ if (reverse) {+ names.insert (0, p);+ } else {+ names.add (p);+ } } } @@ -48,7 +48,14 @@ public class ContextualLigature : GLib.Object { FontData fd = new FontData (); Font font = BirdFont.get_current_font (); // FIXME: thread safety? - Gee.ArrayList<string> backtrack = font.get_names (backtrack);+ // FIXME: it looks like get_names is the right function+ // but harfbuzz assumes that glyphs appear in the other + // order for latin scripts, get_names_in_reverse_order+ // creates an array of glyphs in reverse order.+ //+ // I have not found out why yet.+ + Gee.ArrayList<string> backtrack = font.get_names_in_reverse_order (backtrack); Gee.ArrayList<string> input = font.get_names (input); Gee.ArrayList<string> lookahead = font.get_names (lookahead); @@ -85,8 +85,8 @@ public class LigatureSet : GLib.Object { bool first = true; int gid; string l;-- l = ligature.ligature;+ + l = ligature.ligature.strip (); if (l.has_prefix ("U+") || l.has_prefix ("u+")) { l = (!) Font.to_unichar (l).to_string (); }