The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Merge ../birdfont-2.x

These changes was commited to the Birdfont repository Sun, 12 Jun 2016 14:21:31 +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 14:21:31 +0000 (16:21 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 12 Jun 2016 14:25:55 +0000 (16:25 +0200)
commit b5b2aa07be9eb885f91f7bbce73b0d2308d5bc9d
tree 4d77cbca6c32283545d949c11671584f19684959
parent 88c2fcede7d946773fe0917213ef4b43189493cd
parent 70af65291434a4a4b6bd753583a44672d0027ba8
Merge ../birdfont-2.x

19 files changed:
libbirdfont/BackgroundTools.vala
libbirdfont/BirdFontFile.vala
libbirdfont/ClipTool.vala
libbirdfont/ExportSettings.vala
libbirdfont/Font.vala
libbirdfont/Glyph.vala
libbirdfont/GlyphMaster.vala
libbirdfont/LoadCallback.vala
libbirdfont/MainWindow.vala
libbirdfont/OpenFontFormat/GlyfData.vala
libbirdfont/OverView.vala
libbirdfont/Path.vala
libbirdfont/PointConverter.vala
libbirdfont/RecentFiles.vala
libbirdfont/TabBar.vala
libbirdfont/TestCases.vala
libbirdfont/Toolbox.vala
libbirdfont/VersionList.vala
--- a/libbirdfont/BackgroundTools.vala +++ b/libbirdfont/BackgroundTools.vala @@ -182,13 +182,13 @@ }); label.has_delete_button = true; parts.add_tool (label, 0); - - parts.redraw (); - parts.clear_cache (); + parts.redraw (); if (!is_null (MainWindow.get_toolbox ())) { - MainWindow.get_toolbox ().update_expanders (); - Toolbox.redraw_tool_box (); + MainWindow.get_toolbox ().update_expanders (); + parts.clear_cache (); + Toolbox.redraw_tool_box (); + GlyphCanvas.redraw (); } }
--- a/libbirdfont/BirdFontFile.vala +++ b/libbirdfont/BirdFontFile.vala @@ -26,7 +26,7 @@ Font font; public static const int FORMAT_MAJOR = 2; - public static const int FORMAT_MINOR = 2; + public static const int FORMAT_MINOR = 1; public static const int MIN_FORMAT_MAJOR = 0; public static const int MIN_FORMAT_MINOR = 0; @@ -343,8 +343,7 @@ os.put_string ("\n"); } - os.put_string (@"<background scale=\"$(font.background_scale)\" />\n"); - os.put_string (@"<conversion tolerance=\"$(font.tolerance)\" />\n"); + os.put_string (@"<background scale=\"$(font.background_scale)\" />\n"); } public void write_description (DataOutputStream os) throws GLib.Error { @@ -819,10 +818,6 @@ parse_background (t); } - if (t.get_name () == "conversion") { - parse_cubic_conversion (t); - } - if (t.get_name () == "postscript_name") { font.postscript_name = XmlParser.decode (t.get_content ()); } @@ -1191,18 +1186,6 @@ } catch (MarkupError e) { warning (e.message); } - } - - private void parse_cubic_conversion (Tag tag) { - string tolerance = "1"; - - foreach (Attribute attr in tag.get_attributes ()) { - if (attr.get_name () == "tolerance") { - tolerance = attr.get_content (); - } - } - - font.tolerance = parse_double (tolerance); } private void parse_background_image (Tag tag) {
--- a/libbirdfont/ClipTool.vala +++ b/libbirdfont/ClipTool.vala @@ -136,7 +136,8 @@ string data; return_if_fail (fd is GlyphTab); - destination = (Glyph) fd; + GlyphTab glyph_tab = (GlyphTab) fd; + destination = glyph_tab.glyphs.get_current (); ((!)destination).store_undo_state (); ((!)destination).clear_active_paths ();
--- a/libbirdfont/ExportSettings.vala +++ b/libbirdfont/ExportSettings.vala @@ -24,7 +24,6 @@ CheckBox ttf; CheckBox eot; CheckBox svg; - TextArea tolerance; Button export_action; Button name_tab; @@ -130,31 +129,6 @@ focus_ring.add (svg); svg.margin_bottom = 20 * MainWindow.units; - - widgets.add (new Text (t_("Conversion Tolerance"), label_size, label_margin)); - - tolerance = new LineTextArea (label_size); - tolerance.margin_bottom = 20 * MainWindow.units; - - tolerance.set_text (@"$(font.tolerance * 100.0)%"); - tolerance.text_changed.connect ((t) => { - Font f = BirdFont.get_current_font (); - string tolerance_percent = t.replace ("%", ""); - tolerance_percent = t.replace (",", "."); - tolerance_percent = t.replace (" ", ""); - double error_tolerance = double.parse (tolerance_percent); - - if (error_tolerance >= 100.0) { - f.tolerance = 1; - } else if (error_tolerance <= 0) { - f.tolerance = 0; - } else { - f.tolerance = error_tolerance / 100.0; - } - }); - - widgets.add (tolerance); - focus_ring.add (tolerance); name_tab = new Button (t_("Name and Description"), margin); name_tab.action.connect ((c) => {
--- a/libbirdfont/Font.vala +++ b/libbirdfont/Font.vala @@ -125,7 +125,6 @@ public int format_minor = 0; public int units_per_em = 1024; - public double tolerance = 1.0; public Font () { KerningClasses kerning_classes;
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -231,7 +231,7 @@ return (!) ttf_data; } - public PathList get_quadratic_paths (double tolerance) { + public PathList get_quadratic_paths () { PointConverter pc; PathList pl; PathList stroke; @@ -242,11 +242,11 @@ if (p.stroke > 0) { stroke = p.get_completed_stroke (); foreach (Path stroke_part in stroke.paths) { - pc = new PointConverter (stroke_part, tolerance); + pc = new PointConverter (stroke_part); pl.add (pc.get_quadratic_path ()); } } else { - pc = new PointConverter (p, tolerance); + pc = new PointConverter (p); pl.add (pc.get_quadratic_path ()); } }
--- a/libbirdfont/GlyphMaster.vala +++ b/libbirdfont/GlyphMaster.vala @@ -114,7 +114,6 @@ GlyphMaster n = new GlyphMaster (); foreach (Glyph g in glyphs) { - n.glyphs.add (g); n.glyphs.add (g); }
--- a/libbirdfont/LoadCallback.vala +++ b/libbirdfont/LoadCallback.vala @@ -85,8 +85,6 @@ f.delete_backup (); f = BirdFont.new_font (); - - MainWindow.clear_glyph_cache (); f.set_file ((!) fn); Preferences.add_recent_files ((!) fn);
--- a/libbirdfont/MainWindow.vala +++ b/libbirdfont/MainWindow.vala @@ -221,16 +221,6 @@ public static bool select_tab (Tab t) { return tabs.selected_open_tab (t); - } - - public static OverView get_overview () { - foreach (Tab t in tabs.tabs) { - if (t.get_display () is OverView) { - return (OverView) t.get_display (); - } - } - - return overview; } public static SpacingClassTab get_spacing_class_tab () { @@ -280,21 +270,6 @@ if (!is_null (MainWindow.native_window)) { MainWindow.native_window.set_scrollbar_position (position); } - } - - /** 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 GlyphTab) { - tab = (GlyphTab) t.get_display (); - g = tab.glyphs.get_current (); - g.add_help_lines (); - } - } - - GlyphCanvas.redraw (); } public static void close_all_tabs () { @@ -348,8 +323,12 @@ public static void set_toolbox (Toolbox tb) { tools = tb; + } + + public static OverView get_overview () { + return overview; } } }
--- a/libbirdfont/OpenFontFormat/GlyfData.vala +++ b/libbirdfont/OpenFontFormat/GlyfData.vala @@ -58,12 +58,11 @@ public GlyfData (Glyph g) { bool process; - Font font = OpenFontFormatWriter.get_current_font (); - PathList quadratic_path = g.get_quadratic_paths (font.tolerance); + PathList qp = g.get_quadratic_paths (); glyph = g; - foreach (Path p in quadratic_path.paths) { + foreach (Path p in qp.paths) { if (p.points.size > 0) { if (!is_empty (p)) { // Add points at extrema @@ -77,7 +76,7 @@ while (process) { points.clear (); paths.clear (); - foreach (Path p in quadratic_path.paths) { + foreach (Path p in qp.paths) { if (!is_empty (p)) { paths.add (p); foreach (EditPoint ep in p.points) {
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 2014 2015 Johan Mattsson + Copyright (C) 2012 - 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 @@ -96,7 +96,7 @@ bool selected = tabs.select_char (n); GlyphCanvas canvas; Glyph g = glyph_collection.get_current (); - GlyphTab glyph_tab; + GlyphTab glyph_tab; if (!selected) { glyph_tab = new GlyphTab (glyph_collection); @@ -1045,8 +1045,10 @@ } store_undo_items (undo_item); - foreach (GlyphCollection gc in selected_items) { - font.delete_glyph (gc); + foreach (GlyphCollection glyph_collection in selected_items) { + font.delete_glyph (glyph_collection); + string name = glyph_collection.get_name (); + MainWindow.get_tab_bar ().close_background_tab_by_name (name); } update_item_list (); @@ -1096,7 +1098,6 @@ font.delete_glyph (g); font.add_glyph_collection (g); } - font.alternates = previous_collection.alternate_sets.copy (); redo_items.remove_at (redo_items.size - 1); @@ -1193,12 +1194,12 @@ if (all_available) { // don't search for glyphs in huge CJK fonts - if (font.length () > 300) { + if (font.length () > 500) { r = 0; } else { // FIXME: too slow for (r = 0; r < font.length (); r += items_per_row) { - for (i = 0; i < items_per_row; i++) { + for (i = 0; i < items_per_row && i < font.length (); i++) { glyphs = font.get_glyph_collection_index ((uint32) r + i); return_if_fail (glyphs != null); glyph = ((!) glyphs).get_current (); @@ -1235,6 +1236,7 @@ if (index > -1) { first_visible = r; + process_item_list_update (); update_item_list (); select_visible_glyph (ch); }
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -309,13 +309,16 @@ y = Glyph.yc () - top.y - sin (angle + PI / 2) * 10 * Glyph.ivz (); if (points.size > 0) { - cr.save (); - cr.translate (x, y); double inverted_zoom = Glyph.ivz (); - cr.rotate (-angle); - cr.translate (-x, -y); + double zoom = 1 / inverted_zoom; cr.scale (inverted_zoom, inverted_zoom); - arrow_icon.draw_at_baseline (cr, x, y); + + cr.save (); + cr.translate (x * zoom, y * zoom); + cr.rotate (-angle); + cr.translate (-x * zoom, -y * zoom); + + arrow_icon.draw_at_baseline (cr, x * zoom, y * zoom); cr.restore (); } } @@ -1204,9 +1207,9 @@ /** Convert quadratic bezier points to cubic representation of the glyph * for ttf-export. */ - public Path get_quadratic_points (double tolerance) { + public Path get_quadratic_points () { PointConverter converter; - converter = new PointConverter (this, tolerance); + converter = new PointConverter (this); return converter.get_quadratic_path (); }
--- a/libbirdfont/PointConverter.vala +++ b/libbirdfont/PointConverter.vala @@ -22,11 +22,9 @@ Path original_path; Path quadratic_path; - double error_tolerance = 1; - public PointConverter (Path path, double tolerance) { + public PointConverter (Path path) { original_path = path; - error_tolerance = tolerance; } public Path get_quadratic_path () { @@ -111,7 +109,7 @@ out distance, out e, out step); } - if (distance > 0.1 + 0.1 * error_tolerance) { // range 0.1 - 0.4, + if (distance > 0.2) { // range 0.1 - 0.4, quadratic_path.insert_new_point_on_path (e); points_in_segment++; size += 2; // the new point + segment start
--- a/libbirdfont/RecentFiles.vala +++ b/libbirdfont/RecentFiles.vala @@ -240,7 +240,6 @@ f = BirdFont.new_font (); - MainWindow.clear_glyph_cache (); MainWindow.close_all_tabs (); f.set_file (fn);
--- a/libbirdfont/TabBar.vala +++ b/libbirdfont/TabBar.vala @@ -21,7 +21,7 @@ public int width = 0; public int height = 0; - public Gee.ArrayList<Tab> tabs; + private Gee.ArrayList<Tab> tabs; static const int NO_TAB = -1; static const int NEXT_TAB = -2; @@ -328,9 +328,11 @@ public bool close_by_name (string name, bool background_tab = false) { int i = 0; - foreach (var t in tabs) { - if (t.get_display ().get_name () == name) { - return close_tab (i, background_tab); + foreach (Tab tab in tabs) { + if (tab.get_display ().get_name () == name) { + bool closed = close_tab (i, background_tab); + redraw_tab_bar (0, 0, width, height); + return closed; } i++; @@ -466,8 +468,7 @@ t = tabs.get (index); previous_tab = current_tab; current_tab = t; - - scroll_to_tab (selected, signal_selected); + scroll_to_tab (selected, signal_selected); } private bool has_scroll () { @@ -579,8 +580,8 @@ public void add_tab (FontDisplay display_item, bool signal_selected = true, GlyphCollection? gc = null) { double tab_width = -1; bool always_open = false; - int s = (tabs.size == 0) ? 0 : selected + 1; - Tab t; + int position = (tabs.size == 0) ? 0 : selected + 1; + Tab tab; if (MenuTab.has_suppress_event ()) { warn_if_test ("Event suppressed"); @@ -592,21 +593,21 @@ tab_width += 36; } - t = new Tab (display_item, tab_width, always_open); - tabs.insert (s,t); + tab = new Tab (display_item, tab_width, always_open); + tabs.insert (position, tab); if (gc != null) { - t.set_glyph_collection ((!) gc); + tab.set_glyph_collection ((!) gc); } - GlyphCanvas.set_display (t.get_display ()); + GlyphCanvas.set_display (tab.get_display ()); MainWindow.get_glyph_canvas () - .set_current_glyph_collection (t.get_glyph_collection ()); + .set_current_glyph_collection (tab.get_glyph_collection ()); - select_tab (s, signal_selected); + select_tab (position, signal_selected); } - + /** Returns true if the new item was added to the bar. */ public bool add_unique_tab (FontDisplay display_item, bool signal_selected = true) { bool i;
--- a/libbirdfont/TestCases.vala +++ b/libbirdfont/TestCases.vala @@ -592,7 +592,7 @@ g = MainWindow.get_current_glyph (); foreach (Path path in g.get_all_paths ()) { - paths.append (path.get_quadratic_points (1.0)); + paths.append (path.get_quadratic_points ()); paths.append (path.copy ()); } @@ -610,7 +610,7 @@ p.add (-10, -10); p.close (); g.add_path (p); - g.add_path (p1.get_quadratic_points (1.0)); + g.add_path (p1.get_quadratic_points ()); e0 = new EditPoint (20, 40); e1 = new EditPoint (40, 40); @@ -634,7 +634,7 @@ e3.process_tied_handle (); g.add_path (p1); - g.add_path (p1.get_quadratic_points (1.0)); + g.add_path (p1.get_quadratic_points ()); foreach (Path path in paths) { g.add_path (path);
--- a/libbirdfont/Toolbox.vala +++ b/libbirdfont/Toolbox.vala @@ -126,6 +126,9 @@ } else if (tab_name == "Themes") { current_set = (ToolCollection) theme_tools; } else if (t != null && ((!) t).get_display () is GlyphTab) { + current_set = (ToolCollection) drawing_tools; + } else if (t != null && ((!) t).get_display () is Glyph) { + warning ("Expecting GlyphTab instead of Glyph."); current_set = (ToolCollection) drawing_tools; } else { current_set = (ToolCollection) file_tools;
--- a/libbirdfont/VersionList.vala +++ b/libbirdfont/VersionList.vala @@ -94,6 +94,8 @@ if (glyphs.size == 1) { over_view.store_undo_state (glyph_collection.copy ()); font.delete_glyph (glyph_collection); + string name = glyph_collection.get_name (); + MainWindow.get_tab_bar ().close_background_tab_by_name (name); return; } @@ -238,7 +240,8 @@ continue; } - glyph = (Glyph) tab.get_display (); + GlyphTab glyph_tab = (GlyphTab) tab.get_display (); + glyph = glyph_tab.glyphs.get_current (); uni.truncate (0); uni.append_unichar (glyph.unichar_code); ug = font.get_glyph (uni.str); @@ -248,7 +251,7 @@ } updated_glyph = (!) ug; - tab.set_display (updated_glyph); + tab.set_display (glyph_tab); updated_glyph.view_zoom = glyph.view_zoom; updated_glyph.view_offset_x = glyph.view_offset_x; updated_glyph.view_offset_y = glyph.view_offset_y;