Clone in a terminal:
Commit 2420772
Johan Mattsson - 2016-06-04T14:30:31+00:00
2420772416abcf3ed48f918083a75e5c9f91fef8johan.mattsson.m@gmail.com

Fix export errors for fonts with missing default characters like notdef and space

Changed files (2)

Diff

diff --git a/libbirdfont/Font.vala b/libbirdfont/Font.valaindex 58466c4..78e7526 100644--- a/libbirdfont/Font.vala+++ b/libbirdfont/Font.vala@@ -438,9 +438,16 @@ public class Font : GLib.Object { 	public GlyphCollection get_nonmarking_return () { 		Glyph g; 		GlyphCollection gc;+		GlyphCollection? non_marking; 		 		if (has_glyph ("nonmarkingreturn")) {-			return (!) get_glyph_collection ("nonmarkingreturn");+			non_marking = get_glyph_collection ("nonmarkingreturn");+			+			if (non_marking == null) {+				warning ("Non marking return not created.");+			} else {+				return (!)non_marking;+			} 		} 		 		gc = new GlyphCollection ('\r', "nonmarkingreturn");@@ -462,9 +469,16 @@ public class Font : GLib.Object { 	public GlyphCollection get_null_character () { 		Glyph n; 		GlyphCollection gc;+		GlyphCollection? none;		 		 		if (has_glyph ("null")) {-			return (!) get_glyph_collection ("null");+			none = get_glyph_collection ("null");+			+			if (none == null) {+				warning("Null character not created.");+			} else {+				return (!) none;+			} 		} 		 		gc = new GlyphCollection ('\0', "null");@@ -485,14 +499,19 @@ public class Font : GLib.Object { 	 	public GlyphCollection get_space () { 		Glyph n;-		GlyphCollection gc;+		GlyphCollection gc;		+		GlyphCollection? space = null; 		 		if (has_glyph (" ")) {-			return (!) get_glyph_collection (" ");+			space = get_glyph_collection (" "); 		}  		if (has_glyph ("space")) {-			return (!) get_glyph_collection ("space");+			space = get_glyph_collection ("space");+		}++		if (space != null) {+			return (!) space;			 		} 		 		gc = new GlyphCollection (' ', "space");diff --git a/libbirdfont/OpenFontFormat/GlyfTable.vala b/libbirdfont/OpenFontFormat/GlyfTable.valaindex badcdc1..511c6b7 100644--- a/libbirdfont/OpenFontFormat/GlyfTable.vala+++ b/libbirdfont/OpenFontFormat/GlyfTable.vala@@ -113,15 +113,17 @@ public class GlyfTable : OtfTable { 		 		foreach (GlyphCollection gc in glyphs) { 			g = gc.get_current ();++			printd (@"adding glyph: $(gc.get_name ())\n");+						 			// set values for loca table 			assert (fd.length () % 4 == 0); 			location_offsets.add (fd.length ()); 			process_glyph (g, fd); -			printd (@"adding glyph: $(g.name)\n"); 			printd (@"glyf length: $(fd.length () - last_len)\n"); 			printd (@"loca fd.length (): $(fd.length ())\n");-+			 			last_len = fd.length (); 		} @@ -194,6 +196,13 @@ public class GlyfTable : OtfTable { 		foreach (GlyphCollection ug in unassigned_glyphs) { 			glyphs.add (ug); 		}+		+		+		int gid = 0;+		foreach (GlyphCollection ug in glyphs) {+			printd (@"Glyph: $(ug.get_name ()) GID: $(gid)\n");+			gid++;+		} 	}  	public void process_glyph (Glyph g, FontData fd) throws GLib.Error {

Contact

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