The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Ignore alternates with no corresponding glyph in the font

These changes was commited to the Birdfont repository Mon, 13 Jun 2016 18:27:24 +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, 13 Jun 2016 18:27:24 +0000 (20:27 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 13 Jun 2016 18:27:24 +0000 (20:27 +0200)
commit cf58fd5cb41c9ee0485580fe1883bf28fcbc230f
tree 681231853bc9d1ccc090641db98700bec704e7f2
parent e860e1705fdcd6312fcf450d6b99ebb1c8f242ce
Ignore alternates with no corresponding glyph in the font

libbirdfont/AlternateSets.vala
libbirdfont/OpenFontFormat/AlternateFeature.vala
--- a/libbirdfont/AlternateSets.vala +++ b/libbirdfont/AlternateSets.vala @@ -51,7 +51,30 @@ return alt; } - + + public Gee.ArrayList<Alternate> get_alt_with_glyph (string tag, Font font) { + Gee.ArrayList<Alternate> alt; + alt = new Gee.ArrayList<Alternate> (); + + foreach (Alternate a in alternates) { + Alternate available = new Alternate (a.glyph_name, a.tag); + + foreach (string substitution in a.alternates) { + if (font.has_glyph (substitution)) { + available.alternates.add (substitution); + } + } + + if (available.tag == tag && available.alternates.size > 0) { + if (font.has_glyph (available.glyph_name)) { + alt.add (available); + } + } + } + + return alt; + } + public void remove_empty_sets () { int i = 0; foreach (Alternate a in alternates) {
--- a/libbirdfont/OpenFontFormat/AlternateFeature.vala +++ b/libbirdfont/OpenFontFormat/AlternateFeature.vala @@ -24,7 +24,7 @@ this.tag = tag; this.glyf_table = glyf_table; - alternates = font.alternates.get_alt (tag); + alternates = font.alternates.get_alt_with_glyph (tag, font); alternates.sort ((a, b) => { Alternate alt1 = (Alternate) a;