Commit 597fb8d
bin folder for wine
Changed files (10)
modifiedNEWSmodifiedsrc/Birdfont.valamodifiedsrc/ExportTool.valamodifiedsrc/FontDisplay.valamodifiedsrc/Glyph.valamodifiedsrc/GtkInterface.valamodifiedsrc/Icons.valamodifiedsrc/Line.valamodifiedsrc/OpenFontFormatWriter.valamodifiedsrc/Supplement.vala
Diff
@@ -1,5 +1,6 @@ birdfont (0.4.1) stable; + * Edit filled paths * Bugfixes -- Johan Mattsson <johan.mattsson.m@gmail.com> Wed Sep 19 15:37:40 CEST 2012@@ -23,6 +23,8 @@ public static int run_gui (string[] arg) { File font_file; Argument args; IdleSource idle;+ int i;+ string exec_path; Supplement.Supplement supplement = new Supplement.Supplement (); @@ -50,8 +52,28 @@ public static int run_gui (string[] arg) { supplement.experimental = args.has_argument ("--test"); supplement.show_coordinates = args.has_argument ("--show-coordinates"); supplement.fatal_wanings = args.has_argument ("--fatal-warning");- supplement.win32 = (arg[0].index_of (".exe") > -1);+ supplement.win32 = (arg[0].index_of (".exe") > -1) || arg[0] == "wine";+ supplement.exec_path = "";+ + print (@"$(arg[0]) \n"); + if (supplement.win32) {+ // wine hack to get "." folder in win32 environment+ i = arg[0].last_index_of ("\\");+ + if (i != -1) { + exec_path = arg[0];+ exec_path = exec_path.substring (0, i);+ supplement.exec_path = wine_to_unix_path (exec_path); + }+ } else {+ supplement.exec_path = "./";+ }+ + print (@"arg[0]: $(arg[0])\n");+ print (@"supplement.win32: $(supplement.win32)\n");+ print (@"supplement.exec_path: $(supplement.exec_path)\n");+ Preferences preferences = new Preferences (); preferences.load (); @@ -214,4 +236,32 @@ public static int run_export (string[] arg) { return 0; } +public static string wine_to_unix_path (string exec_path) {+ bool drive_c, drive_z;+ int i;+ string p;+ + p = exec_path;+ p = p.replace ("\\", "/");+ + drive_c = exec_path.index_of ("C:") == 0;+ drive_z = exec_path.index_of ("Z:") == 0;+ + i = p.index_of (":");+ + if (i != -1) {+ p = p.substring (i + 2);+ }++ if (drive_c) {+ return (@"/home/$(Environment.get_user_name ())/.wine/drive_c/" + p).dup ();+ }+ + if (drive_z) {+ return ("/" + p).dup ();+ }++ return exec_path.dup ();+}+ }@@ -443,6 +443,7 @@ os.put_string ( export_command = @"$(get_birdfont_export ()) --ttf -o $((!) folder.get_path ()) $temp_file"; try {+ print (@"Execute \"$export_command\" \n"); Process.spawn_command_line_async (export_command); } catch (Error e) { stderr.printf (@"Failed to execute \"$export_command\" \n");@@ -530,16 +531,20 @@ os.put_string ( void write_ttf () { OpenFontFormatWriter fo = new OpenFontFormatWriter (); Font f = new Font ();+ File file = (!) File.new_for_path (ttf); return_if_fail (!is_null (ffi)); return_if_fail (!is_null (ttf));+ return_if_fail (!is_null (file));+ return_if_fail (!is_null (f));+ return_if_fail (!is_null (fo)); try { if (!f.load (ffi, false)) { warning (@"Can't read $ffi"); } - fo.open ((!) File.new_for_path (ttf));+ fo.open (file); fo.write_ttf_font (f); fo.close (); } catch (Error e) {@@ -18,6 +18,7 @@ using Cairo; using Gtk; using Gdk;+using Birdfont; namespace Supplement { @@ -45,27 +46,31 @@ internal abstract class FontDisplay : GLib.Object { } public static string path_to_uri (string path) {- int i; string uri = path; string wp; + // wine uri hack if (Supplement.win32) {- uri = path.replace ("\\", "/");- i = uri.index_of (":");+ wp = wine_to_unix_path (uri); - if (i != -1) {- uri = uri.substring (i + 2);+ print (@"wp: $wp\n");+ + if (find_file (wp, "").query_exists ()) {+ uri = wp; } - // wine uri hack- wp = @"/home/$(Environment.get_user_name ())/.wine/drive_c/" + uri;- - if (Icons.find_file (null, wp).query_exists ()) {- uri = wp.substring (i);+ if (uri.index_of ("\\") > -1) {+ uri = uri.replace ("\\", "/"); } } - return @"file:///$uri";+ if (uri.index_of ("/") == 0) {+ uri = @"file://$uri";+ } else {+ uri = @"file:///$uri";+ }+ + return uri; } public virtual string get_uri () {@@ -141,28 +146,7 @@ internal abstract class FontDisplay : GLib.Object { } public static File find_layout_dir () {- File f;- string name = "layout";-- f = Icons.find_file ("./", name);- if (likely (f.query_exists ())) return f; -- f = Icons.find_file ("../", name);- if (likely (f.query_exists ())) return f;-- f = Icons.find_file (".\\", name);- if (likely (f.query_exists ())) return f;-- f = Icons.find_file ("", name);- if (likely (f.query_exists ())) return f;- - f = Icons.find_file ("/usr/local/share/birdfont/", name);- if (likely (f.query_exists ())) return f;-- f = Icons.find_file ("/usr/share/birdfont/", name);- if (likely (f.query_exists ())) return f;- - return f;+ return find_file (null, "layout"); } public void add_html_callback (string prop, PropertyFunction.PropertyCallback cb) {@@ -208,6 +192,49 @@ internal abstract class FontDisplay : GLib.Object { cb.call (v); } + public static File find_file (string? dir, string name) {+ File f;+ string d = (dir == null) ? "" : (!) dir;+ + f = get_file (Supplement.exec_path + "/", name + "/");+ if (likely (f.query_exists ())) return f;+ + f = get_file (Supplement.exec_path + "/" + d + "/", name);+ if (likely (f.query_exists ())) return f;+ + f = get_file ("./" + d + "/", name);+ if (likely (f.query_exists ())) return f; ++ f = get_file ("../" + d + "/", name);+ if (likely (f.query_exists ())) return f;++ f = get_file (".\\" + d + "\\", name);+ if (likely (f.query_exists ())) return f;++ f = get_file ("", name);+ if (likely (f.query_exists ())) return f;++ f = get_file (d + "\\", name);+ if (likely (f.query_exists ())) return f;++ f = get_file ("/usr/local/share/birdfont/" + d + "/", name);+ if (likely (f.query_exists ())) return f;++ f = get_file ("/usr/share/birdfont/" + d + "/", name);+ if (likely (f.query_exists ())) return f;+ + warning (@"Did not find file $name in $d");+ + return f; + }++ public static File get_file (string? path, string name) {+ StringBuilder fn = new StringBuilder ();+ string p = (path == null) ? "" : (!) path;+ fn.append (p);+ fn.append ((!) name);+ return File.new_for_path (fn.str);+ } } }@@ -1774,8 +1774,6 @@ class Glyph : FontDisplay { } if (!juxtaposed.is_empty ()) {- print (@"Glyph.xc () $(Glyph.xc ()) + left $left + x $x + kern $kern\n");- cr.save (); cr.scale (glyph.view_zoom, glyph.view_zoom); cr.translate (-glyph.view_offset_x, -glyph.view_offset_y);@@ -109,25 +109,6 @@ public class GtkWindow : Gtk.Window, NativeWindow { html_box.set_visible (false); MainWindow.glyph_canvas.set_visible (true); }- /*- if (fd.get_name () == "Preview") {- if (Supplement.win32) {- TimeoutSource t1 = new TimeoutSource (300);- t1.set_callback (() => {- html_canvas.load_html_string ("<html><body>Loading</body></html>", "file:///"); - return false;- });- t1.attach (null);-- TimeoutSource t2 = new TimeoutSource (10000);- t2.set_callback (() => {- html_canvas.load_uri (uri);- html_canvas.reload ();- return false;- });- t2.attach (null);- } - }*/ }); // Hide this canvas when window is realized and flip canvas @@ -21,8 +21,6 @@ using Cairo; class Icons { - static string icon_dir = "";- public static ImageSurface? get_icon (string? name) { ImageSurface? img = null; File f;@@ -43,45 +41,9 @@ class Icons { return img; }- - public static File find_icon (string name) {- File f;-- f = find_file (icon_dir, name);- if (likely (f.query_exists ())) return f;-- f = find_file ("./icons/", name);- if (likely (f.query_exists ())) return f; -- f = find_file ("../icons/", name);- if (likely (f.query_exists ())) return f;-- f = find_file (".\\icons\\", name);- if (likely (f.query_exists ())) return f; - f = find_file ("", name);- if (likely (f.query_exists ())) return f;-- f = find_file ("icons\\", name);- if (likely (f.query_exists ())) return f;-- f = find_file ("/usr/local/share/birdfont/icons/", name);- if (likely (f.query_exists ())) return f;-- f = find_file ("/usr/share/birdfont/icons/", name);- if (likely (f.query_exists ())) return f;- - return f;- }- - public static File find_file (string? path, string name) {- StringBuilder fn = new StringBuilder ();- string p = (path == null) ? "" : (!) path;- - icon_dir = p;- fn.append (icon_dir);- fn.append ((!) name);- return File.new_for_path (fn.str);+ public static File find_icon (string name) {+ return FontDisplay.find_file ("icons", name); } } @@ -153,7 +153,7 @@ class Line : GLib.Object { pos = Glyph.path_coordinate_x (x); redraw_line (); // draw at new position } else {- pos = Glyph.path_coordinate_y (y);+ pos = -Glyph.path_coordinate_y (y); redraw_line (); } @@ -1574,14 +1574,15 @@ class GlyfTable : Table { Glyph g; Font font = OpenFontFormatWriter.get_current_font (); uint32 indice; - + List<Glyph> unassigned_glyphs; + // add notdef. character at index zero + other special chars first glyphs.append (font.get_not_def_character ()); glyphs.append (font.get_null_character ()); glyphs.append (font.get_nonmarking_return ()); glyphs.append (font.get_space ()); - List<Glyph> unassigned_glyphs = new List<Glyph> (); + unassigned_glyphs = new List<Glyph> (); // add glyphs, first all assigned then the unassigned ones for (indice = 0; (gl = font.get_glyph_indice (indice)) != null; indice++) { @@ -26,6 +26,7 @@ internal class Supplement { internal static bool show_coordinates = false; internal static bool fatal_wanings = false; internal static bool win32 = false; + internal static string exec_path = ""; internal static Font current_font; internal static Glyph current_glyph;