The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Merge ../birdfont-2.x

These changes was commited to the Birdfont repository Sun, 08 Jan 2017 12:55:27 +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, 08 Jan 2017 12:55:27 +0000 (13:55 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 08 Jan 2017 12:55:27 +0000 (13:55 +0100)
commit 80cd1f064f9efa37dafc1116d90af06e0a0c0c48
tree 3df0c333f6a2ecd52d2e9ff52db55c65ed4468f3
parent d29201c91eed2ccf1e43e84153c53a0c2d356cc3
parent 1e65e0776852b38719662e59bbf4127a377252c2
Merge ../birdfont-2.x

libbirdfont/BirdFont.vala
libbirdfont/ExportTool.vala
libbirdfont/Font.vala
libbirdfont/KerningDisplay.vala
libbirdfont/Preview.vala
scripts/version.py
--- a/libbirdfont/BirdFont.vala +++ b/libbirdfont/BirdFont.vala @@ -346,14 +346,17 @@ } public static File get_preview_directory () { - File settings = get_settings_directory (); - File backup = get_child(settings, "preview"); - - if (!backup.query_exists ()) { - DirUtils.create ((!) backup.get_path (), 0755); + string? export = BirdFont.get_current_font ().get_export_directory (); + + if (export == null) { + warning ("No export directory is set."); + export = ""; } - return backup; + File e = File.new_for_path ((!) export); + File p = get_child(e, "preview"); + + return p; } public static void set_settings_subdir (string? subdir) {
--- a/libbirdfont/ExportTool.vala +++ b/libbirdfont/ExportTool.vala @@ -22,6 +22,28 @@ public static string? error_message = null; public ExportTool (string n) { + } + + public static void set_output_directory () { + #if MAC + Font font = BirdFont.get_current_font (); + string? path = font.get_export_directory (); + + FileChooser fc = new FileChooser (); + fc.file_selected.connect ((p) => { + path = p; + }); + + if (path == null) { + File export_path_handle = File.new_for_path (path); + + if (!can_write (export_path_handle)) { + MainWindow.file_chooser (t_("Export"), fc, FileChooser.LOAD | FileChooser.DIRECTORY); + } + } + + font.export_directory = path; + #endif } public static string export_selected_paths_to_svg () { @@ -450,22 +472,31 @@ public static string get_export_folder () { Font font = BirdFont.get_current_font (); - string? sandbox = BirdFont.get_sandbox_directory (); + string? d = font.get_export_directory (); + + if (d == null) { + warning ("No export path is not set"); + return ""; + } + + return (!) d; + } - if (sandbox != null) { - File s = File.new_for_path ((!) sandbox); - File f = get_child (s, "Fonts"); - try { - if (!f.query_exists ()) { - f.make_directory (); - } - } catch (GLib.Error e) { - warning(e.message); + static bool can_write (File folder) { + File test = get_child (folder, "text.tmp"); + bool writable = false; + + try { + writable = FileUtils.set_contents (test.get_path (), "test"); + + if (writable) { + FileUtils.remove (test.get_path ()); } - return (!) get_child (f, font.full_name).get_path (); - } else { - return (!) font.get_folder ().get_path (); + } catch (GLib.Error e) { + writable = false; } + + return writable; } public static File get_export_dir () { @@ -593,7 +624,8 @@ } catch (Error e) { warning (@"Can't create TTF font to $ttf"); critical (@"$(e.message)"); - error_message = e.message; + error_message = e.message; + f.export_directory = null; } }
--- a/libbirdfont/Font.vala +++ b/libbirdfont/Font.vala @@ -63,6 +63,7 @@ public Gee.ArrayList<Line> custom_guides = new Gee.ArrayList<Line> (); public string? font_file = null; + public string? export_directory = null; bool modified = false; @@ -185,6 +186,13 @@ ~Font () { font_deleted (); + } + + public string? get_export_directory () { + #if MAC + return export_directory; + #endif + return get_path (); } public void add_default_characters () {
--- a/libbirdfont/KerningDisplay.vala +++ b/libbirdfont/KerningDisplay.vala @@ -158,7 +158,7 @@ row_height = get_row_height (); alpha = 1; - y = get_row_height () + font.base_line + 20; + y = get_row_height () - font.base_line + 20; x = 20; w = 0; prev = null; @@ -294,7 +294,7 @@ // draw caret if (first_row) { x2 = x; - caret_y = get_row_height () + font.base_line + 20; + caret_y = get_row_height () - font.base_line + 20; cr.save (); cr.set_line_width (1.0 / KerningTools.font_size); Theme.color_opacity (cr, "Foreground 1", 0.5);
--- 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 () { @@ -113,11 +113,26 @@ try { dis = new DataInputStream (get_file ().read ()); - preview_directory = BirdFont.get_preview_directory (); + string? d = font.get_export_directory (); + + if (d == null) { + warning ("Export dir is not set."); + ExportTool.set_output_directory (); + d = font.get_export_directory (); + } + + preview_directory = File.new_for_path ((!) d); + + warning (@"previwdir $((!) d)"); + + if (ExportTool.get_export_dir () == null) { + ExportTool.set_output_directory (); + } - f_ttf = get_child (ExportTool.get_export_dir (), @"$(ExportSettings.get_file_name (font)).ttf"); - f_eot = get_child (ExportTool.get_export_dir (), @"$(ExportSettings.get_file_name (font)).eot"); - f_svg = get_child (ExportTool.get_export_dir (), @"$(ExportSettings.get_file_name (font)).svg"); + File dir = File.new_for_path ((!) d); + f_ttf = get_child (dir, @"$(ExportSettings.get_file_name (font)).ttf"); + f_eot = get_child (dir, @"$(ExportSettings.get_file_name (font)).eot"); + f_svg = get_child (dir, @"$(ExportSettings.get_file_name (font)).svg"); if (!f_ttf.query_exists ()) { warning ("TTF file does not exist."); @@ -127,10 +142,14 @@ warning ("SVG file does not exist."); } + string name = ExportSettings.get_file_name_mac (font); + while ((line = dis.read_line (null)) != null) { - line = ((!) line).replace (@"$(ExportSettings.get_file_name (font)).ttf", @"$(TabContent.path_to_uri ((!) f_ttf.get_path ()))?$rid"); - line = ((!) line).replace (@"$(ExportSettings.get_file_name (font)).eot", @"$(TabContent.path_to_uri ((!) f_eot.get_path ()))?$rid"); - line = ((!) line).replace (@"$(ExportSettings.get_file_name (font)).svg", @"$(TabContent.path_to_uri ((!) f_svg.get_path ()))?$rid"); + warning (@"PRE $line name $name rep $(TabContent.path_to_uri ((!) f_ttf.get_path ()))"); + line = ((!) line).replace (@"$name.ttf", @"$(TabContent.path_to_uri ((!) f_ttf.get_path ()))?$rid"); + line = ((!) line).replace (@"$name.eot", @"$(TabContent.path_to_uri ((!) f_eot.get_path ()))?$rid"); + line = ((!) line).replace (@"$name.svg", @"$(TabContent.path_to_uri ((!) f_svg.get_path ()))?$rid"); + warning (@"POST $line"); sb.append ((!) line); }
--- a/scripts/version.py +++ b/scripts/version.py @@ -13,7 +13,7 @@ Lesser General Public License for more details. """ - VERSION = '2.18.3' + VERSION = '2.18.4' SO_VERSION_MAJOR = '36' SO_VERSION_MINOR = '0' SO_VERSION = SO_VERSION_MAJOR + '.' + SO_VERSION_MINOR