The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Skip empty ligatures in kerning display

These changes was commited to the Birdfont repository Mon, 12 Oct 2015 14:18:03 +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 14:18:03 +0000 (16:18 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 12 Oct 2015 14:22:22 +0000 (16:22 +0200)
commit cf52bf0f58c63cc029819bed802abc2e88c8b5e2
tree e7d30cf3c09ec5cb4cc681b88525f5eb17cfaca6
parent 893948dc74656e44416f2c28faf27c433f07857d
Skip empty ligatures in kerning display

libbirdfont/GlyphSequence.vala
libbirdfont/OpenFontFormat/ContextualLigature.vala
--- a/libbirdfont/GlyphSequence.vala +++ b/libbirdfont/GlyphSequence.vala @@ -81,8 +81,12 @@ ligatures = font.get_ligatures (); foreach (ContextualLigature c in ligatures.contextual_ligatures) { - ligature_sequence.replace_contextual (c.get_backtrack (), - c.get_input (), c.get_lookahead (), c.get_ligature_sequence ()); + if (c.is_valid ()) { + ligature_sequence.replace_contextual (c.get_backtrack (), + c.get_input (), + c.get_lookahead (), + c.get_ligature_sequence ()); + } } ligatures.get_single_substitution_ligatures ((substitute, ligature) => { @@ -156,7 +160,7 @@ glyph = substitute (i + backtrack.length (), input.length (), replacement); advance = backtrack.length () + replacement.length (); - i += advance; + i += advance + 1; if (advance <= 0) { warning ("No advancement.");
--- a/libbirdfont/OpenFontFormat/ContextualLigature.vala +++ b/libbirdfont/OpenFontFormat/ContextualLigature.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Johan Mattsson + Copyright (C) 2014 2015 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -141,7 +141,35 @@ public GlyphSequence get_ligature_sequence () { return get_sequence (ligatures); } + + public bool is_valid () { + foreach (string s in font.get_names (backtrack)) { + if (font.get_glyph_collection_by_name (s) == null) { + return false; + } + } + foreach (string s in font.get_names (input)) { + if (font.get_glyph_collection_by_name (s) == null) { + return false; + } + } + + foreach (string s in font.get_names (lookahead)) { + if (font.get_glyph_collection_by_name (s) == null) { + return false; + } + } + + foreach (string s in font.get_names (ligatures)) { + if (font.get_glyph_collection_by_name (s) == null) { + return false; + } + } + + return true; + } + GlyphSequence get_sequence (string context) { GlyphCollection? gc; GlyphSequence gs;