Clone in a terminal:
Commit fd63e9b
Johan Mattsson - 2015-03-25T19:54:02+00:00
fd63e9b4179887adf9d6061ccb8677bb0ac853d8johan.mattsson.m@gmail.com

Fix ligature substitution in spaving and kerning tab

Changed files (2)

Diff

diff --git a/libbirdfont/Font.vala b/libbirdfont/Font.valaindex 82b5fa4..7c7ac5b 100644--- a/libbirdfont/Font.vala+++ b/libbirdfont/Font.vala@@ -847,6 +847,14 @@ public class Font : GLib.Object { 				p = (!) to_unichar (p).to_string (); 			} 			+			if (p == "space") {+				p = " ";+			}++			if (p == "divis") {+				p = " ";+			}+			 			if (!has_glyph (p)) { 				warning (@"The character $p does not have a glyph in " + get_file_name ()); 				p = ".notdef";diff --git a/libbirdfont/GlyphSequence.vala b/libbirdfont/GlyphSequence.valaindex fa5e70b..5411939 100644--- a/libbirdfont/GlyphSequence.vala+++ b/libbirdfont/GlyphSequence.vala@@ -70,12 +70,13 @@ public class GlyphSequence : GLib.Object { 			return ligature_sequence; 		} +		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 ());	 		} 		-		ligatures = font.get_ligatures (); 		ligatures.get_single_substitution_ligatures ((substitute, ligature) => { 			ligature_sequence.replace (substitute, ligature); 		});@@ -92,7 +93,7 @@ public class GlyphSequence : GLib.Object { 		int i = 0; 		while (i < glyph.size) { 			if (starts_with (old, i)) {-				substitute (i, old.glyph.size, replacement);+				glyph = substitute (i, old.glyph.size, replacement); 				i += replacement.length (); 			} else { 				i++;@@ -100,17 +101,28 @@ public class GlyphSequence : GLib.Object { 		} 	} -	void replace_contextual (GlyphSequence backtrack, GlyphSequence input, GlyphSequence lookahead, GlyphSequence replacement) {+	void replace_contextual (GlyphSequence backtrack, GlyphSequence input, GlyphSequence lookahead, +		GlyphSequence replacement) {+			 		bool start, middle, end; 		int i = 0;+		int advance = 0;+ 		while (i < glyph.size) { 			start = starts_with (backtrack, i); 			middle = starts_with (input, i + backtrack.length ()); 			end = starts_with (lookahead, i + backtrack.length () + input.length ()); 			 			if (start && middle && end) {-				substitute (i + backtrack.length (), input.length (), replacement);-				i += i + backtrack.length () + input.length ();+				glyph = substitute (i + backtrack.length (), input.length (), replacement);+				+				advance = backtrack.length () + replacement.length ();+				i += advance;+				+				if (advance <= 0) {+					warning ("No advancement.");+					return;+				} 			} else { 				i++; 			}@@ -137,7 +149,7 @@ public class GlyphSequence : GLib.Object { 		return true; 	} 	-	void substitute (uint index, uint length, GlyphSequence substitute) {+	Gee.ArrayList<Glyph?> substitute (uint index, uint length, GlyphSequence substitute) { 		Gee.ArrayList<Glyph?> new_list = new Gee.ArrayList<Glyph?> (); 		int i = 0; 		@@ -155,7 +167,7 @@ public class GlyphSequence : GLib.Object { 			i++; 		} 		-		glyph = new_list;		+		return new_list; 	} } 

Contact

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