Commit 80cd1f0
Merge ../birdfont-2.x
Changed files (6)
modifiedlibbirdfont/BirdFont.valamodifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/KerningDisplay.valamodifiedlibbirdfont/Preview.valamodifiedscripts/version.py
Diff
@@ -346,14 +346,17 @@ public class BirdFont { } 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) {@@ -24,6 +24,28 @@ public class ExportTool : GLib.Object { 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 () { return export_current_glyph_to_string (true); }@@ -450,22 +472,31 @@ os.put_string ( 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 @@ os.put_string ( } 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; } } @@ -63,6 +63,7 @@ public class Font : GLib.Object { public Gee.ArrayList<Line> custom_guides = new Gee.ArrayList<Line> (); public string? font_file = null;+ public string? export_directory = null; bool modified = false; @@ -187,6 +188,13 @@ public class Font : GLib.Object { font_deleted (); } + public string? get_export_directory () {+#if MAC+ return export_directory;+#endif+ return get_path ();+ }+ public void add_default_characters () { GlyphCollection notdef = get_notdef_character (); @@ -158,7 +158,7 @@ public class KerningDisplay : FontDisplay { 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 @@ public class KerningDisplay : FontDisplay { // 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);@@ -28,7 +28,7 @@ public class Preview : FontDisplay { } 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 @@ public class Preview : FontDisplay { 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 @@ public class Preview : FontDisplay { 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); } @@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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