The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Insert specia characters in spacing classes

These changes was commited to the Birdfont repository Sun, 12 Jun 2016 18:41:29 +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>
Sun, 12 Jun 2016 18:41:29 +0000 (20:41 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 12 Jun 2016 18:41:29 +0000 (20:41 +0200)
commit 8ac186c2ebe4f76a5b19d94bdcad4a7d7b533815
tree 0f4e281c0c7d77361b6568f47888feb1ec7d68e7
parent 2728472658f14d107bb801bd7b4e7bce3492c0a9
Insert specia characters in spacing classes

libbirdfont/SpacingClass.vala
libbirdfont/SpacingClassTab.vala
libbirdfont/SpacingClassTools.vala [new ]
libbirdfont/Toolbox.vala
--- a/libbirdfont/SpacingClass.vala +++ b/libbirdfont/SpacingClass.vala @@ -39,6 +39,11 @@ public void set_next () { update_first = false; update (next); + } + + public void update_class (string value, bool first) { + update_first = first; + update (value); } void update (string val) { @@ -48,7 +53,7 @@ string v = text; if (v.has_prefix ("U+") || v.has_prefix ("u+")) { - v = (!) Font.to_unichar (val).to_string (); + v = ((!) Font.to_unichar (val).to_string ()).dup (); } if (update_first) {
--- a/libbirdfont/SpacingClassTab.vala +++ b/libbirdfont/SpacingClassTab.vala @@ -20,8 +20,11 @@ public static int NEW_CLASS = -1; Gee.ArrayList<Row> rows = new Gee.ArrayList<Row> (); + public static SpacingClass current_class; + public static bool current_class_first_element; public SpacingClassTab () { + current_class = new SpacingClass ("", ""); } public override Gee.ArrayList<Row> get_rows () { @@ -51,11 +54,13 @@ warning (@"Index: $(row.get_index ()) classes.size: $(spacing.classes.size)"); return; } - spacing.classes.get (row.get_index ()).set_first (); + current_class = spacing.classes.get (row.get_index ()); + current_class.set_first (); font.touch (); } else if (column == 2) { return_if_fail (0 <= row.get_index () < spacing.classes.size); - spacing.classes.get (row.get_index ()).set_next (); + current_class = spacing.classes.get (row.get_index ()); + current_class .set_next (); font.touch (); } }
--- /dev/null +++ b/libbirdfont/SpacingClassTools.vala @@ -1,1 +1,57 @@ + /* + Copyright (C) 2016 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 + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + */ + + using Cairo; + using Math; + + namespace BirdFont { + + public class SpacingClassTools : ToolCollection { + public static Gee.ArrayList<Expander> expanders; + + public SpacingClassTools () { + Expander spacing_class_tools = new Expander (); + Tool insert = new Tool ("insert_glyph_from_overview_in_spacing_class", t_("Insert glyph from overview")); + + insert.set_icon ("insert_glyph_from_overview"); + + insert.select_action.connect ((self) => { + GlyphSelection glyph_selection = new GlyphSelection (); + + glyph_selection.selected_glyph.connect ((glyph_collection) => { + SpacingClassTab.current_class.update_class (glyph_collection.get_name (), + SpacingClassTab.current_class_first_element); + MainWindow.get_tab_bar ().select_tab_name ("SpacingClasses"); + }); + + GlyphCanvas.set_display (glyph_selection); + self.set_selected (false); + }); + spacing_class_tools.add_tool (insert); + } + + public override Gee.ArrayList<Expander> get_expanders () { + return expanders; + } + + public override Gee.ArrayList<string> get_displays () { + Gee.ArrayList<string> d = new Gee.ArrayList<string> (); + d.add ("SpacingClasses"); + return d; + } + + } + + }
--- a/libbirdfont/Toolbox.vala +++ b/libbirdfont/Toolbox.vala @@ -27,6 +27,7 @@ public static OverviewTools overview_tools; public static BackgroundTools background_tools; public static SpacingTools spacing_tools; + public static SpacingClassTools spacing_class_tools; public static FileTools file_tools; public static ThemeTools theme_tools; @@ -64,6 +65,7 @@ overview_tools = new OverviewTools (); background_tools = new BackgroundTools (); spacing_tools = new SpacingTools (); + spacing_class_tools = new SpacingClassTools (); file_tools = new FileTools (); theme_tools = new ThemeTools (); @@ -74,6 +76,7 @@ tool_sets.add (kerning_tools); tool_sets.add (preview_tools); tool_sets.add (overview_tools); + tool_sets.add (spacing_class_tools); tool_sets.add (background_tools); // the menu has all the file_tools commands, it will not be added here tool_sets.add (hidden_tools); // tools without a button