The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix backtrack sequence for contextual ligatures

These changes was commited to the Birdfont repository Mon, 12 Oct 2015 13:22:16 +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>
Mon, 12 Oct 2015 13:22:16 +0000 (15:22 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 12 Oct 2015 13:25:47 +0000 (15:25 +0200)
commit 893948dc74656e44416f2c28faf27c433f07857d
tree df761687de8dea5502a89dddbae4b1645526e952
parent cd5df0b1227f222c27e73776618170315371678c
Fix backtrack sequence for contextual ligatures
Generate contextual substitutions compatible with the currents version of
Harfbuzz.

libbirdfont/Font.vala
libbirdfont/OpenFontFormat/ContextualLigature.vala
libbirdfont/OpenFontFormat/LigatureSet.vala
--- a/libbirdfont/Font.vala +++ b/libbirdfont/Font.vala @@ -944,6 +944,14 @@ * @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 @@ } if (p != "") { - names.add (p); + if (reverse) { + names.insert (0, p); + } else { + names.add (p); + } } }
--- a/libbirdfont/OpenFontFormat/ContextualLigature.vala +++ b/libbirdfont/OpenFontFormat/ContextualLigature.vala @@ -48,7 +48,14 @@ 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);
--- a/libbirdfont/OpenFontFormat/LigatureSet.vala +++ b/libbirdfont/OpenFontFormat/LigatureSet.vala @@ -85,8 +85,8 @@ 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 (); }