Clone in a terminal:
Commit 8ed1aea
Johan Mattsson - 2013-02-17T22:18:47+00:00
8ed1aea9c3de03e8efbbc5110ab2cef38db35987johan.mattsson.m@gmail.com

truncate kerning table

Changed files (9)

Diff

diff --git a/README b/READMEindex c45b3e5..78ce6bd 100644--- a/README+++ b/README@@ -61,6 +61,8 @@ You need to install the windows version on drive C:. A Ubuntu package is avalilable at https://launchpad.net
 You can apt-get install birdfont form Olivier Bertens repository.
 
+A Debian packages is available at http://packages.debian.org
+
 A Machintosh binary image is available at http://birdfont.org
 You might need to install a more recent version of XOrg. Install 
 the server and run:
diff --git a/birdfont-export.sh b/birdfont-export.shindex 792bcad..fbef6d7 100755--- a/birdfont-export.sh+++ b/birdfont-export.sh@@ -1,4 +1,6 @@+#!/bin/bash export LD_LIBRARY_PATH="./build/:$LD_LIBRARY_PATH" PKG_PATH=$(dirname "$(readlink -f "$0")") cd "${PKG_PATH}"-./build/bin/birdfont-export $@++./build/bin/birdfont-export "$@"diff --git a/birdfont-export/BirdfontExport.vala b/birdfont-export/BirdfontExport.valaindex f77cd4e..f6f7dab 100644--- a/birdfont-export/BirdfontExport.vala+++ b/birdfont-export/BirdfontExport.vala@@ -17,7 +17,6 @@  using BirdFont; -/** Stand alone command line utility for exporting fonts. */-public static int main (string[] arg) {				+public static int main (string[] arg) { 	return run_export (arg); }diff --git a/birdfont.sh b/birdfont.shindex 0af33d6..d5fabdc 100755--- a/birdfont.sh+++ b/birdfont.sh@@ -1,3 +1,4 @@+#!/bin/bash export LD_LIBRARY_PATH="./build/:$LD_LIBRARY_PATH" PKG_PATH=$(dirname "$(readlink -f "$0")") cd "${PKG_PATH}"diff --git a/libbirdfont/BirdFont.vala b/libbirdfont/BirdFont.valaindex 3952052..77054b6 100644--- a/libbirdfont/BirdFont.vala+++ b/libbirdfont/BirdFont.vala@@ -18,7 +18,7 @@ using BirdFont; const string GETTEXT_PACKAGE = "birdfont";   namespace BirdFont {-+	 static void print_export_help (string[] arg) { 	stdout.printf (_("Usage:")); 	stdout.printf (arg[0]);@@ -38,7 +38,7 @@ public static int run_export (string[] arg) { 	bool write_svg = false; 	 	File directory;-		+ 	if (arg.length < 2) { 		print_export_help (arg); 		return -1;@@ -177,13 +177,13 @@ public bool has_flag (uint32 flag, uint32 mask) { public class BirdFont { 	public static Argument args; 	public static bool experimental = false;-	internal static bool show_coordinates = false;-	internal static bool fatal_wanings = false;+	public static bool show_coordinates = false;+	public static bool fatal_wanings = false; 	public static bool win32 = false; 	public static bool mac = false;-	internal static string exec_path = "";+	public static string exec_path = ""; -	internal static Font current_font;+	public static Font current_font; 	public static Glyph current_glyph; 	 	public void init (string[] arg) {diff --git a/libbirdfont/ExportTool.vala b/libbirdfont/ExportTool.valaindex 96a8d92..8cd5f29 100644--- a/libbirdfont/ExportTool.vala+++ b/libbirdfont/ExportTool.vala@@ -471,6 +471,7 @@ os.put_string (  			if (async) { 				export_command = @"$(get_birdfont_export ()) --ttf -o \"$((!) folder.get_path ())\" \"$temp_file\"";+				print (@"Running export command: $export_command\n"); 				 				try { 					Process.spawn_command_line_async (export_command);@@ -481,7 +482,6 @@ os.put_string ( 			} 			 			if (!async) {-				print ("sync\n"); 				export_thread.run (); 			} 			diff --git a/libbirdfont/Font.vala b/libbirdfont/Font.valaindex 2988536..9c7f3ec 100644--- a/libbirdfont/Font.vala+++ b/libbirdfont/Font.vala@@ -886,7 +886,6 @@ public class Font : GLib.Object { 	}  	private bool parse_svg_file (string path) {-		print ("parse_svg_file\n"); 		SvgFont svg_font = new SvgFont (this); 		svg_font.load (path); 		return true;diff --git a/libbirdfont/OpenFontFormatWriter.vala b/libbirdfont/OpenFontFormatWriter.valaindex 78bc9aa..d2f3d90 100644--- a/libbirdfont/OpenFontFormatWriter.vala+++ b/libbirdfont/OpenFontFormatWriter.vala@@ -275,14 +275,14 @@ class FontData : Object { 
 	public uint64 read_uint64 () {
 		uint64 f;
-		f = read () << 8 * 7;
-		f += read () << 8 * 6;
-		f += read () << 8 * 5;
-		f += read () << 8 * 4;
-		f += read () << 8 * 3;
-		f += read () << 8 * 2;
-		f += read () << 8 * 1;
-		f += read () << 8 * 0;
+		f = (uint64) read () << 8 * 7;
+		f += (uint64) read () << 8 * 6;
+		f += (uint64) read () << 8 * 5;
+		f += (uint64) read () << 8 * 4;
+		f += (uint64) read () << 8 * 3;
+		f += (uint64) read () << 8 * 2;
+		f += (uint64) read () << 8 * 1;
+		f += (uint64) read () << 8 * 0;
 		return f;
 	}
 
@@ -4240,6 +4240,7 @@ class KernTable : Table { 		uint16 search_range = 0;
 		
 		Kern kern;
+		int i;
 		
 		fd.add_ushort (0); // version 
 		fd.add_ushort (1); // n subtables
@@ -4253,8 +4254,8 @@ class KernTable : Table { 		}
 		
 		if (n_pairs > (uint16.MAX - 14) / 6.0) {
-			warning ("Too many kerning pairs!"); // TODO: find a way to deal with it.
-			n_pairs = 0;
+			warning ("Too many kerning pairs!"); 
+			n_pairs = (uint16) ((uint16.MAX - 14) / 6.0);
 		}
 		
 		this.kerning_pairs = n_pairs;
@@ -4274,27 +4275,31 @@ class KernTable : Table { 
 		gid_left = 0;
 		
-		if (n_pairs != 0) { // n_pairs will be set to zero to prevent buffer overflow
-			foreach (Glyph g in glyf_table.glyphs) {
+		i = 0;
+		foreach (Glyph g in glyf_table.glyphs) {
+			
+			foreach (Kerning k in g.kerning) {
+				// n_pairs is used to truncate this table to prevent buffer overflow
+				if (n_pairs == ++i) {
+					break;
+				}
+
+				gid_right = glyf_table.get_gid (k.glyph_right);
 				
-				foreach (Kerning k in g.kerning) {
-					gid_right = glyf_table.get_gid (k.glyph_right);
-					
-					if (gid_right == -1) {
-						warning ("right glyph not found in kerning table");
-					}
-					
-					kern = new Kern (gid_left, (uint16)gid_right, (int16) (k.val * UNITS));
-					
-					fd.add_ushort (kern.left);
-					fd.add_ushort (kern.right);
-					fd.add_short (kern.kerning);
-					
-					kernings.append (kern);
+				if (gid_right == -1) {
+					warning ("right glyph not found in kerning table");
 				}
 				
-				gid_left++;
+				kern = new Kern (gid_left, (uint16)gid_right, (int16) (k.val * UNITS));
+				
+				fd.add_ushort (kern.left);
+				fd.add_ushort (kern.right);
+				fd.add_short (kern.kerning);
+				
+				kernings.append (kern);
 			}
+			
+			gid_left++;
 		}
 		
 		fd.pad ();
@@ -4772,7 +4777,7 @@ class DirectoryTable : Table { 		
 		fd = new FontData ();
 
-		return_val_if_fail (offset_table.num_tables > 0, fd);
+		return_if_fail (offset_table.num_tables > 0);
 		
 		table_offset += offset_table.get_font_data ().length_with_padding ();
 		
@@ -4842,7 +4847,7 @@ internal static uint16 largest_pow2_exponent (uint16 max) { }
 
 void printd (string s) {
-	print (s);
+	//print (s);
 }
 
 }
diff --git a/libbirdfont/load_svg_font.c b/libbirdfont/load_svg_font.cindex 355689e..0415b32 100644--- a/libbirdfont/load_svg_font.c+++ b/libbirdfont/load_svg_font.c@@ -199,7 +199,6 @@ GString* get_svg_glyph_data (FT_Face face, int* err) { 	int end; 	 	if (face->glyph->outline.n_points == 0) {-		fprintf (stderr, "Freetype error no points for outline in glyph.\n"); // FIXME: DELETE 		return svg;			 	} 

Contact

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