Clone in a terminal:
Commit cf58fd5
Johan Mattsson - 2016-06-13T18:27:24+00:00
cf58fd5cb41c9ee0485580fe1883bf28fcbc230fjohan.mattsson.m@gmail.com

Ignore alternates with no corresponding glyph in the font

Changed files (2)

Diff

diff --git a/libbirdfont/AlternateSets.vala b/libbirdfont/AlternateSets.valaindex 871c1a0..637e3f6 100644--- a/libbirdfont/AlternateSets.vala+++ b/libbirdfont/AlternateSets.vala@@ -51,7 +51,30 @@ public class AlternateSets : GLib.Object { 		 		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) {diff --git a/libbirdfont/OpenFontFormat/AlternateFeature.vala b/libbirdfont/OpenFontFormat/AlternateFeature.valaindex 0a40223..9434b7a 100644--- a/libbirdfont/OpenFontFormat/AlternateFeature.vala+++ b/libbirdfont/OpenFontFormat/AlternateFeature.vala@@ -24,7 +24,7 @@ public class AlternateFeature : GLib.Object { 		 		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;

Contact

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