Clone in a terminal:
Commit f8c2080
Johan Mattsson - 2012-08-28T20:28:07+00:00
f8c2080b5496e6de19e49a6260643aec304f538ajohan.mattsson.m@gmail.com

improved is over test case

Changed files (2)

Diff

diff --git a/src/OpenFontFormatWriter.vala b/src/OpenFontFormatWriter.valaindex 57e8cc0..b4b841a 100644--- a/src/OpenFontFormatWriter.vala+++ b/src/OpenFontFormatWriter.vala@@ -599,7 +599,7 @@ class LocaTable : Table { 						warning (@"Invalid loca table, it must be sorted. ($(glyph_offsets[i - 1]) > $(glyph_offsets[i]))");
 						print_offsets ();
 					}
-				} 
+				}
 				break;
 				
 			case 1:
@@ -611,6 +611,7 @@ class LocaTable : Table { 						print_offsets ();
 					}				
 				}
+
 				break;
 			
 			default:
@@ -629,12 +630,25 @@ class LocaTable : Table { 		FontData fd = new FontData ();
 		Font font = Supplement.get_current_font ();
 		uint32 last = 0;
+		uint32 prev = 0;
+		int i = 0;
 		
 		foreach (uint32 o in glyf_table.location_offsets) {
+			if (i != 0 && (o - prev) == 0) {
+				warning (@"gid $i is empty in loca table");
+			}
+
+			if (i != 0 && (o - prev) % 4 != 0) {
+				warning (@"glyph length is not a multiple of four in gid $i");
+			}
+			
 			if (o % 4 != 0) {
 				warning ("glyph is not on a four byte boundry");
 				assert_not_reached ();
 			}
+			
+			prev = o;
+			i++;
 		}
 	
 		if (head_table.loca_offset_size == 0) {
@@ -662,8 +676,7 @@ class LocaTable : Table { 		} else {
 			warn_if_reached ();
 		}
-		
-		// err maybe not +1
+
 		if (!(glyf_table.location_offsets.length () == glyf_table.glyphs.length () + 1)) {
 			warning (@"(glyf_table.location_offsets.length () == glyf_table.glyphs.length () + 1) ($(glyf_table.location_offsets.length ()) == $(glyf_table.glyphs.length () + 1))");
 		}
@@ -1426,8 +1439,8 @@ class GlyfTable : Table { 				
 				fd.add_16 ((int16) x);
 				
-				if (x + prev <= txmin) txmin = (int16) (x + prev);
-				if (x + prev >= txmax) txmax = (int16) (x + prev + 0.5);
+				if (x + prev <= txmin) txmin = (int16) x + (int16) prev;
+				if (x + prev >= txmax) txmax = (int16) x + (int16) prev;
 				
 				prev = e.x * UNITS + g.left_limit * UNITS;
 				
@@ -1451,8 +1464,8 @@ class GlyfTable : Table { 				y = e.y * UNITS - prev + font.base_line  * UNITS;
 				fd.add_16 ((int16) y);
 
-				if (y + prev <= tymin) tymin = (int16) (y + prev);
-				if (y + prev >= tymax) tymax = (int16) (y + prev + 0.5);
+				if (y + prev <= tymin) tymin = (int16) y + (int16) prev;
+				if (y + prev >= tymax) tymax = (int16) y + (int16) prev;
 
 				prev = e.y * UNITS + font.base_line * UNITS;
 				
diff --git a/src/TestCases.vala b/src/TestCases.valaindex 7a5123d..30cca6d 100644--- a/src/TestCases.vala+++ b/src/TestCases.vala@@ -64,7 +64,7 @@ class TestCases { 		warn_if_fail (g.active_paths.length () == 0);  		g.select_path (50, 50);-		+ 		warn_if_fail (g.active_paths.length () == 1); 		 		p.add (-10, 10);@@ -72,8 +72,8 @@ class TestCases { 		p.add (10, -10); 		p.add (-10, -10); 		p.update_region_boundries ();-		p.close (); 		g.add_path (p);+		g.close_path ();  		if (!p.is_over_coordinate (0, 0)) { 			warning ("Coordinate 0, 0 is not in path.");@@ -83,7 +83,14 @@ class TestCases { 			warning ("Corner corrdinate -10, 10 is not in path."); 		} 		-		warn_if_fail (!p.is_over_coordinate (-20, -20));		+		warn_if_fail (!p.is_over_coordinate (-20, -20));+		+		for (double x = -10; x <= 10; x += 0.1) {+			for (double y = 10; y <= 10; y += 0.1) {+				warn_if_fail (p.is_over_coordinate (x, y));+			} +		} +		 	}  	public static void test_merge () {

Contact

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