The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Show fallback character in UCD entries

These changes was commited to the Birdfont repository Mon, 25 May 2015 06:35:37 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 25 May 2015 06:35:37 +0000 (08:35 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 25 May 2015 06:35:37 +0000 (08:35 +0200)
commit 479c884a242f1a8cbfad7a0bc53ec9a5db0fa521
tree 65e60f629cfa892b4bab7c7075600e8ca8fcfdb1
parent e1a0a67c7f5be6fbb37ad24d2cef37670954f0e7
Show fallback character in UCD entries

libbirdfont/CharacterInfo.vala
libbirdfont/OverView.vala
libbirdfont/OverViewItem.vala
libbirdfont/Renderer/FallbackFont.vala
libbirdfont/Renderer/Text.vala
--- a/libbirdfont/CharacterInfo.vala +++ b/libbirdfont/CharacterInfo.vala @@ -18,11 +18,12 @@ /** 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 = "";
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -63,6 +63,7 @@ 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 @@ 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 @@ 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 @@ 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 (); }
--- a/libbirdfont/OverViewItem.vala +++ b/libbirdfont/OverViewItem.vala @@ -266,22 +266,22 @@ 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) {
--- a/libbirdfont/Renderer/FallbackFont.vala +++ b/libbirdfont/Renderer/FallbackFont.vala @@ -83,7 +83,7 @@ } // control characters - if (c <= 0x001f) { + if (c <= 0x001f || (0x007f <= c <= 0x008d)) { return bf_font; }
--- a/libbirdfont/Renderer/Text.vala +++ b/libbirdfont/Renderer/Text.vala @@ -182,7 +182,6 @@ iter (glyph, kern, i + 1 == word_with_ligatures.glyph.size); prev = g; wi++; - } } @@ -300,7 +299,11 @@ } 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); }