Clone in a terminal:
Commit a32c242
Johan Mattsson - 2012-08-16T18:46:11+00:00
a32c2423b4433ff284931bc1924a9482d97bb294johan.mattsson.m@gmail.com

look up name in kerning tab

Changed files (6)

Diff

diff --git a/src/Context.vala b/src/Context.valaindex 045cbd0..630c90d 100644--- a/src/Context.vala+++ b/src/Context.vala@@ -143,8 +143,6 @@ class ContextDisplay : FontDisplay {  		font.touch (); -		// handle++; // use handle before next glyph- 		a = ""; 		b = ""; @@ -158,7 +156,6 @@ class ContextDisplay : FontDisplay { 				b = s; 				 				if (handle == wi) {-					print (@"SET get $a\n"); 					kern = font.get_kerning (a, b) + val; 					font.set_kerning (a, b, kern); 				}@@ -212,7 +209,8 @@ class ContextDisplay : FontDisplay { 	 	public override void key_press (EventKey e) { 		unichar c = (unichar) e.keyval;-		StringBuilder s = new StringBuilder ();+		Font f = Supplement.get_current_font ();+		string name; 		 		if (e.type == EventType.KEY_PRESS && (KeyBindings.singleton.modifier == NONE || KeyBindings.singleton.modifier == SHIFT)) { 					@@ -225,8 +223,8 @@ class ContextDisplay : FontDisplay { 			} 			 			if (!is_modifier_key (c) && c.validate ()) {-				s.append_unichar (c);-				row.first ().data.glyph.append (s.str);+				name = f.get_name_for_character (c);+				row.first ().data.glyph.append (name); 			} 		} 		diff --git a/src/Font.vala b/src/Font.valaindex aefd26d..fd7589c 100644--- a/src/Font.vala+++ b/src/Font.vala@@ -351,7 +351,32 @@ class Font : GLib.Object { 		} 	} 	-	bool has_name (string name) {+	public string get_name_for_character (unichar c) {+		// if some glyph is already mapped to unichar, return it's name+		uint i = 0;+		Glyph? gl;+		Glyph g;+		StringBuilder sb;+		+		while ((gl = get_glyph_indice (i++)) != null) {+			g = (!) gl;+			+			if (g.unichar_code == c) {+				return g.name;+			}+		}+						+		// otherwise return some default name, possibly from unicode database+		if (c == 0) {+			return ".null".dup ();+		}+		+		sb = new StringBuilder ();+		sb.append_unichar (c);+		return sb.str;		+	}+	+	public bool has_name (string name) { 		foreach (string n in glyph_names) { 			if (n == name) { 				return true;@@ -397,12 +422,6 @@ class Font : GLib.Object { 		return gc; 	} 	-	public Glyph? get_glyph_from_unichar (unichar glyph) {-		StringBuilder name = new StringBuilder ();-		name.append_unichar (glyph);-		return get_glyph (name.str);-	}-	 	public Glyph? get_glyph (string glyph) { 		GlyphCollection? gc = get_glyph_collection (glyph); 		@@ -797,32 +816,6 @@ class Font : GLib.Object { 		return true; 	} 	-	/** Measure height of x or other lower case letter. */-	private double estimate_xheight () {-		Glyph? g;-		double ym = 0;-		for (unichar c = 'x'; c >= 'a' ; c--) {-			g = get_glyph_from_unichar (c);-			-			// we want x-height skip letters with ascender-			if (c == 'l' || c == 'k' || c == 'i' -				|| c == 'j' || c == 'h' || c == 'd') {-				continue;-			}-			-			if (g != null) {-				foreach (Path path in ((!) g).path_list) {-					path.update_region_boundries ();-					if (path.ymax > ym) {-						ym = path.ymax;-					}-				}-			} -		}-		-		return -ym;-	}-	 	public bool parse_file (string path) { 		Parser.init (); 		diff --git a/src/GlyphTable.vala b/src/GlyphTable.valaindex 3ac873d..d34daa8 100644--- a/src/GlyphTable.vala+++ b/src/GlyphTable.vala@@ -258,16 +258,6 @@ class GlyphTable : GLib.Object {  	unowned List<Item>? find_next_index (string n) { 		unowned List<Item>? next = find_next_via_index (n);-		-		if (next != null) {-			/*-			if (compare (n, ((!)next).data) == 0) { // not unique-				warning (@"Index is not unique $n == $(((!)next).data.name)");-			}-			*/-			//return ((!)next).prev;-		}-	 		return next; 	} diff --git a/src/Path.vala b/src/Path.valaindex 26039c9..9106e5a 100644--- a/src/Path.vala+++ b/src/Path.vala@@ -43,6 +43,7 @@ class Path { 	bool edit = true; 	bool open = true; +	bool set_direction_from_tool = true; 	bool no_derived_direction = false; 	bool clockwise_direction = true; @@ -1040,11 +1041,12 @@ class Path { 		EditPointHandle eh; 		 		quadratic_path = copy ();-		+		quadratic_path.close ();+				 		if (quadratic_path.points.length () < 2) { 			return quadratic_path; 		}-	+ 		// split all curves in as many regions as we need 		split_cubic_in_parts (quadratic_path);	 @@ -1069,9 +1071,9 @@ class Path { 		eh.length = 0;  		eh = ((!)quadratic_path.points.last ().prev).data.get_right_handle ();-		eh.set_point_type (PointType.NONE);-		eh.length *= 1.7;-						+		eh.set_point_type (PointType.CURVE);+		eh.length *= 1.6;+ 		return quadratic_path; 	} @@ -1121,12 +1123,15 @@ class Path { 		if (split_cubic_in_half (cubic_path, middle)) { 			need_split = true; 		}-				+			 		e = (!) cubic_path.points.first (); 		for (uint i = 0; i < len - 1; i++) { 			middle.prev = e; 			middle.next = e.next; 			+			middle.get_prev ().data.recalculate_linear_handles ();+			middle.get_next ().data.recalculate_linear_handles ();+			 			if (split_cubic_in_half (cubic_path, middle)) { 				e = (!) e.next.next; 				need_split = true;diff --git a/src/PenTool.vala b/src/PenTool.valaindex befa1b5..c1c21dc 100644--- a/src/PenTool.vala+++ b/src/PenTool.vala@@ -384,7 +384,7 @@ class PenTool : Tool { 		((!)glyph.active_path).points.last ().data.right_handle.parent.recalculate_linear_handles (); 	} -	void set_default_handle_positions () {+	public static void set_default_handle_positions () { 		Glyph g = MainWindow.get_current_glyph (); 		foreach (var p in g.path_list) { 			if (p.is_editable ()) {@@ -394,14 +394,7 @@ class PenTool : Tool { 		} 	} -	void set_default_handle_positions_on_path (Path path) {-		EditPointHandle h;-		EditPoint n;-		double nx, ny;-		-		// set handle pointing at next point to create a line to next point-		// as default handle position for LINE points.-		+	static void set_default_handle_positions_on_path (Path path) { 		foreach (EditPoint e in path.points) { 			e.recalculate_linear_handles (); 		}diff --git a/src/TestCases.vala b/src/TestCases.valaindex c049cca..e356394 100644--- a/src/TestCases.vala+++ b/src/TestCases.vala@@ -38,6 +38,25 @@ class TestCases { 		add (test_view_result, "View result in web browser"); 		add (test_save_backup, "Save backup"); 		add (test_convert_to_quadratic_bezier_path, "Convert to quadratic path");+		add (test_notdef, "Notdef");+	}++	public static void test_notdef () {+		Font f = Supplement.get_current_font ();+		Glyph n = f.get_not_def_character ();+		Glyph g;+		Path pn;+		+		f.add_glyph (n);+		+		Tool.test_open_next_glyph ();+		g = MainWindow.get_current_glyph ();+		foreach (Path p in n.path_list) {+			pn = p.copy ().get_quadratic_points ();+			g.path_list.append (pn);+			pn.move (50, 0);+			g.path_list.append (p.copy ());+		} 	}  	public static void test_convert_to_quadratic_bezier_path () {

Contact

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