Commit d6d6d4e
many small bugfixes
Changed files (14)
modifiedsrc/Birdfont.valamodifiedsrc/ExportTool.valamodifiedsrc/Font.valamodifiedsrc/GtkInterface.valamodifiedsrc/MenuTab.valamodifiedsrc/OpenFontFormatWriter.valamodifiedsrc/OverView.valamodifiedsrc/TestSupplement.valamodifiedsrc/Tool.valamodifiedsrc/Toolbox.valamodifiedsrc/VersionList.valamodifiedsrc/wscriptmodifiedwin32/wscriptmodifiedwscript
Diff
@@ -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; } @@ -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; } @@ -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; } @@ -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 @@ -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 () {@@ -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 @@ -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);@@ -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; } @@ -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 ()) {@@ -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 ();@@ -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) {@@ -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'])@@ -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/")@@ -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("}");