Clone in a terminal:
Commit 99947cf
Johan Mattsson - 2012-08-02T16:41:52+00:00
99947cf53ea9e0c6bf8e4b94b56c4310733acf12johan.mattsson.m@gmail.com

fix overview scroll issues

Changed files (4)

Diff

diff --git a/src/Font.vala b/src/Font.valaindex 44bef00..d985ff6 100644--- a/src/Font.vala+++ b/src/Font.vala@@ -676,7 +676,7 @@ class Font : GLib.Object { 	 	/** Callbackt function for finishing parsing of font file. */  	public void loading_finished_callback () {-		print ("Done Loading.");+		print ("Done Loading.\n"); 	}  	/** Callback function for loading glyph in a separate thread. */@@ -686,8 +686,6 @@ class Font : GLib.Object { 		 		gcl = get_glyph_collection (g.get_name ()); 		-		// print (@"added name: $(g.name)\n");-		 		if (gcl != null) { 			warning (@"glyph \"$(g.get_name ())\" does already exist"); 		}@@ -699,6 +697,8 @@ class Font : GLib.Object { 				g.name = @"($(++next_unindexed))"; 			} 			+			// del: print (@"added name: $(g.name)\n");+			 			add_glyph_collection ((!) gc); 		} else if (gcl == null) { 			gc = new GlyphCollection (g);@@ -709,7 +709,7 @@ class Font : GLib.Object { 			g.name = @"($(++next_unindexed))"; 			add_glyph_collection ((!) gc); 		}-		+				 		// take xheight from appropriate lower case letter 		// xheight_position = estimate_xheight (); 	}diff --git a/src/GlyphTable.vala b/src/GlyphTable.valaindex c924b34..3ac873d 100644--- a/src/GlyphTable.vala+++ b/src/GlyphTable.vala@@ -102,6 +102,7 @@ class GlyphTable : GLib.Object { 		next = find_next (g.get_name ()); 		 		item = new Item (g.get_name (), g);+		 		if (next == null) { 			data.append (item); 		} else {diff --git a/src/OpenFontFormatWriter.vala b/src/OpenFontFormatWriter.valaindex 91a7a20..3c9a7bc 100644--- a/src/OpenFontFormatWriter.vala+++ b/src/OpenFontFormatWriter.vala@@ -751,7 +751,7 @@ class GlyfTable : Table { 					name_c.append_unichar (character);
 					name = name_c.str;
 				}
-				
+
 				printd (@"name: $(name)\n");
 				
 				if (!loca.is_empty (i)) {	
@@ -778,12 +778,18 @@ class GlyfTable : Table { 					glyph.right_limit = hmtx_table.get_advance (i) - hmtx_table.get_lsb (i);				
 				}
 				
-				if (character == 0 && i != 0) {
+				glyph.name = name;
+
+				if (character == 0) {
 					glyph.set_unassigned (true);
 				}
 				
-				glyph.name = name;
-				
+				if (character == 0 && name != "") {
+					stderr.printf (@"gid: $i\n");
+					stderr.printf (@"char: $((uint) character)\n");
+					stderr.printf (@"name: $(name)\n");
+				}
+								
 				add_glyph (glyph);
 				
 			} catch (Error e) {
diff --git a/src/OverView.vala b/src/OverView.valaindex 0657bae..b95a489 100644--- a/src/OverView.vala+++ b/src/OverView.vala@@ -27,9 +27,9 @@ class OverView : FontDisplay { 	 	int rows = 0; 	int items_per_row = 0;-	unichar first_character = 0;-	unichar first_visible = 0;-	unichar selected = 0;+	uint32 first_character = 0;+	int64 first_visible = 0;+	uint32 selected = 0; 	 	double view_offset_y = 0; 	double view_offset_x = 0;@@ -83,7 +83,6 @@ class OverView : FontDisplay { 				z.store_current_view (); 			} 		});- 	}  	public override void scroll_wheel_up (Gdk.EventScroll e) {@@ -385,17 +384,17 @@ class OverView : FontDisplay { 				items_per_row = n_items; 				first_visible = first_character; 				-				while (selected < first_visible)+				while (selected <= first_visible) 					scroll (-nail_height); 					-				while (selected < first_visible + rows * n_items)+				while (selected <= first_visible + rows * n_items) 					scroll (nail_height); 					 			} 			 			scroll_top (); 			-			while (first_visible <= selected) {+			while (first_visible < selected) { 				scroll_rows (1); 			} 			scroll_rows (-2);@@ -448,6 +447,10 @@ class OverView : FontDisplay { 			view_offset_y = 0; 			first_visible += items_per_row; 		}+		+		if (first_visible < 0) {+			scroll_top ();+		} 	} 	 	public void scroll_top () {@@ -492,8 +495,8 @@ class OverView : FontDisplay { 				selected++; 			} 			-			if (selected > len) {-				selected = len;+			if (selected >= len) {+				selected = len - 1; 			} 			 			adjust_scroll ();@@ -512,8 +515,11 @@ class OverView : FontDisplay {  	private void key_up () { 		if (glyph_range.length () == 0) return;-				+		+		warn_if_fail (selected >= first_character);+		 		if (selected < first_character + items_per_row) {+			scroll_top (); 			return; 		} 		@@ -529,6 +535,10 @@ class OverView : FontDisplay { 		} 		 		adjust_scroll ();++		if (first_visible < first_character) {+			scroll_top ();+		} 	}	 	 	public void open_current_glyph () {@@ -552,14 +562,14 @@ class OverView : FontDisplay { 		 		selected++; 		-		if (selected > len) {-			selected = len;+		if (selected >= len) {+			selected = len - 1; 		}  		if (selected_offset_y (selected) > allocation.height - nail_height) { 			selected -= items_per_row; 			key_down ();-		}		+		} 	} 	 	public void key_left () {@@ -570,6 +580,8 @@ class OverView : FontDisplay { 				key_up (); 			} 		}+		+		print (@"selected: $(selected)\n"); 	} 	 	public string get_selected_char () {@@ -672,7 +684,7 @@ class OverView : FontDisplay { 		full.use_full_unicode_range (); 		 		set_glyph_range (full);-		selected = c + 1;+		selected = c; 		set_glyph_range (gr); 	} 		@@ -733,7 +745,7 @@ class OverView : FontDisplay { 		if (glyph_range.length () == 0) return;  		// scroll to the selected glyph-		selected = first_visible;+		selected = (uint32) first_visible;  		while (y < e.y < allocation.height) { 			selected += items_per_row;@@ -764,14 +776,14 @@ class OverView : FontDisplay {  	/** Returns true if overview shows the last character. */ 	private bool at_bottom () {-		return (rows * items_per_row + items_per_row + first_visible > glyph_range.length ());+		return (rows * items_per_row + items_per_row + first_visible >= glyph_range.length ()); 	}  	public void set_glyph_range (GlyphRange range) { 		string c = glyph_range.get_char (selected); 		bool done = false;-		unichar i;-		unichar len;+		uint32 i;+		uint32 len; 		 		glyph_range = range; 		@@ -795,7 +807,7 @@ class OverView : FontDisplay { 		}  		while (true) {-			for (i = first_visible; i < first_visible + items_per_row * (rows + 1); i++) {+			for (i = (uint32) first_visible; i < first_visible + items_per_row * (rows + 1); i++) { 				if (range.get_char (i) == c) { 					selected = i; 					done = true;@@ -818,9 +830,9 @@ class OverView : FontDisplay { 		adjust_scroll (); 		 		if (at_bottom ()) {-			while (c != glyph_range.get_char (selected) && glyph_range.get_length () > items_per_row) {+			while (c != glyph_range.get_char (selected) && glyph_range.get_length () >= items_per_row) { 				key_right ();	-				if (selected > glyph_range.get_length () - items_per_row) {+				if (selected >= glyph_range.get_length () - items_per_row) { 					break; 				} 			}

Contact

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