The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Merge ../birdfont-2.x

These changes was commited to the Birdfont repository Sat, 11 Jun 2016 10:02:49 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sat, 11 Jun 2016 10:02:49 +0000]

Updated Files

libbirdfont/AbstractMenu.vala
libbirdfont/ClipTool.vala
libbirdfont/DrawingTools.vala
libbirdfont/Glyph.vala
libbirdfont/GlyphRange.vala
libbirdfont/GlyphTab.vala
libbirdfont/KerningClasses.vala
libbirdfont/MainWindow.vala
libbirdfont/OverView.vala
libbirdfont/OverViewItem.vala
libbirdfont/Path.vala
libbirdfont/PointConverter.vala
libbirdfont/SpacingClass.vala
libbirdfont/SpacingData.vala
libbirdfont/TabContent.vala
libbirdfont/Toolbox.vala
libbirdfont/VersionList.vala
--- a/libbirdfont/AbstractMenu.vala +++ b/libbirdfont/AbstractMenu.vala @@ -83,7 +83,7 @@ display = current_display.get_name (); - if (current_display is Glyph) { + if (current_display is GlyphTab) { display = "Glyph"; }
--- a/libbirdfont/ClipTool.vala +++ b/libbirdfont/ClipTool.vala @@ -34,7 +34,7 @@ string bf_data; string data; - if (fd is Glyph) { + if (fd is GlyphTab) { svg_data = ExportTool.export_selected_paths_to_svg (); bf_data = export_selected_paths_to_birdfont_clipboard (); @@ -89,7 +89,7 @@ double x, y, w, h; double dx, dy; - if (fd is Glyph) { + if (fd is GlyphTab) { paste_paths (false); g.selection_boundaries (out x, out y, out w, out h); @@ -117,7 +117,7 @@ // Determine if clipboard contains data in birdfont format. is_bf_clipboard = clipboard_data.index_of ("BirdFontClipboard") > -1; - if (fd is Glyph) { + if (fd is GlyphTab) { paste_to_glyph (is_bf_clipboard, paste_guide_lines); } @@ -134,7 +134,7 @@ FontDisplay fd = MainWindow.get_current_display (); Glyph? destination = null; string data; - return_if_fail (fd is Glyph); + return_if_fail (fd is GlyphTab); destination = (Glyph) fd; ((!)destination).store_undo_state ();
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -685,7 +685,7 @@ }); bg_selection.select_action.connect((self) => { - if (MainWindow.get_current_display () is Glyph) { + if (MainWindow.get_current_display () is GlyphTab) { BackgroundTool.import_background_image (); } }); @@ -1255,9 +1255,11 @@ // update selelction when the user switches tab MainWindow.get_tab_bar ().signal_tab_selected.connect((tab) => { Glyph glyph; + GlyphTab glyph_tab; - if (tab.get_display () is Glyph) { - glyph = (Glyph) tab.get_display (); + if (tab.get_display () is GlyphTab) { + glyph_tab = (GlyphTab) tab.get_display (); + glyph = glyph_tab.glyphs.get_current (); show_bg.set_selected (glyph.get_background_visible ()); update_line_selection (glyph); }
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -122,7 +122,7 @@ Line left_line; Line right_line; - /** Cache for Cairo rendering */ + /** Cache for Cairo surface rendering */ HashMap<string, Surface> glyph_cache = new HashMap<string, Surface> (); public const double CANVAS_MIN = -10000;
--- a/libbirdfont/GlyphRange.vala +++ b/libbirdfont/GlyphRange.vala @@ -532,7 +532,9 @@ uns = unserialize (c); if (uns.char_count () != 1) { - warning (@"Expecting a single character got $c"); + // the glyph was not found by its name because it is not in the list of + // unassigned characters + return false; } s = uns.get_char ();
diff --git libbirdfont/GlyphTab.vala(new)
--- /dev/null +++ b/libbirdfont/GlyphTab.vala @@ -1,1 +1,156 @@ + /* + 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 GlyphTab : FontDisplay { + + public GlyphCollection glyphs; + + public GlyphTab (GlyphCollection glyphs) { + this.glyphs = glyphs; + } + + public override string get_name () { + return glyphs.get_current ().get_name (); + } + + public override string get_label () { + return glyphs.get_current ().get_label (); + } + + public override void close () { + glyphs.get_current ().close (); + } + + public override bool has_scrollbar () { + return glyphs.get_current ().has_scrollbar (); + } + + public override void update_scrollbar () { + glyphs.get_current ().update_scrollbar (); + } + + public override void scroll_to (double percent) { + glyphs.get_current ().scroll_to (percent); + } + + public override void draw (WidgetAllocation allocation, Context cr) { + glyphs.get_current ().draw (allocation, cr); + } + + public override void selected_canvas () { + glyphs.get_current ().selected_canvas (); + } + + public override void key_press (uint keyval) { + glyphs.get_current ().key_press (keyval); + } + + public override void key_release (uint keyval) { + glyphs.get_current ().key_release (keyval); + } + + public override void motion_notify (double x, double y) { + glyphs.get_current ().motion_notify (x, y); + } + + public override void button_release (int button, double x, double y) { + glyphs.get_current ().button_release (button, x, y); + } + + public override void button_press (uint button, double x, double y) { + glyphs.get_current ().button_press (button, x, y); + } + + public override void double_click (uint button, double ex, double ey) { + glyphs.get_current ().double_click (button, ex, ey); + } + + public override void magnify (double magnification) { + glyphs.get_current ().magnify (magnification); + } + + public override void tap_down (int finger, int x, int y) { + glyphs.get_current ().tap_down (finger, x, y); + } + + public override void tap_up (int finger, int x, int y) { + glyphs.get_current ().tap_up (finger, x, y); + } + + public override void tap_move (int finger, int x, int y) { + glyphs.get_current ().tap_move (finger, x, y); + } + + public override void zoom_in () { + glyphs.get_current ().zoom_in (); + } + + public override void zoom_out () { + glyphs.get_current ().zoom_out (); + } + + public override void zoom_max () { + glyphs.get_current ().zoom_max (); + } + + public override void zoom_min () { + glyphs.get_current ().zoom_min (); + } + + public override void move_view (double x, double y) { + glyphs.get_current ().move_view (x, y); + } + + public override void reset_zoom () { + glyphs.get_current ().reset_zoom (); + } + + public override void store_current_view () { + glyphs.get_current ().store_current_view (); + } + + public override void restore_last_view () { + glyphs.get_current ().restore_last_view (); + } + + public override void next_view () { + glyphs.get_current ().next_view (); + } + + public override void scroll_wheel (double x, double y, + double pixeldelta_x, double pixeldelta_y) { + glyphs.get_current ().scroll_wheel (x, y, pixeldelta_x, pixeldelta_y); + } + + public override void undo () { + glyphs.get_current ().undo (); + } + + public override void redo () { + glyphs.get_current ().redo (); + } + + /** returns false if bindings to a single key works in the display. */ + public override bool needs_modifier () { + return glyphs.get_current ().needs_modifier (); + } + } + + }
--- a/libbirdfont/KerningClasses.vala +++ b/libbirdfont/KerningClasses.vala @@ -78,6 +78,27 @@ warning (e.message); } } + } + + /** Copy kerning pairs for newly created spacing classes. */ + public void copy_single_kerning_pairs (string from_spacing_class, string to_spacing_class) { + double? kerning; + + foreach (string left in single_kerning_letters_left) { + kerning = get_kerning_for_single_glyphs (left, from_spacing_class); + + if (kerning != null) { + set_kerning_for_single_glyphs (left, to_spacing_class, (!) kerning); + } + } + + foreach (string right in single_kerning_letters_right) { + kerning = get_kerning_for_single_glyphs (from_spacing_class, right); + + if (kerning != null) { + set_kerning_for_single_glyphs (to_spacing_class, right, (!) kerning); + } + } } /** Class based gpos kerning. */ @@ -125,36 +146,21 @@ } return 0; - } - - public void update_space_class (string c) { - double? k; - - foreach (string l in single_kerning_letters_left) { - k = get_kerning_for_single_glyphs (l, c); - - if (k != null) { - set_kerning_for_single_glyphs (l, c, (!) k); - } - } - - foreach (string r in single_kerning_letters_right) { - k = get_kerning_for_single_glyphs (c, r); - - if (k != null) { - set_kerning_for_single_glyphs (c, r, (!) k); - } - } } public double? get_kerning_for_single_glyphs (string first, string next) { double? k = null; + double? kerning = null; string left = GlyphRange.serialize (first); string right = GlyphRange.serialize (next); foreach (string l in get_spacing_class (left)) { foreach (string r in get_spacing_class (right)) { - k = single_kerning.get (@"$l - $r"); + kerning = single_kerning.get (@"$l - $r"); + + if (kerning != null) { + k = kerning; + } } }
--- a/libbirdfont/MainWindow.vala +++ b/libbirdfont/MainWindow.vala @@ -285,9 +285,11 @@ /** Reaload all paths and help lines from disk. */ public static void clear_glyph_cache () { Glyph g; + GlyphTab tab; foreach (Tab t in get_tab_bar ().tabs) { - if (t.get_display () is Glyph) { - g = (Glyph) t.get_display (); + if (t.get_display () is GlyphTab) { + tab = (GlyphTab) t.get_display (); + g = tab.glyphs.get_current (); g.add_help_lines (); } }
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -96,10 +96,12 @@ bool selected = tabs.select_char (n); GlyphCanvas canvas; Glyph g = glyph_collection.get_current (); + GlyphTab glyph_tab; if (!selected) { + glyph_tab = new GlyphTab (glyph_collection); canvas = MainWindow.get_glyph_canvas (); - tabs.add_tab (g, true, glyph_collection); + tabs.add_tab (glyph_tab, true, glyph_collection); canvas.set_current_glyph_collection (glyph_collection); set_initial_zoom (); PenTool.update_orientation (); @@ -184,6 +186,7 @@ Glyph glyph; GlyphCollection glyph_collection; GlyphCanvas canvas; + GlyphTab glyph_tab; glyph_collection = MainWindow.get_current_glyph_collection (); name.append_unichar (character); @@ -191,10 +194,10 @@ if (!selected) { glyph_collection = add_character_to_font (character); - + glyph_tab = new GlyphTab (glyph_collection); glyph = glyph_collection.get_current (); glyph.layers.add_layer (new Layer ()); - tabs.add_tab (glyph, true, glyph_collection); + tabs.add_tab (glyph_tab, true, glyph_collection); selected_items.add (glyph_collection);
--- a/libbirdfont/OverViewItem.vala +++ b/libbirdfont/OverViewItem.vala @@ -271,8 +271,8 @@ cr.set_line_width (1); cr.stroke (); cr.restore (); - - draw_thumbnail (cr, x, y + height); + + draw_thumbnail (cr, x, y + height); draw_caption (cr); draw_menu (cr); }
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -1471,7 +1471,7 @@ if (steps == -1) { steps = (int) (10 * get_length_from (start, stop)); - } + } if (right == PointType.DOUBLE_CURVE || left == PointType.DOUBLE_CURVE) { return all_of_double (start.x, start.y, start.get_right_handle ().x, start.get_right_handle ().y, stop.get_left_handle ().x, stop.get_left_handle ().y, stop.x, stop.y, iter, steps, min_t, max_t);
--- a/libbirdfont/PointConverter.vala +++ b/libbirdfont/PointConverter.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Johan Mattsson + Copyright (C) 2014 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 @@ -49,6 +49,8 @@ PenTool.convert_point_segment_type (e, e.get_next (), PointType.DOUBLE_CURVE); } } + + if (!original_path.is_open ()) { if (quadratic_path.get_last_point ().get_right_handle ().type == PointType.CUBIC) { @@ -93,8 +95,9 @@ quadratic_segment_start = segment_start.copy (); quadratic_segment_stop = segment_stop.copy (); - PenTool.convert_point_segment_type (quadratic_segment_start, quadratic_segment_stop, PointType.DOUBLE_CURVE); - + PenTool.convert_point_segment_type (quadratic_segment_start, quadratic_segment_stop, PointType.DOUBLE_CURVE); + + // add new points to estimate path distance = 0; e = new EditPoint (); if (segment_start.get_right_handle ().is_line () @@ -124,7 +127,7 @@ out double distance, out EditPoint new_point, out double step) { double max_d; double min_d; - int steps = (int) (1.6 * Path.get_length_from (a0, a1)); + int steps; double x_out, y_out; double step_out;
--- a/libbirdfont/SpacingClass.vala +++ b/libbirdfont/SpacingClass.vala @@ -56,12 +56,11 @@ } else { next = v.dup (); } - - updated (this); }); listener.signal_submit.connect (() => { TabContent.hide_text_input (); + updated (this); }); TabContent.show_text_input (listener);
--- a/libbirdfont/SpacingData.vala +++ b/libbirdfont/SpacingData.vala @@ -83,11 +83,11 @@ } public void add_class (string first, string next) { - SpacingClass s = new SpacingClass (first, next); - s.updated.connect (update_all_rows); - s.updated.connect (update_kerning); - classes.add (s); - update_kerning (s); + SpacingClass spacing_class = new SpacingClass (first, next); + spacing_class.updated.connect (update_all_rows); + spacing_class.updated.connect (update_kerning); + classes.add (spacing_class); + update_kerning (spacing_class); } void update_all_rows (SpacingClass s) { @@ -103,14 +103,18 @@ return; } - kerning_classes.update_space_class (s.next); + if (s.next == "" || s.first == "") { + return; + } + + kerning_classes.copy_single_kerning_pairs (s.first, s.next); + g = font.get_glyph_collection (s.next); if (g != null) { gc = (!) g; gc.get_current ().update_spacing_class (); } - kerning_classes.update_space_class (s.first); g = font.get_glyph_collection (s.first); if (g != null) { gc = (!) g;
--- a/libbirdfont/TabContent.vala +++ b/libbirdfont/TabContent.vala @@ -439,7 +439,7 @@ TabContent.key_release (Key.LOGO_LEFT); TabContent.key_release (Key.LOGO_RIGHT); - if (MainWindow.get_current_display () is Glyph) { + if (MainWindow.get_current_display () is GlyphTab) { TabContent.key_release ((uint) ' '); } }
--- a/libbirdfont/Toolbox.vala +++ b/libbirdfont/Toolbox.vala @@ -125,7 +125,7 @@ current_set = (ToolCollection) background_tools; } else if (tab_name == "Themes") { current_set = (ToolCollection) theme_tools; - } else if (t != null && ((!) t).get_display () is Glyph) { + } else if (t != null && ((!) t).get_display () is GlyphTab) { current_set = (ToolCollection) drawing_tools; } else { current_set = (ToolCollection) file_tools;
--- a/libbirdfont/VersionList.vala +++ b/libbirdfont/VersionList.vala @@ -234,7 +234,7 @@ tab = (!) tn; - if (! (tab.get_display () is Glyph)) { + if (! (tab.get_display () is GlyphTab)) { continue; }