Clone in a terminal:
Commit d6d6d4e
Johan Mattsson - 2012-09-19T08:37:47+00:00
d6d6d4e8e0b5c913f5f1540ebfbdcd3be5cef415johan.mattsson.m@gmail.com

many small bugfixes

Changed files (14)

Diff

diff --git a/src/Birdfont.vala b/src/Birdfont.valaindex 68d27f1..051d714 100644--- a/src/Birdfont.vala+++ b/src/Birdfont.vala@@ -103,13 +103,17 @@ static void print_export_help (string[] arg) { 	stdout.printf (" [OPTION ...] FILE\n"); 	stdout.printf ("-h, --help                      print this message\n"); 	stdout.printf ("-o, --output [DIRECTORY]        write files to this directory\n");+	stdout.printf ("-s, --svg                       write file\n");+	stdout.printf ("-t, --ttf                       write ttf and eot files\n"); 	stdout.printf ("\n"); }  public static int run_export (string[] arg) { 	string output_directory = "."; 	string file_name = "";-	+	bool specific_formats = false;	+	bool write_ttf = false;+	bool write_svg = false; 	Supplement.Supplement supplement = new Supplement.Supplement (); 	 	File directory;@@ -135,6 +139,20 @@ public static int run_export (string[] arg) { 			i++; 			continue; 		}++		if (arg[i] == "-t" || arg[i] == "--ttf") {+			write_ttf = true;+			specific_formats = true;+			i++;+			continue;+		}++		if (arg[i] == "-s" || arg[i] == "--svg") {+			write_svg = true;+			specific_formats = true;+			i++;+			continue;+		} 		 		if (arg[i].has_prefix ("-")) { 			print_export_help (arg);@@ -183,9 +201,16 @@ public static int run_export (string[] arg) { 		return 1; 	} -	ExportTool.export_svg_font_path (File.new_for_path (output_directory));-	ExportTool.export_ttf_font_path (File.new_for_path (output_directory), false);-					+	if (!specific_formats || write_svg) {+		print (@"Writing $(supplement.current_font.get_name ()).svg to $output_directory\n");+		ExportTool.export_svg_font_path (File.new_for_path (output_directory));+	}++	if (!specific_formats || write_ttf) {+		print (@"Writing $(supplement.current_font.get_name ()).ttf to $output_directory\n");+		ExportTool.export_ttf_font_path (File.new_for_path (output_directory), false);+	}+	 	return 0; } diff --git a/src/ExportTool.vala b/src/ExportTool.valaindex 87a9dc5..742946d 100644--- a/src/ExportTool.vala+++ b/src/ExportTool.vala@@ -21,9 +21,7 @@ class ExportTool : Tool {  	private static string? prefered_browser = null; 	private static ExportThread export_thread;--	public static StaticMutex export_mutex;-	public static bool export_thread_is_running = false;+	 	private static unowned Thread<void*> export_thread_handle;  	private static bool stop_export_thread = false;@@ -44,8 +42,6 @@ class ExportTool : Tool { 		 		move_action.connect ((self, x, y)	 => { 		});-		-		export_mutex = new StaticMutex (); 	}  	public static bool export_all () {@@ -378,6 +374,34 @@ os.put_string ( 		return r; 	}  	+	public static string get_birdfont_export () {+		File f;+		+		f = File.new_for_path ("birdfont-export.sh");+		if (f.query_exists ()) {+			return "sh birdfont-export.sh";+		}++		f = File.new_for_path ("../birdfont-export.sh");	+		if (f.query_exists ()) {+			return "sh ../birdfont-export.sh";+		}++		f = File.new_for_path ("birdfont-export.exe");	+		if (f.query_exists ()) {+			return (!) f.get_path ();+		}++		f = File.new_for_path (@"$PREFIX/birdfont-export");+		if (f.query_exists ()) {+			return @"$PREFIX/birdfont-export";+		}++		warning ("Can't fint birdfont-export.");+		+		return "birdfont-export";+	}+	 	public static bool export_ttf_font_path (File folder, bool async = true) { 		Font current_font = Supplement.get_current_font (); 		string path;@@ -387,27 +411,12 @@ os.put_string ( 		File eot_file; 		string temp_file; 		bool done = true;--		lock (stop_export_thread) {-			stop_export_thread = true;-		}--		export_mutex.lock ();--		lock (stop_export_thread) {-			stop_export_thread = false;-		}-+		string export_command;+		 		if (Supplement.win32) { 			async = false; 		} -		while (ExportTool.export_thread_is_running) {-			export_mutex.unlock ();-			Thread.usleep (100);-			export_mutex.lock ();-		}- 		try { 			// create a copy of current font and use it in a separate  			// export thread@@ -426,30 +435,34 @@ os.put_string ( 			assert (!is_null (temp_file)); 			assert (!is_null (ttf_file.get_path ())); 			assert (!is_null (eot_file.get_path ()));-			+ 			export_thread = new ExportThread (temp_file, (!) ttf_file.get_path (), (!) eot_file.get_path ());  			try { 				if (async) {-					export_thread_is_running = true;-					export_thread_handle = Thread.create<void*> (export_thread.run, true);+					export_command = @"$(get_birdfont_export ()) --ttf -o $((!) folder.get_path ()) $temp_file";+					+					try {+						Process.spawn_command_line_async (export_command);+					} catch (Error e) {+						stderr.printf (@"Failed to execute \"$export_command\" \n");+						critical (@"$(e.message)");+					} 				} 				 				if (!async) { 					export_thread.run (); 				} 			} catch (ThreadError e) {-				export_mutex.unlock (); 				warning (e.message); 				done = false;-			}			+			}	+			 		} catch (Error e) { 			critical (@"$(e.message)"); 			done = false; 		} 		-		export_mutex.unlock ();-		 		return done;		 	} 	@@ -499,8 +512,6 @@ os.put_string ( 		} 		 		public void* run () {-			ExportTool.export_mutex.lock ();-			 			assert (!is_null (ffi)); 			assert (!is_null (ttf)); 			assert (!is_null (eot));@@ -512,10 +523,7 @@ os.put_string ( 			if (!should_stop ()) {  				write_eof (); 			}-			-			ExportTool.export_thread_is_running = false;-			-			ExportTool.export_mutex.unlock ();+ 			return null; 		} 		diff --git a/src/Font.vala b/src/Font.valaindex cbfe238..73ae3e2 100644--- a/src/Font.vala+++ b/src/Font.vala@@ -1188,7 +1188,7 @@ class Font : GLib.Object { 		GlyphBackgroundImage img; 		GlyphBackgroundImage? new_img = null; 		-		string attr_name;+		string attr_name = ""; 		string attr_content; 		 		File img_file = get_backgrounds_folder ().get_child ("parts");@@ -1209,8 +1209,8 @@ class Font : GLib.Object { 			} 		} 		-		if (new_img == null) {-			warning ("No source for image found.");+		if (unlikely (new_img == null)) {+			warning (@"No source for image found for $attr_name in $(g.name)"); 			return; 		} 	diff --git a/src/GtkInterface.vala b/src/GtkInterface.valaindex f980971..56e2d08 100644--- a/src/GtkInterface.vala+++ b/src/GtkInterface.vala@@ -45,7 +45,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { 		margin_bottom.set_size_request (0, 0); 		margin_right.set_size_request (0, 0); 		-		//set_title (title);+		// set_title (title);  		delete_event.connect (quit); 		@@ -71,16 +71,10 @@ public class GtkWindow : Gtk.Window, NativeWindow { 			bool n; 			File layout_dir; 			File layout_uri;-			string uri;+			string uri = ""; 			int i; 			FontDisplay fd = tab.get_display (); 			-			if (fd.get_name () == "Preview") {-				html_canvas.load_html_string ("", "");	-				Tool.yield ();-				ExportTool.export_all ();-			}-			 			MainWindow.glyph_canvas.set_current_glyph (fd); 			n = fd.is_html_canvas (); 			@@ -92,11 +86,19 @@ public class GtkWindow : Gtk.Window, NativeWindow { 					layout_uri = layout_dir.get_child (fd.get_html_file ()); 					uri = fd.path_to_uri ((!) layout_uri.get_path ()); 				}++				if (fd.get_name () == "Preview") {+					ExportTool.export_all ();+				} 				 				if (fd.get_html () == "") {-					html_canvas.load_html_string (fd.get_html (), uri);	+					html_canvas.load_html_string ("<html></html>", "file:///");	 					html_canvas.reload_bypass_cache ();+					 					html_canvas.load_uri (uri);+					html_canvas.reload_bypass_cache ();+					html_canvas.load_uri (uri);+					 				} else { 					html_canvas.load_html_string (fd.get_html (), uri); 				}@@ -107,6 +109,25 @@ 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/MenuTab.vala b/src/MenuTab.valaindex c771c19..1d32530 100644--- a/src/MenuTab.vala+++ b/src/MenuTab.vala@@ -143,9 +143,6 @@ c.append ("""  		</div> 	</div>--	<div class="inner_format_box">-	</div> 	 	<br class="clearBoth" /> 	@@ -243,7 +240,7 @@ c.append (""" 			select_overview (); 		}); 		-		MainWindow.get_tab_bar ().add_unique_tab (save, 70);+		MainWindow.get_tab_bar ().add_unique_tab (save, 80); 		 		if (!font.is_modified ()) { 			save.finished ();@@ -327,7 +324,7 @@ c.append (""" 			select_overview (); 		}); 		-		MainWindow.get_tab_bar ().add_unique_tab (save, 70);+		MainWindow.get_tab_bar ().add_unique_tab (save, 80); 		 		if (!font.is_modified ()) { 			save.finished ();@@ -339,7 +336,7 @@ c.append (""" 		save.finished.connect (() => { 			load_new_font (); 		});-		MainWindow.get_tab_bar ().add_unique_tab (save);+		MainWindow.get_tab_bar ().add_unique_tab (save, 80); 	}  	private static void load_new_font () {diff --git a/src/OpenFontFormatWriter.vala b/src/OpenFontFormatWriter.valaindex 5cbbc75..11b98e2 100644--- a/src/OpenFontFormatWriter.vala+++ b/src/OpenFontFormatWriter.vala@@ -1629,10 +1629,6 @@ class GlyfTable : Table { 			printd (@"loca fd.length (): $(fd.length ())\n");
 
 			last_len = fd.length ();
-			
-			if (ExportTool.should_stop ()) {
-				break;
-			}
 		}
 
 		location_offsets.append (fd.length ()); // last entry in loca table is special
diff --git a/src/OverView.vala b/src/OverView.valaindex 9f656cf..f17c547 100644--- a/src/OverView.vala+++ b/src/OverView.vala@@ -77,6 +77,8 @@ class OverView : FontDisplay { 				Glyph g = (fg == null) ? new Glyph (s, new_char) : ((!) fg).get_current (); 				ZoomTool z = (ZoomTool) tools.get_tool ("zoom_tool"); 				+				stdout.printf (@"Open '%s' %u (%s)\n", s, new_char, Font.to_hex (new_char));+				 				z.store_current_view (); 				f.add_glyph (g); 				tabs.add_tab (g);diff --git a/src/TestSupplement.vala b/src/TestSupplement.valaindex 716a197..e03b659 100644--- a/src/TestSupplement.vala+++ b/src/TestSupplement.vala@@ -87,7 +87,7 @@ class TestSupplement : GLib.Object { 		}	
 		
 		if (s == "" || s == "All") {
-			print ("No speceific tescase given run all test cases.\n");
+			print ("No specific tescase given run all test cases.\n");
 			return true;
 		}
 		
diff --git a/src/Tool.vala b/src/Tool.valaindex 5a782a4..403fe0f 100644--- a/src/Tool.vala+++ b/src/Tool.vala@@ -292,8 +292,7 @@ class Tool : GLib.Object { 		 		while (unlikely (!a)) { 			warning ("Failed to acquire main loop.\n");-			a = c.acquire ();-			Thread.usleep (2*1000000);+			return; 		}  		while (c.pending () || TestSupplement.is_slow_test ()) {diff --git a/src/Toolbox.vala b/src/Toolbox.valaindex ea036af..f65d737 100644--- a/src/Toolbox.vala+++ b/src/Toolbox.vala@@ -197,7 +197,7 @@ class Toolbox : GLib.Object  { 		path_tool_modifiers.add_tool (move_layer); 		 		// Character set tools-		Tool full_unicode = new Tool ("utf_8", "Show full unicode characters set", 'a', CTRL);+		Tool full_unicode = new Tool ("utf_8", "Show full unicode characters set"); 		full_unicode.select_action.connect ((self) => { 				MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 100, false);	 				OverView o = MainWindow.get_overview ();diff --git a/src/VersionList.vala b/src/VersionList.valaindex 2189f06..f41ae6c 100644--- a/src/VersionList.vala+++ b/src/VersionList.vala@@ -73,10 +73,10 @@ class VersionList : DropMenu { 		 		((!)ma.parent).deselect_all (); 		ma.set_selected (true);		--		MainWindow.get_tab_bar ().close_by_name (get_current ().name);			-		// MainWindow.get_glyph_canvas ().set_current_glyph (get_current ());-		// MainWindow.get_overview ().open_glyph_signal (get_current ().name);+			+		if (!is_null (MainWindow.get_tab_bar ())) {+			MainWindow.get_tab_bar ().close_by_name (get_current ().name);			+		}	 	} 	 	public void add_glyph (Glyph new_version, bool selected = true) {diff --git a/src/wscript b/src/wscriptindex 29b7edd..170099c 100644--- a/src/wscript+++ b/src/wscript@@ -134,5 +134,9 @@ def build (bld): 		target  = 'birdfont-export', 		depends = 'birdfont_export' 	)++def install (bld):	+	bld (rule = 'chmod 755 src/birdfont src/birdfont-export', name = "privileges", always=True)+	bld (rule = 'cp src/birdfont ${DEST}/${PREFIX}/bin/', depends = "privileges")+	bld (rule = 'cp src/birdfont-export ${DEST}/${PREFIX}/bin/', depends = "privileges")	 	-	bld.install_files('${PREFIX}/bin/', ['birdfont', 'birdfont-export'])diff --git a/win32/wscript b/win32/wscriptindex 66f04e2..47295d3 100644--- a/win32/wscript+++ b/win32/wscript@@ -89,7 +89,7 @@ def build(bld): 	bld(rule="windres ${SRC} -O coff -o ${TGT}", source="../win32/icon.rc", target="icon.res", always=True) 	bld(rule="mv ${SRC} ${TGT}", source="../win32/icon.res", target="../build/", name="icon", always=True) -	bld(rule="""i686-w64-mingw32-gcc -c ./Main.c ./src/*.c ./ \+	bld(rule="""i686-w64-mingw32-gcc -c ./Main.c ./BirdfontExport.c ./src/*.c ./ \ 		-I./ \ 		-mthreads \ 		$(i686-w64-mingw32-pkg-config --cflags --libs glib-2.0) \@@ -99,6 +99,9 @@ def build(bld): 		$(i686-w64-mingw32-pkg-config --cflags --libs gtk+-2.0) \ 		$(i686-w64-mingw32-pkg-config --cflags --libs webkit-1.0) && mv *.o win32/""", source="../build/src/Supplement.c", target="./Supplement.o", name="mingw compile", depends_on="clean_src", always=True); 	+	bld(rule="""mv win32/BirdfontExport.* ./ """, always=True);+	bld(rule="""mv win32/Main.* ./ """, always=True);+	 	bld(rule="""i686-w64-mingw32-gcc \ 		-shared \ 		./win32/*.o \@@ -114,7 +117,7 @@ def build(bld): 	bld(rule="""i686-w64-mingw32-ar rcs libbirdfont.dll.a win32/*.o""", name="mingw link static", depends_on="mingw link shared")  	bld(rule="""i686-w64-mingw32-gcc \-		./win32/Main.o \+		./Main.o \ 		./icon.res \ 		-Wl,-subsystem,windows \ 		-mthreads \@@ -126,6 +129,20 @@ def build(bld): 		-B static -l webkitgtk-1.0.dll  -B static -l gtk-win32-2.0.dll -B static -l gdk-win32-2.0.dll -B static -l atk-1.0.dll -B static -l gio-2.0.dll -B static -l pangowin32-1.0.dll -B static -l pangocairo-1.0.dll -B static -l gdk_pixbuf-2.0.dll -B static -l pango-1.0.dll -B static -l cairo.dll -B static -l gobject-2.0.dll -B static -l gmodule-2.0.dll -B static -l gthread-2.0.dll -B static -l glib-2.0.dll \ 		-static -o birdfont.exe""", source="../build/src/Supplement.c", target="../birdfont.exe", depends_on=['mingw link shared', 'icon'], name="mingw link", always=True) +	bld(rule="""i686-w64-mingw32-gcc \+		./BirdfontExport.o \+		./icon.res \+		-Wl,-subsystem,windows \+		-mthreads \+		-L./ \+		-L/usr/i686-w64-mingw32/sys-root/mingw/lib \+		-static -B -static -l birdfont.dll \+		-static -B static -lintl.dll -B static -l glib-2.0.dll -B static -l xml2.dll  \+		-B static -l gio-2.0.dll -B static -l soup-2.4.dll \+		-B static -l webkitgtk-1.0.dll  -B static -l gtk-win32-2.0.dll -B static -l gdk-win32-2.0.dll -B static -l atk-1.0.dll -B static -l gio-2.0.dll -B static -l pangowin32-1.0.dll -B static -l pangocairo-1.0.dll -B static -l gdk_pixbuf-2.0.dll -B static -l pango-1.0.dll -B static -l cairo.dll -B static -l gobject-2.0.dll -B static -l gmodule-2.0.dll -B static -l gthread-2.0.dll -B static -l glib-2.0.dll \+		-static -o birdfont-export.exe""", source="../build/src/Supplement.c", target="../birdfont-export.exe", depends_on=['mingw link shared', 'icon'], name="mingw link", always=True)++	bld(rule="mv birdfont-export.exe supplement/", depends_on='mingw link', always=True) 	bld(rule="mv birdfont.exe supplement/", depends_on='mingw link', always=True) 	bld(rule="mv libbirdfont.dll supplement/", depends_on='mingw link', always=True) @@ -196,7 +213,9 @@ Section "Start Menu Shortcuts"    CreateDirectory "$SMPROGRAMS\Birdfont"   CreateShortCut "$SMPROGRAMS\Birdfont\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0-  CreateShortCut "$SMPROGRAMS\Birdfont\Birdfont.lnk" "$INSTDIR\birdfont.exe" "" "$INSTDIR\birdfont.exe" 0+  CreateShortCut "$SMPROGRAMS\Birdfont\Birdfont.lnk" "$INSTDIR\birdfont.exe" ""+  +  CreateShortCut "$DESKTOP\Birdfont.lnk" "$INSTDIR\birdfont.exe" ""    SectionEnd @@ -287,9 +306,11 @@ def copy_runtime_dependencies (bld): 	bld(rule="cp -ra ../icons/ supplement/")  	bld(rule="cp ../win32/birdfont.ico supplement/")- 	bld(rule="cp -r " + MINGW + "/etc supplement/") +	bld(rule="cp " + MINGW_BIN + "/gspawn-win32-helper.exe supplement/")+	bld(rule="cp " + MINGW_BIN + "/gspawn-win32-helper-console.exe supplement/")+ 	# DLL-hell 	for dll in WIN32_DLLS: 		bld(rule="cp " + MINGW_BIN + "/" + dll + " supplement/")diff --git a/wscript b/wscriptindex f4b0185..75a69d9 100644--- a/wscript+++ b/wscript@@ -24,6 +24,8 @@ def configure(conf): 	
 	conf.env.append_unique('VALAFLAGS', ['--thread', '--pkg', 'webkit-1.0', '--enable-experimental', '--enable-experimental-non-null', '--vapidir=../../'])
 
+	conf.find_program('ldconfig', var='LDCONFIG', mandatory=False)
+
 	if conf.options.win32 :
 		conf.recurse('win32')
 
@@ -32,12 +34,16 @@ def pre (bld): 	
 	if not bld.options.noconfig:
 		write_config ()
-		
+
+def post (bld):
+	bld.exec_command ('${LDCONFIG}')
+				
 def build(bld):
 	bld.env.VERSION = VERSION
 	
 	bld.add_pre_fun(pre)
-
+	bld.add_post_fun(post)
+	
 	bld.recurse('src')
 
 	start_dir = bld.path.find_dir('./')
@@ -68,5 +74,10 @@ def write_config (): 	f.write(localtime)
 	f.write("\"");
 	f.write(";\n")
-		
+
+	f.write("	internal static const string PREFIX = \"")
+	f.write("${PREFIX}")
+	f.write("\"");
+	f.write(";\n")
+			
 	f.write("}");

Contact

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