The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Insert characters by unicode value in kerning tab

These changes was commited to the Birdfont repository Sun, 05 Oct 2014 15:37:35 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sun, 05 Oct 2014 15:37:35 +0000]

Updated Files

icons/insert_unichar.png
libbirdfont/KerningDisplay.vala
libbirdfont/KerningTools.vala
diff --git icons/insert_unichar.png(new)
--- /dev/null +++ b/icons/insert_unichar.png @@ -1,1 +1,4 @@ - + PNG +  + IHDR/'sBIT|d pHYs0}0}K@OtEXtSoftwarewww.inkscape.org<(IDATX=Pܹ bˆ̀Z ~(v s"ZX, 6 + gBďfAq+̵z͝L0 7/I.I "]౷눪~ Vu<hyu*SX`MlfUZvZk8!iwtf{E ȼadޯ2|Yɧ̓vy3jKOk/Rc*M뵭GDm'sE$I\|7kιFqcι7EcLZ~zC_o?@4o+JQ8/8^GU=b^}<DJ0Go>6*s^zu Y$o;Uݜ4. w_DNH,{cTu 9 <`io49 nvZ_D 5}~Q՟;c7POU}-`x&k<ad|uGUQU}/@yց˪\B_n"p,k๪`v"wRIENDB`
--- a/libbirdfont/KerningDisplay.vala +++ b/libbirdfont/KerningDisplay.vala @@ -584,44 +584,87 @@ if (suppress_input) { return; - } - - if (keyval == Key.LEFT && KeyBindings.modifier == NONE) { - first_update = true; - set_space (selected_handle, -1 / KerningTools.font_size); - } - - if (keyval == Key.RIGHT && KeyBindings.modifier == NONE) { - first_update = true; - set_space (selected_handle, 1 / KerningTools.font_size); } - if (KeyBindings.modifier == CTRL && (keyval == Key.LEFT || keyval == Key.RIGHT)) { - if (keyval == Key.LEFT) { - selected_handle--; + if (keyval == 'u' || keyval == 'U' && KeyBindings.has_ctrl ()) { + insert_unichar (); + } else { + if (keyval == Key.LEFT && KeyBindings.modifier == NONE) { + first_update = true; + set_space (selected_handle, -1 / KerningTools.font_size); } - if (keyval == Key.RIGHT) { - selected_handle++; + if (keyval == Key.RIGHT && KeyBindings.modifier == NONE) { + first_update = true; + set_space (selected_handle, 1 / KerningTools.font_size); + } + + if (KeyBindings.modifier == CTRL && (keyval == Key.LEFT || keyval == Key.RIGHT)) { + if (keyval == Key.LEFT) { + selected_handle--; + } + + if (keyval == Key.RIGHT) { + selected_handle++; + } + + set_selected_handle (selected_handle); } - set_selected_handle (selected_handle); + if (KeyBindings.modifier == NONE || KeyBindings.modifier == SHIFT) { + if (keyval == Key.BACK_SPACE && row.size > 0 && row.get (0).glyph.size > 0) { + row.get (0).glyph.remove_at (row.get (0).glyph.size - 1); + row.get (0).ranges.remove_at (row.get (0).ranges.size - 1); + } + + if (row.size == 0 || c == Key.ENTER) { + new_line (); + } + + add_character (c); + } } - if (KeyBindings.modifier == NONE || KeyBindings.modifier == SHIFT) { - if (keyval == Key.BACK_SPACE && row.size > 0 && row.get (0).glyph.size > 0) { - row.get (0).glyph.remove_at (row.get (0).glyph.size - 1); - row.get (0).ranges.remove_at (row.get (0).ranges.size - 1); - } + GlyphCanvas.redraw (); + } + + public void insert_unichar () { + TextListener listener; + string submitted_value = ""; + string unicodestart; + + unicodestart = (KeyBindings.has_shift ()) ? "" : "U+"; + + listener = new TextListener (t_("Unicode"), unicodestart, t_("Insert")); + + listener.signal_text_input.connect ((text) => { + submitted_value = text; - if (row.size == 0 || c == Key.ENTER) { - new_line (); + if (MenuTab.suppress_event) { + return; } - add_character (c); - } + GlyphCanvas.redraw (); + }); - GlyphCanvas.redraw (); + listener.signal_submit.connect (() => { + unichar c; + MainWindow.native_window.hide_text_input (); + + text_input = false; + suppress_input = false; + + if (submitted_value.has_prefix ("u+") || submitted_value.has_prefix ("U+")) { + c = Font.to_unichar (submitted_value); + add_character (c); + } else { + add_text (submitted_value); + } + }); + + suppress_input = true; + text_input = true; + MainWindow.native_window.set_text_listener (listener); } public void new_line () { @@ -809,7 +852,7 @@ text_input = true; MainWindow.native_window.set_text_listener (listener); - GlyphCanvas.redraw (); + GlyphCanvas.redraw (); } public override void button_press (uint button, double ex, double ey) {
--- a/libbirdfont/KerningTools.vala +++ b/libbirdfont/KerningTools.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Johan Mattsson + Copyright (C) 2013 2014 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -63,6 +63,13 @@ GlyphCanvas.redraw (); }); kerning_tools.add_tool (insert_last); + + Tool insert_unicode = new Tool ("insert_unichar", t_("Insert character by unicode value"), 'U', CTRL); + insert_unicode.select_action.connect ((self) => { + KerningDisplay d = MainWindow.get_kerning_display (); + d.insert_unichar (); + }); + kerning_tools.add_tool (insert_unicode); SpinButton font_size1 = new SpinButton ("kerning_font_size_one", t_("Font size"));