Clone in a terminal:
Commit 597fb8d
Johan Mattsson - 2012-09-20T15:23:11+00:00
597fb8d8a73b7a2c880038979e1ba30b66c5e895johan.mattsson.m@gmail.com

bin folder for wine

Changed files (10)

Diff

diff --git a/NEWS b/NEWSindex 3b2552b..5bdfae8 100644--- a/NEWS+++ b/NEWS@@ -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 2012diff --git a/src/Birdfont.vala b/src/Birdfont.valaindex 051d714..dfc4a3f 100644--- a/src/Birdfont.vala+++ b/src/Birdfont.vala@@ -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 ();+}+ }diff --git a/src/ExportTool.vala b/src/ExportTool.valaindex 742946d..1e8559d 100644--- a/src/ExportTool.vala+++ b/src/ExportTool.vala@@ -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) {diff --git a/src/FontDisplay.vala b/src/FontDisplay.valaindex 794b2ff..3cc598d 100644--- a/src/FontDisplay.vala+++ b/src/FontDisplay.vala@@ -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);+	} }  }diff --git a/src/Glyph.vala b/src/Glyph.valaindex a986224..acd99ec 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -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);diff --git a/src/GtkInterface.vala b/src/GtkInterface.valaindex 56e2d08..03119b0 100644--- a/src/GtkInterface.vala+++ b/src/GtkInterface.vala@@ -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 diff --git a/src/Icons.vala b/src/Icons.valaindex 8e05b5f..5705383 100644--- a/src/Icons.vala+++ b/src/Icons.vala@@ -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); 	} } 	diff --git a/src/Line.vala b/src/Line.valaindex 5423fc8..1d0d279 100644--- a/src/Line.vala+++ b/src/Line.vala@@ -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 (); 			} diff --git a/src/OpenFontFormatWriter.vala b/src/OpenFontFormatWriter.valaindex 11b98e2..187df0a 100644--- a/src/OpenFontFormatWriter.vala+++ b/src/OpenFontFormatWriter.vala@@ -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++) {		
diff --git a/src/Supplement.vala b/src/Supplement.valaindex 4753f40..f649687 100644--- a/src/Supplement.vala+++ b/src/Supplement.vala@@ -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;

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112