Commit ae49c16
Merge branch 'master' of github.com:johanmattssonm/birdfont
Changed files (9)
modifiedREADME.mdmodifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/Menu.valamodifiedlibbirdfont/MoveTool.valamodifiedlibbirdfont/OverView.valamodifiedlibbirdfont/OverviewTools.valamodifiedlibbirdfont/PreviewTools.vala
Diff
@@ -21,7 +21,7 @@ packages with a -dev or -devel affix: libgee-0.8-dev libglib2.0-dev libgtk-3-dev - libwebkit2gtk-3.0-dev + libwebkit2gtk-4.0-dev libnotify-dev libsqlite3-dev libxmlbird-dev@@ -615,7 +615,7 @@ os.put_string ( File file = (!) File.new_for_path (ttf); File file_mac = (!) File.new_for_path (ttf_mac); - error_message = null; + error_message = null; try { fo.open (file, file_mac);@@ -626,7 +626,7 @@ os.put_string ( critical (@"$(e.message)"); error_message = e.message; f.export_directory = null;- } + } } static void write_eot (string ttf, string eot) {@@ -191,8 +191,21 @@ public class Font : GLib.Object { public string? get_export_directory () { #if MAC return export_directory;-#endif+#else return get_path ();+#endif+ }+ + public bool has_svg_glyph () {+ for (int glyph_index = 0; glyph_index < glyph_name.length (); glyph_index++) {+ GlyphCollection gc = glyph_name.nth (glyph_index);+ + if (gc.get_current ().has_svg_path ()) {+ return true;+ }+ }+ + return false; } public void add_default_characters () {@@ -184,6 +184,16 @@ public class Glyph : FontDisplay { warning ("Layer is not added to glyph."); } + public bool has_svg_path () {+ foreach (SvgBird.Object object in get_visible_objects ()) {+ if (object is EmbeddedSvg) {+ return true;+ }+ }+ + return false;+ }+ public Gee.ArrayList<SvgBird.Object> get_visible_objects () { return LayerUtils.get_visible_objects (layers); }@@ -287,9 +287,39 @@ public class Menu : AbstractMenu { MenuItem import_color_svg; import_color_svg = add_menu_item (t_("Import SVG file"),- "import svg file color", "Glyph");+ "import svg file color", ""); import_color_svg.action.connect (() => {+ FontDisplay current_display = MainWindow.get_current_display ();+ OverView overview = MainWindow.get_overview ();+ + if (current_display is OverView) {+ GlyphCollection? gc;+ + gc = overview.get_selected_item ().glyphs;+ + OverViewItem item = overview.get_selected_item ();+ + if (gc == null) {+ // ignore control characters+ if (item.character <= 0x1F) {+ show_menu = false;+ return;+ }+ + gc = overview.create_new_glyph (item.character, false);+ }++ GlyphCanvas canvas = MainWindow.get_glyph_canvas ();+ canvas.set_current_glyph_collection ((!) gc, false);+ }+ SvgParser.import (SvgType.COLOR);+ + if (current_display is OverView) {+ overview.reset_thumbnails ();+ GlyphCanvas.redraw ();+ }+ show_menu = false; }); export_menu.items.add (import_color_svg);@@ -526,6 +526,10 @@ public class MoveTool : Tool { } convert_objects_to_monochrome_glyph (glyph, embedded_paths);+ + glyph.add_help_lines ();+ glyph.fix_curve_orientation ();+ GlyphCanvas.redraw (); } @@ -541,6 +545,9 @@ public class MoveTool : Tool { } convert_objects_to_monochrome_glyph (glyph, embedded_paths);+ + glyph.add_help_lines ();+ glyph.fix_curve_orientation (); } public void convert_objects_to_monochrome_glyph (Glyph glyph, ObjectGroup embedded_paths) {@@ -186,7 +186,7 @@ public class OverView : FontDisplay { FontDisplay.dirty_scrollbar = true; } - public GlyphCollection create_new_glyph (unichar character) {+ public GlyphCollection create_new_glyph (unichar character, bool select_tab = true) { StringBuilder name = new StringBuilder (); TabBar tabs = MainWindow.get_tab_bar (); bool selected;@@ -204,7 +204,10 @@ public class OverView : FontDisplay { glyph_tab = new GlyphTab (glyph_collection); glyph = glyph_collection.get_current (); glyph.layers.add_layer (new Layer ());- tabs.add_tab (glyph_tab, true, glyph_collection);+ + if (select_tab) {+ tabs.add_tab (glyph_tab, true, glyph_collection);+ } selected_items.add (glyph_collection); @@ -518,7 +521,7 @@ public class OverView : FontDisplay { GlyphCanvas.redraw (); } - OverViewItem get_selected_item () {+ public OverViewItem get_selected_item () { if (visible_items.size == 0) { return new OverViewItem (); }@@ -682,6 +685,16 @@ public class OverView : FontDisplay { update_scheduled = false; } + public void reset_thumbnails () {+ for (int i = 0; i < visible_items.size; i++) {+ OverViewItem item = visible_items.get (i);+ item.clear_cache ();+ item.draw_glyph_from_font (); + }+ + update_item_list ();+ }+ public override void draw (WidgetAllocation allocation, Context cr) { if (update_scheduled || this.allocation.width != allocation.width@@ -1723,6 +1736,7 @@ public class OverView : FontDisplay { } g.insert_glyph (glyph, true);+ update_path_boundaries (glyph); i++; } @@ -1732,6 +1746,12 @@ public class OverView : FontDisplay { GlyphCanvas.redraw (); } + void update_path_boundaries (Glyph glyph) {+ foreach (Path p in glyph.get_all_paths ()) {+ p.update_region_boundaries ();+ }+ }+ public override bool needs_modifier () { return true; }@@ -1740,6 +1760,7 @@ public class OverView : FontDisplay { public AlternateSets alternate_sets = new AlternateSets (); public Gee.ArrayList<GlyphCollection> glyphs = new Gee.ArrayList<GlyphCollection> (); }+ } }@@ -1,5 +1,5 @@ /*- Copyright (C) 2014 2015 Johan Mattsson+ Copyright (C) 2014 2015 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 @@ -179,7 +179,9 @@ public class OverviewTools : ToolCollection { IdleSource idle = new IdleSource (); idle.set_callback (() => { self.set_selected (false);- BirdFont.get_current_font ().touch (); + BirdFont.get_current_font ().touch ();+ MainWindow.get_overview ().reset_thumbnails (); + GlyphCanvas.redraw (); return false; }); idle.attach (null);@@ -58,11 +58,18 @@ public class PreviewTools : ToolCollection { IdleSource idle = new IdleSource (); idle.set_callback (() => {+ Font font = BirdFont.get_current_font ();+ bool has_svg = font.has_svg_glyph ();+ + if (has_svg) {+ MainWindow.show_message (t_("SVG glyphs can't be viewed in preview."));+ }+ if (!Preview.has_html_document ()) { Preview.generate_html_document (); } - if (ExportTool.error_message == null) {+ if (ExportTool.error_message == null && !has_svg) { MainWindow.tabs.select_tab_name ("Preview"); }