Clone in a terminal:
Commit 479c884
Johan Mattsson - 2015-05-25T06:35:37+00:00
479c884a242f1a8cbfad7a0bc53ec9a5db0fa521johan.mattsson.m@gmail.com

Show fallback character in UCD entries

Changed files (5)

Diff

diff --git a/libbirdfont/CharacterInfo.vala b/libbirdfont/CharacterInfo.valaindex 94f5605..839ab69 100644--- a/libbirdfont/CharacterInfo.vala+++ b/libbirdfont/CharacterInfo.vala@@ -18,11 +18,12 @@ namespace BirdFont {  /** Display functions for a unicode character database entry. */ public class CharacterInfo : GLib.Object {+	+	public unichar unicode;  	Text icon; 	double x = 0; 	double y = 0;-	unichar unicode; 	bool ligature = false; 	string name = ""; 	diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex 389a111..c1e532e 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -63,6 +63,7 @@ public class OverView : FontDisplay { 	CharacterInfo? character_info = null; 	 	double scroll_size = 1;+	const double UCD_LINE_HEIGHT = 17 * 1.3;  	public OverView (GlyphRange? range = null, bool open_selected = true) { 		GlyphRange gr;@@ -1194,8 +1195,12 @@ public class OverView : FontDisplay { 		bool see_also = false; 		WidgetAllocation allocation = MainWindow.get_overview ().allocation; 		string name;+		string[] lines;+		double character_start;+		double character_height; 		 		entry = ((!)character_info).get_entry ();+		lines = entry.split ("\n"); 		 		foreach (string line in entry.split ("\n")) { 			len = line.char_count ();@@ -1239,7 +1244,7 @@ public class OverView : FontDisplay { 			draw_info_line (t_("Ligature") + ": " + name, cr, x, y, 0); 		} else { 			i = 0;-			foreach (string line in entry.split ("\n")) {+			foreach (string line in lines) { 				if (i == 0) { 					column = line.split ("\t"); 					return_if_fail (column.length == 2);@@ -1267,20 +1272,39 @@ public class OverView : FontDisplay { 						draw_info_line (line.replace ("\tx (", "•").replace (")", ""), cr, x, y, i); 						i++; 					} else {- 						i++; 					} 				} 			}+			+			character_start = y + 10 + i * UCD_LINE_HEIGHT;+			character_height = h - character_start;+			draw_fallback_character (cr, x, character_start, character_height); 		} 	}+	+	/** Fallback character in UCD info. */+	void draw_fallback_character (Context cr, double x, double y, double height)+	requires (character_info != null) {+		unichar c = ((!)character_info).unicode;+		+		cr.save ();+		Text character = new Text ();+		Theme.text_color (character, "Foreground 1");+		character.set_text ((!) c.to_string ());+		character.set_font_size (height);+		character.draw_at_top (cr, x + 10, y);+		//character.draw_at_baseline (cr, x, y);+		cr.restore ();+	}  	void draw_info_line (string line, Context cr, double x, double y, int row) {+		Text ucd_entry = new Text (line); 		cr.save ();-		cr.set_font_size (12);-		Theme.color (cr, "Foreground 1");-		cr.move_to (x + 10, y + 28 + row * 18 * 1.2);-		cr.show_text (line);+		Theme.text_color (ucd_entry, "Foreground 1");+		ucd_entry.widget_x = 10 + x;+		ucd_entry.widget_y = 10 + y + row * UCD_LINE_HEIGHT;+		ucd_entry.draw (cr); 		cr.restore ();		 	} 	diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex dae1059..5f6ecb6 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -266,22 +266,22 @@ public class OverViewItem : GLib.Object { 			draw_character_info_icon (cr); 		} -		text = (glyphs == null) -			? name.str-			: ((!) glyphs).get_current ().name;-		-		double w = has_icons () ? width - 43 : width;-		label = new Text (text, 17);-		label.truncate (w);-		label.use_cache (true);-		-		if (selected) {-			Theme.text_color (label, "Overview Selected Foreground");-		} else {-			Theme.text_color (label, "Overview Foreground");+		if (glyphs != null) {+			text = name.str;+					+			double w = has_icons () ? width - 43 : width;+			label = new Text (text, 17);+			label.truncate (w);+			label.use_cache (true);+			+			if (selected) {+				Theme.text_color (label, "Overview Selected Foreground");+			} else {+				Theme.text_color (label, "Overview Foreground");+			}+			+			label.draw_at_baseline (cr, x + 0.08 * width, y + height - 6); 		}-		-		label.draw_at_baseline (cr, x + 0.08 * width, y + height - 6); 	}  	private void draw_character_info_icon (Context cr) {diff --git a/libbirdfont/Renderer/FallbackFont.vala b/libbirdfont/Renderer/FallbackFont.valaindex 5d61256..09cd7e1 100644--- a/libbirdfont/Renderer/FallbackFont.vala+++ b/libbirdfont/Renderer/FallbackFont.vala@@ -83,7 +83,7 @@ public class FallbackFont : GLib.Object { 		} 		 		// control characters-		if (c <= 0x001f) {+		if (c <= 0x001f || (0x007f <= c <= 0x008d)) { 			return bf_font; 		} 		diff --git a/libbirdfont/Renderer/Text.vala b/libbirdfont/Renderer/Text.valaindex 8603bd7..7e54998 100644--- a/libbirdfont/Renderer/Text.vala+++ b/libbirdfont/Renderer/Text.vala@@ -182,7 +182,6 @@ public class Text : Widget { 			iter (glyph, kern, i + 1 == word_with_ligatures.glyph.size);			 			prev = g; 			wi++;- 		} 	} @@ -300,7 +299,11 @@ public class Text : Widget { 	}		 	 	public override void draw (Context cr) {-		double y = widget_y + get_height () + get_scale () * (cached_font.bottom_limit + cached_font.base_line);+		double descender = cached_font.bottom_limit + cached_font.base_line;+		double y = widget_y + get_height () + get_scale () * descender;+			+		cached_font.get_glyph_by_name ((!) text.get_char (0).to_string ());+		 		draw_at_baseline (cr, widget_x, y); 	} 	

Contact

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