The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

SpacingTools.vala in /libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Circle boundaries heads/master
1 /* 2 Copyright (C) 2015 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Cairo; 16 using Math; 17 18 namespace BirdFont { 19 20 public class SpacingTools : ToolCollection { 21 public static Gee.ArrayList<Expander> expanders; 22 23 public static ZoomBar zoom_bar; 24 25 public SpacingTools () { 26 expanders = new Gee.ArrayList<Expander> (); 27 28 Expander font_name = new Expander (); 29 font_name.add_tool (new FontName ()); 30 31 Expander zoom_expander = new Expander (t_("Font Size")); 32 33 zoom_bar = new ZoomBar (); 34 zoom_bar.new_zoom.connect ((z) => { 35 Font f; 36 37 KerningTools.font_size = 3 * z; 38 39 if (KerningTools.font_size < 0.1) { 40 KerningTools.font_size = 0.1; 41 } 42 43 f = BirdFont.get_current_font (); 44 f.settings.set_setting ("spacing_zoom", @"$z"); 45 46 GlyphCanvas.redraw (); 47 }); 48 zoom_expander.add_tool (zoom_bar); 49 50 Expander spacing_tools_expander = new Expander (); 51 52 Tool insert_last = new Tool ("insert_glyph_from_overview", t_("Insert glyph from overview")); 53 insert_last.select_action.connect ((self) => { 54 SpacingTab d = MainWindow.get_spacing_tab (); 55 GlyphSelection gs = new GlyphSelection (); 56 57 gs.selected_glyph.connect ((gc) => { 58 d.inser_glyph (gc.get_current ()); 59 MainWindow.get_tab_bar ().select_tab_name ("Spacing"); 60 }); 61 62 GlyphCanvas.set_display (gs); 63 self.set_selected (false); 64 }); 65 spacing_tools_expander.add_tool (insert_last); 66 67 Tool insert_unicode = new Tool ("insert_unichar", t_("Insert character by unicode value")); 68 insert_unicode.select_action.connect ((self) => { 69 SpacingTab d = MainWindow.get_spacing_tab (); 70 d.insert_unichar (); 71 self.set_selected (false); 72 }); 73 spacing_tools_expander.add_tool (insert_unicode); 74 75 spacing_tools_expander.add_tool (KerningTools.previous_kerning_string); 76 spacing_tools_expander.add_tool (KerningTools.next_kerning_string); 77 78 expanders.add (font_name); 79 expanders.add (zoom_expander); 80 expanders.add (spacing_tools_expander); 81 } 82 83 public override Gee.ArrayList<string> get_displays () { 84 Gee.ArrayList<string> d = new Gee.ArrayList<string> (); 85 d.add ("Spacing"); 86 return d; 87 } 88 89 public override Gee.ArrayList<Expander> get_expanders () { 90 return expanders; 91 } 92 } 93 94 } 95