The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Merge branch 'master' of github.com:johanmattssonm/birdfont

These changes was commited to the Birdfont repository Tue, 10 Jan 2017 19:12:55 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Tue, 10 Jan 2017 19:12:55 +0000]

Updated Files

README.md
libbirdfont/ExportTool.vala
libbirdfont/Font.vala
libbirdfont/Glyph.vala
libbirdfont/Menu.vala
libbirdfont/MoveTool.vala
libbirdfont/OverView.vala
libbirdfont/OverviewTools.vala
libbirdfont/PreviewTools.vala
--- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ libgee-0.8-dev libglib2.0-dev libgtk-3-dev - libwebkit2gtk-3.0-dev + libwebkit2gtk-4.0-dev libnotify-dev libsqlite3-dev libxmlbird-dev
--- a/libbirdfont/ExportTool.vala +++ b/libbirdfont/ExportTool.vala @@ -615,7 +615,7 @@ 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 @@ critical (@"$(e.message)"); error_message = e.message; f.export_directory = null; - } + } } static void write_eot (string ttf, string eot) {
--- a/libbirdfont/Font.vala +++ b/libbirdfont/Font.vala @@ -191,8 +191,21 @@ 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 () {
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -182,6 +182,16 @@ } 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 () {
--- a/libbirdfont/Menu.vala +++ b/libbirdfont/Menu.vala @@ -287,9 +287,39 @@ 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);
--- a/libbirdfont/MoveTool.vala +++ b/libbirdfont/MoveTool.vala @@ -526,6 +526,10 @@ } convert_objects_to_monochrome_glyph (glyph, embedded_paths); + + glyph.add_help_lines (); + glyph.fix_curve_orientation (); + GlyphCanvas.redraw (); } @@ -541,6 +545,9 @@ } 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) {
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -186,7 +186,7 @@ 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 @@ 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 @@ GlyphCanvas.redraw (); } - OverViewItem get_selected_item () { + public OverViewItem get_selected_item () { if (visible_items.size == 0) { return new OverViewItem (); } @@ -680,6 +683,16 @@ get_selected_item ().selected = true; 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) { @@ -1723,6 +1736,7 @@ } g.insert_glyph (glyph, true); + update_path_boundaries (glyph); i++; } @@ -1730,6 +1744,12 @@ update_item_list (); 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 () { @@ -1740,7 +1760,8 @@ public AlternateSets alternate_sets = new AlternateSets (); public Gee.ArrayList<GlyphCollection> glyphs = new Gee.ArrayList<GlyphCollection> (); } + } }
--- a/libbirdfont/OverviewTools.vala +++ b/libbirdfont/OverviewTools.vala @@ -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 @@ 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);
--- a/libbirdfont/PreviewTools.vala +++ b/libbirdfont/PreviewTools.vala @@ -58,11 +58,18 @@ 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"); }