The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Warn before opening the preview tab with an embedded svg font

These changes was commited to the Birdfont repository Mon, 02 Jan 2017 19:03:04 +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>
Mon, 02 Jan 2017 19:03:04 +0000 (20:03 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 02 Jan 2017 19:03:04 +0000 (20:03 +0100)
commit d5b7771627154ae151c270c0159d38b1b650452d
tree acd7b57cddb5346c7d4cae3e8ab7f33d5412bd2f
parent 3062c9138c0d21be235fc193139d217fde4d20ed
Warn before opening the preview tab with an embedded svg font

libbirdfont/ExportTool.vala
libbirdfont/Font.vala
libbirdfont/Glyph.vala
libbirdfont/Preview.vala
libbirdfont/PreviewTools.vala
--- a/libbirdfont/ExportTool.vala +++ b/libbirdfont/ExportTool.vala @@ -584,7 +584,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); @@ -594,7 +594,7 @@ warning (@"Can't create TTF font to $ttf"); critical (@"$(e.message)"); error_message = e.message; - } + } } static void write_eot (string ttf, string eot) {
--- a/libbirdfont/Font.vala +++ b/libbirdfont/Font.vala @@ -185,6 +185,18 @@ ~Font () { font_deleted (); + } + + 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/Preview.vala +++ b/libbirdfont/Preview.vala @@ -28,7 +28,7 @@ } public override void selected_canvas () { - MainWindow.set_scrollbar_size (0); + MainWindow.set_scrollbar_size (0); } public static string get_html_path () {
--- 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"); }