The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Editable .notdef character

These changes was commited to the Birdfont repository Thu, 24 Dec 2015 05:23:15 +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>
Thu, 24 Dec 2015 05:23:15 +0000 (06:23 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 24 Dec 2015 06:34:34 +0000 (07:34 +0100)
commit ee1c4ccfd873b6bd9077a8730e965c93d274e517
tree 5ced2d3d3822bb33df589317cf4546c1fdd0a2bb
parent 0e55d118e6b88857c78f56692a8f06b2b916f9ad
Editable .notdef character

libbirdfont/OpenFontFormat/GlyfTable.vala
libbirdfont/OverView.vala
libbirdfont/OverViewItem.vala
libbirdfont/OverviewTools.vala
--- a/libbirdfont/OpenFontFormat/GlyfTable.vala +++ b/libbirdfont/OpenFontFormat/GlyfTable.vala @@ -163,7 +163,7 @@ g.remove_empty_paths (); unassigned = gc.is_unassigned (); - if (unassigned) { + if (unassigned && gc.get_name () != ".notdef") { unassigned_glyphs.add (gc); }
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -102,6 +102,13 @@ canvas.set_current_glyph_collection (glyph_collection); set_initial_zoom (); PenTool.update_orientation (); + } + + if (glyph_collection.get_name () == ".notdef") { + Font font = BirdFont.get_current_font (); + if (!font.has_glyph (".notdef")) { + font.add_glyph_collection (glyph_collection); + } } }); @@ -519,7 +526,7 @@ public void process_item_list_update () { string character_string; - Font f = BirdFont.get_current_font (); + Font font = BirdFont.get_current_font (); GlyphCollection? glyphs = null; uint32 index; OverViewItem item; @@ -543,10 +550,11 @@ y = OverViewItem.margin; if (all_available) { - uint font_length = f.length (); + uint font_length = font.length (); + int i; - for (int i = 0; i < item_list_length && index < font_length; i++) { - glyphs = f.get_glyph_collection_index ((uint32) index); + for (i = 0; i < item_list_length && index < font_length; i++) { + glyphs = font.get_glyph_collection_index ((uint32) index); return_if_fail (glyphs != null); glyph = ((!) glyphs).get_current (); @@ -557,15 +565,19 @@ item.set_character (character); item.set_glyphs (glyphs); item.generate_graphics (); - item.x = x; - item.y = y; - - if (glyphs != null) { - item.selected = (selected_items.index_of ((!) glyphs) != -1); - } + item.selected = (selected_items.index_of ((!) glyphs) != -1); visible_items.add (item); index++; + } + + if (i < item_list_length && !font.has_glyph (".notdef")) { + item = new OverViewItem (); + item.set_glyphs (font.get_not_def_character ()); + item.generate_graphics (false); + item.version_menu = null; + item.selected = (selected_items.index_of ((!) glyphs) != -1); + visible_items.add (item); } } else { uint32 glyph_range_size = glyph_range.get_length (); @@ -593,7 +605,7 @@ visible_size = visible_items.size; for (int i = 0; i < visible_size; i++) { item = visible_items.get (i); - glyphs = f.get_glyph_collection_by_name ((!) item.character.to_string ()); + glyphs = font.get_glyph_collection_by_name ((!) item.character.to_string ()); item.set_glyphs (glyphs); if (glyphs != null) { @@ -669,9 +681,8 @@ void draw_empty_canvas (WidgetAllocation allocation, Context cr) { Text t; - cr.save (); - t = new Text (t_("No glyphs in this view."), 24); + t = new Text ("No glyphs in this view.", 24); Theme.text_color (t, "Text Foreground"); t.widget_x = 40; t.widget_y = 30; @@ -1315,7 +1326,8 @@ if (is_null(i.version_menu)) { update = true; } else { - update = !i.version_menu.menu_visible; + VersionList v = (!) i.version_menu; + update = !v.menu_visible; } } index++;
--- a/libbirdfont/OverViewItem.vala +++ b/libbirdfont/OverViewItem.vala @@ -42,7 +42,7 @@ public static double glyph_scale = 1.0; - public VersionList version_menu; + public VersionList? version_menu = null; Text label; private Surface? cache = null; @@ -63,19 +63,22 @@ glyphs = gc; } - public void generate_graphics () { - if (glyphs != null) { - version_menu = new VersionList ((!) glyphs); - version_menu.add_glyph_item.connect ((glyph) => { + public void generate_graphics (bool generate_versions = true) { + if (glyphs != null && generate_versions) { + VersionList versions = new VersionList ((!) glyphs); + + versions.add_glyph_item.connect ((glyph) => { ((!) glyphs).insert_glyph (glyph, true); }); - version_menu.signal_delete_item.connect ((glyph_index) => { + versions.signal_delete_item.connect ((glyph_index) => { OverView v = MainWindow.get_overview (); version_menu = new VersionList ((!) glyphs); v.update_item_list (); GlyphCanvas.redraw (); }); + + version_menu = versions; } info = new CharacterInfo (character, glyphs); @@ -236,16 +239,17 @@ GlyphCollection g; bool s = (x <= px <= x + width) && (y <= py <= y + height); - if (has_icons () && glyphs != null) { + if (has_icons () && glyphs != null && version_menu != null) { g = (!) glyphs; - version_menu.set_position (x + width - 21, y + height - 18); - a = version_menu.menu_item_action (px, py); // select one item on the menu + VersionList versions = (!) version_menu; + versions.set_position (x + width - 21, y + height - 18); + a = versions.menu_item_action (px, py); // select one item on the menu if (a) { return s; } - version_menu.menu_icon_action (px, py); // click in the open menu + versions.menu_icon_action (px, py); // click in the open menu } info.set_position (x + width - 17, y + height - 22.5); @@ -367,7 +371,10 @@ cc.fill (); if (has_icons ()) { - draw_menu_icon (cc, false); + if (version_menu != null) { + draw_menu_icon (cc, false); + } + draw_character_info_icon (cc); } @@ -464,7 +471,8 @@ public void hide_menu () { if (!is_null (version_menu)) { - version_menu.menu_visible = false; + VersionList v = (!) version_menu; + v.menu_visible = false; } } @@ -484,13 +492,23 @@ } private void draw_menu (Context cr) { - if (glyphs == null || !version_menu.menu_visible) { + if (glyphs == null) { + return; + } + + if (version_menu == null) { + return; + } + + VersionList v = (!) version_menu; + + if (!v.menu_visible) { return; } - version_menu.draw_menu (cr); + v.draw_menu (cr); } } }
--- a/libbirdfont/OverviewTools.vala +++ b/libbirdfont/OverviewTools.vala @@ -308,9 +308,16 @@ GlyphRange gr; uint size; OverView overview; - - // All characters - size = BirdFont.get_current_font ().length (); + Font font; + + // All characters including .notdef + font = BirdFont.get_current_font (); + size = font.length (); + + if (!font.has_glyph (".notdef")) { + size++; + } + all_glyphs.number = get_display_value (size); // Default