Commit f34bac5
a separate library and utility for font export from the command line
Changed files (24)
addedbirdfont-export.shaddedbirdfont.shaddedsrc/Birdfont.valamodifiedsrc/BirdfontExport.valamodifiedsrc/DropMenu.valamodifiedsrc/ExportTool.valamodifiedsrc/Font.valamodifiedsrc/FontDisplay.valamodifiedsrc/GlyphCanvas.valamodifiedsrc/KeyBindings.valamodifiedsrc/Main.valamodifiedsrc/MainWindow.valamodifiedsrc/MenuTab.valamodifiedsrc/OpenFontFormatReader.valamodifiedsrc/OpenFontFormatWriter.valamodifiedsrc/Path.valamodifiedsrc/Preferences.valamodifiedsrc/Supplement.valamodifiedsrc/Svg.valamodifiedsrc/Toolbox.valamodifiedsrc/VersionList.valamodifiedsrc/wscriptmodifiedwin32/wscriptmodifiedwscript
Diff
new file mode 100755@@ -0,0 +1,4 @@+export LD_LIBRARY_PATH="./build/src/:$LD_LIBRARY_PATH"+PKG_PATH=$(dirname "$(readlink -f "$0")")+cd "${PKG_PATH}"+./build/src/birdfont-export $*new file mode 100755@@ -0,0 +1,4 @@+export LD_LIBRARY_PATH="./build/src/:$LD_LIBRARY_PATH"+PKG_PATH=$(dirname "$(readlink -f "$0")")+cd "${PKG_PATH}"+./build/src/birdfontnew file mode 100644@@ -0,0 +1,189 @@+/*+ Copyright (C) 2012 Johan Mattsson++ This program is free software: you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+*/+using Supplement;++namespace Birdfont {++public static int run_gui (string[] arg) {+ int err_arg;+ File font_file;+ Argument args;+ IdleSource idle;++ Supplement.Supplement supplement = new Supplement.Supplement ();++ supplement.args = new Argument.command_line (arg);+ args = supplement.args;+ + if (supplement.args.has_argument ("--help")) {+ args.print_help ();+ Process.exit (0);+ }++ err_arg = args.validate ();+ if (err_arg != 0) {+ stdout.printf (@"Unknown parameter $(arg [err_arg])\n\n");+ args.print_help ();+ Process.exit (0);+ }++ stdout.printf ("birdfont version %s\n", VERSION); ++ supplement.current_font = new Font ();++ 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);++ Preferences preferences = new Preferences ();+ preferences.load ();+ + if (args.get_file () != "") {+ font_file = File.new_for_path (args.get_file ());+ + if (!font_file.query_exists ()) {+ stderr.printf (@"File $(args.get_file ()) not found.");+ return -1;+ }+ }+ + Gtk.init (ref arg);+ MainWindow window = new MainWindow ("Birdfont");+ window.show_all ();++ if (supplement.fatal_wanings) {+ LogLevelFlags levels = LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL | LogLevelFlags.LEVEL_WARNING;+ Log.set_handler (null, levels, supplement.fatal_warning);+ }+ + idle = new IdleSource ();+ idle.set_callback(() => {+ preferences.load ();+ + if (args.get_file () != "") {+ supplement.get_current_font ().load (args.get_file ());+ MainWindow.get_toolbox ().select_tool_by_name ("available_characters");+ } else {+ MainWindow.get_tab_bar ().select_tab_name ("Menu");+ }+ + return false;+ });+ + idle.attach (null);+ + Gtk.main ();+ + preferences.set_last_file (supplement.get_current_font ().get_path ());+ + return 0;+}++static void print_export_help (string[] arg) {+ stdout.printf ("Usage: ");+ stdout.printf (arg[0]);+ 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 ("\n");+}++public static int run_export (string[] arg) {+ string output_directory = ".";+ string file_name = "";+ + Supplement.Supplement supplement = new Supplement.Supplement ();+ + File directory;+ + if (arg.length < 2) {+ print_export_help (arg);+ }+ + for (int i = 1; i < arg.length; i++) {++ if (arg[i] == "-f" || arg[i] == "--fatal-warnings") {+ supplement.fatal_wanings = true;+ return 0;+ }++ if (arg[i] == "-h" || arg[i] == "--help") {+ print_export_help (arg);+ return 0;+ }+ + if (arg[i] == "-o" || arg[i] == "--output" && i + 1 < arg.length) {+ output_directory = arg[i + 1];+ i++;+ continue;+ }+ + if (arg[i].has_prefix ("-")) {+ print_export_help (arg);+ return 1;+ continue;+ }+ + if (!arg[i].has_prefix ("-")) {+ file_name = arg[i];+ + if (i != arg.length - 1) {+ print_export_help (arg);+ return 1;+ }+ + break;+ }+ }++ if (supplement.fatal_wanings) {+ LogLevelFlags levels = LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL | LogLevelFlags.LEVEL_WARNING;+ Log.set_handler (null, levels, supplement.fatal_warning); + }++ Preferences preferences = new Preferences ();+ preferences.load ();+ + supplement.args = new Argument ("");+ supplement.current_font = new Font ();+ supplement.current_glyph = new Glyph ("");+ + if (!supplement.get_current_font ().load (file_name, false)) {+ stderr.printf (@"Failed to load font $file_name.\n");+ + if (!file_name.has_suffix (".ffi")) {+ stderr.printf (@"Is it a .ffi file?\n");+ }+ + return 1;+ }++ directory = File.new_for_path (output_directory);+ + if (!directory.query_exists ()) {+ stderr.printf ("Can't find output directory $directory\n");+ 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);+ + return 0;+}++}@@ -15,104 +15,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -namespace Supplement {+using Birdfont; /** Stand alone command line utility for exporting fonts. */-class BirdfontExport {- - static string folder;- - public BirdfontExport () {- }- - static void print_help (string[] arg) {- stdout.printf ("Usage: ");- stdout.printf (arg[0]);- 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 ("\n");- }- - public static int main (string[] arg) {- OptionContext opt;- - LogLevelFlags levels = LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL | LogLevelFlags.LEVEL_WARNING;- Log.set_handler (null, levels, Supplement.fatal_warning);- - string output_directory = ".";- string file_name = "";- - File directory;- - if (arg.length < 2) {- print_help (arg);- }- - for (int i = 1; i < arg.length; i++) {- if (arg[i] == "-h" || arg[i] == "--help") {- print_help (arg);- return 0;- }- - if (arg[i] == "-o" || arg[i] == "--output" && i + 1 < arg.length) {- output_directory = arg[i + 1];- i++;- continue;- }- - if (arg[i].has_prefix ("-")) {- print_help (arg);- return 1;- continue; - }- - if (!arg[i].has_prefix ("-")) {- file_name = arg[i];- - if (i != arg.length - 1) {- print_help (arg);- return 1;- }- - break;- }- }-- Preferences preferences = new Preferences ();- preferences.load ();- - Supplement.args = new Argument ("");- Supplement.current_font = new Font ();-- // TODO: refactor and remove all the gtk stuff from this program- Gtk.init (ref arg);- MainWindow window = new MainWindow ("Birdfont");- window.show_all ();- - if (!Supplement.get_current_font ().load (file_name, false)) {- stderr.printf (@"Failed to load font $file_name.\n");- - if (!file_name.has_suffix (".ffi")) {- stderr.printf (@"Is it a .ffi file?\n");- }- - return 1;- }-- directory = File.new_for_path (output_directory);- - if (!directory.query_exists ()) {- stderr.printf ("Can't find output directory $directory\n");- 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);- - return 0;- }- -}-+public static int main (string[] arg) { + return run_export (arg); }@@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; namespace Supplement { @@ -67,23 +67,15 @@ class ExportTool : Tool { public void export_glyph_to_svg () { Glyph glyph = MainWindow.get_current_glyph ();- Font font = Supplement.get_current_font (); FontDisplay fd = MainWindow.get_current_display ();- string glyph_svg; string svg_file = @"$(glyph.get_name ()).svg";- File file = font.get_folder ().get_child (svg_file);- DataOutputStream os;- string name = glyph.get_name ();- int pid = 0; - TooltipArea status = MainWindow.get_tool_tip ();- if (!(fd is Glyph)) { return; }@@ -128,10 +120,10 @@ class ExportTool : Tool { } catch (Error e) { stderr.printf (@"Export \"$svg_file\" \n"); critical (@"$(e.message)");- status.show_text ("Can't export $svg_file.");+ status ("Can't export $svg_file."); } - status.show_text ("Wrote $svg_file.");+ status ("Wrote $svg_file."); } /** Export font and open html document */@@ -359,32 +351,30 @@ os.put_string (""" unowned Thread<void*> th; File file; string temp_file;- + try { // create a copy of current font and use it in a separate // export thread temp_file = current_font.save_backup ();- file = folder.get_child (temp_font.get_name () + ".ttf");+ file = folder.get_child (current_font.get_name () + ".ttf"); if (file.query_exists ()) { file.delete (); } path = (!) file.get_path ();- export_thread = new ExportThread (temp_file, path);++ try {+ th = Thread.create<void*> (export_thread.run, true); - if (async) {- try {- th = Thread.create<void*> (export_thread.run, true);- } catch (ThreadError e) {- stderr.printf ("%s\n", e.message);- return false;+ if (!async) {+ th.join (); }- } else {- export_thread.run ();- }- + } catch (ThreadError e) {+ stderr.printf ("%s\n", e.message);+ return false;+ } } catch (Error e) { critical (@"$(e.message)"); return false;@@ -399,7 +389,6 @@ os.put_string (""" } public static bool export_svg_font_path (File folder) {- TooltipArea ta = MainWindow.get_tool_tip (); Font font = Supplement.get_current_font (); string file_name = @"$(font.get_name ()).svg"; File file;@@ -418,11 +407,11 @@ os.put_string (""" fo.close (); } catch (Error e) { critical (@"$(e.message)");- ta.show_text (e.message);+ status (e.message); return false; } - ta.show_text (@"Wrote $file_name");+ status (@"Wrote $file_name"); return true; } @@ -461,6 +450,16 @@ os.put_string (""" return null; } }+ + private static void status (string s) {+ TooltipArea status = MainWindow.get_tool_tip ();+ + if (is_null (status)) {+ return;+ }+ + status.show_text (s);+ } } }@@ -33,7 +33,8 @@ class Font : GLib.Object { int next_unindexed = 0; public List <string> background_images = new List <string> ();- + public string background_scale = "1";+ /** Top margin */ public double top_limit; @@ -54,7 +55,6 @@ class Font : GLib.Object { public string? backup_file = null; public string? font_file = null;- public string? export_dir = null; bool modified = false; @@ -66,6 +66,8 @@ class Font : GLib.Object { OpenFontFormatReader otf; bool otf_font = false; + public List<string> grid_width = new List<string> ();+ public Font () { // positions in pixels at first zoom level // default x-height should be 60 in 1:1@@ -540,15 +542,15 @@ class Font : GLib.Object { os.put_string ("</lines>\n\n"); - foreach (SpinButton s in GridTool.sizes) {- os.put_string (@"<grid width=\"$(s.get_display_value ())\"/>\n");+ foreach (string gv in grid_width) {+ os.put_string (@"<grid width=\"$(gv)\"/>\n"); } if (GridTool.sizes.length () > 0) { os.put_string ("\n"); } - os.put_string (@"<background scale=\"$(MainWindow.get_toolbox ().background_scale.get_display_value ())\" />\n");+ os.put_string (@"<background scale=\"$(background_scale)\" />\n"); os.put_string ("\n"); if (background_images.length () > 0) {@@ -684,6 +686,10 @@ class Font : GLib.Object { try { otf_font = false; + while (grid_width.length () > 0) {+ grid_width.remove_link (grid_width.first ());+ }+ while (glyph_names.length () > 0) { glyph_names.remove_link (glyph_names.first ()); }@@ -820,8 +826,7 @@ class Font : GLib.Object { // empty cache and fill it with new glyphs from disk glyph_cache.remove_all (); unassigned_glyphs.remove_all ();- - MainWindow.get_toolbox ().remove_all_grid_buttons ();+ while (background_images.length () > 0) { background_images.remove_link (background_images.first ()); }@@ -922,7 +927,7 @@ class Font : GLib.Object { attr_content = prop->children->content; if (attr_name == "scale") {- MainWindow.get_toolbox ().background_scale.set_value (attr_content);+ background_scale = attr_content; } } }@@ -953,7 +958,7 @@ class Font : GLib.Object { string attr_content = prop->children->content; if (attr_name == "width") {- MainWindow.get_toolbox ().parse_grid (attr_content);+ grid_width.append (attr_content); } } }@@ -22,12 +22,12 @@ using Gdk; namespace Supplement { /** Javascripts in webkit do use this callback. */-public class PropertyFunction {+internal class PropertyFunction { public delegate void PropertyCallback (string val); public PropertyCallback call; } -public abstract class FontDisplay : GLib.Object {+internal abstract class FontDisplay : GLib.Object { List<string> property = new List<string> (); List<PropertyFunction> call = new List<PropertyFunction> ();@@ -23,8 +23,7 @@ using Math; namespace Supplement { class GlyphCanvas : DrawingArea { - - public Glyph current_glyph = new Glyph (""); + FontDisplay current_display; Allocation alloc; @@ -35,7 +34,7 @@ class GlyphCanvas : DrawingArea { alloc.width = 0; alloc.height = 0; - current_display = current_glyph; + current_display = new Glyph (""); expose_event.connect ((t, e)=> { @@ -63,7 +62,7 @@ class GlyphCanvas : DrawingArea { warning (@"\nGlyph canvas is not divisible by two.\nWidth: $(allocation.width)\nHeight: $(allocation.height)"); } - current_glyph.resized (alloc, allocation); + Supplement.current_glyph.resized (alloc, allocation); Preferences.update_window_size (); } @@ -135,7 +134,7 @@ class GlyphCanvas : DrawingArea { g.allocation = allocation; - current_glyph = g; + Supplement.current_glyph = g; } current_display = fd; @@ -149,8 +148,8 @@ class GlyphCanvas : DrawingArea { redraw (); } - public Glyph get_current_glyph () { - return current_glyph; + public static Glyph get_current_glyph () { + return Supplement.current_glyph; } public FontDisplay get_current_display () { @@ -68,12 +68,12 @@ bool is_modifier_key (uint i) { } /** Modifier flags */-public static const uint NONE = 0;-public static const uint CTRL = 1 << 0;-public static const uint ALT = 1 << 2;-public static const uint SHIFT = 1 << 3;+internal static const uint NONE = 0;+internal static const uint CTRL = 1 << 0;+internal static const uint ALT = 1 << 2;+internal static const uint SHIFT = 1 << 3; -public bool is_mod (EventKey e) {+internal bool is_mod (EventKey e) { return (e.keyval == Key.CTRL_RIGHT || e.keyval == Key.CTRL_LEFT || e.keyval == Key.ALT_RIGHT || e.keyval == Key.ALT_LEFT); } @@ -15,82 +15,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk;--namespace Supplement {- -public static int main(string[] arg) {- int err_arg;- File font_file;- Argument args;- IdleSource idle;-- Supplement.args = new Argument.command_line (arg);- args = Supplement.args;- - if (Supplement.args.has_argument ("--help")) {- args.print_help ();- Process.exit (0);- }-- err_arg = args.validate ();- if (err_arg != 0) {- stdout.printf (@"Unknown parameter $(arg [err_arg])\n\n");- args.print_help ();- Process.exit (0);- }-- stdout.printf ("birdfont version %s\n", VERSION); -- Supplement.current_font = new Font ();-- 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);-- Preferences preferences = new Preferences ();- preferences.load ();+using Birdfont; - if (args.get_file () != "") {- font_file = File.new_for_path (args.get_file ());- - if (!font_file.query_exists ()) {- stderr.printf (@"File $(args.get_file ()) not found.");- return -1;- }- }- - Gtk.init (ref arg);- MainWindow window = new MainWindow ("Birdfont");- window.show_all ();-- if (Supplement.fatal_wanings) {- LogLevelFlags levels = LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL | LogLevelFlags.LEVEL_WARNING;- Log.set_handler (null, levels, Supplement.fatal_warning);- }- - idle = new IdleSource ();- idle.set_callback(() => {- preferences.load ();- - if (args.get_file () != "") {- Supplement.get_current_font ().load (args.get_file ());- MainWindow.get_toolbox ().select_tool_by_name ("available_characters");- } else {- MainWindow.get_tab_bar ().select_tab_name ("Menu");- }- - return false;- });- - idle.attach (null);- - Gtk.main ();- - preferences.set_last_file (Supplement.get_current_font ().get_path ());- - return 0;-}-+public static int main (string[] arg) {+ return run_gui (arg); }@@ -21,7 +21,7 @@ using WebKit; namespace Supplement { -public class MainWindow : Gtk.Window { +internal class MainWindow : Gtk.Window { HBox list_box; HBox canvas_box; @@ -223,14 +223,12 @@ public class MainWindow : Gtk.Window { } internal static Glyph get_current_glyph () { - Glyph? g = get_singleton ().glyph_canvas.get_current_glyph (); - - if (unlikely (g == null)) { + if (unlikely (is_null (Supplement.current_glyph))) { warning ("No default glyph have been set yet.\n"); return new Glyph ("no_glyph_created"); } - return (!) g; + return Supplement.current_glyph; } internal static Toolbox get_toolbox () { @@ -240,7 +240,14 @@ c.append (""" } MainWindow.get_singleton ().set_title (f.get_name ());-+ + MainWindow.get_toolbox ().remove_all_grid_buttons ();+ foreach (string v in f.grid_width) {+ MainWindow.get_toolbox ().parse_grid (v);+ }+ + MainWindow.get_toolbox ().background_scale.set_value (f.background_scale);+ select_overview (); }); @@ -304,6 +311,16 @@ c.append (""" fn = (!) f.font_file; if (f.font_file != null && fn.has_suffix (".ffi")) {+ f.background_scale = MainWindow.get_toolbox ().background_scale.get_display_value ();+ + while (f.grid_width.length () > 0) {+ f.grid_width.remove_link (f.grid_width.first ());+ }+ + foreach (SpinButton s in GridTool.sizes) {+ f.grid_width.append (s.get_display_value ());+ }+ f.save (fn); saved = true; } else {@@ -323,6 +340,10 @@ c.append (""" Supplement.new_font (); MainWindow.close_all_tabs (); + MainWindow.get_toolbox ().remove_all_grid_buttons ();+ MainWindow.get_toolbox ().add_new_grid ();+ MainWindow.get_toolbox ().add_new_grid ();+ select_overview (); }); @@ -19,7 +19,7 @@ namespace Supplement { [SimpleType] [CCode (has_type_id = false)] // Vala bug-public struct Fixed : uint32 {+internal struct Fixed : uint32 { public void @set (uint16 upper, uint16 lower) { uint32* p = &this;@@ -39,7 +39,7 @@ public struct Fixed : uint32 { [SimpleType] [CCode (has_type_id = false)] // same as above-public struct F2Dot14 : uint32 {+internal struct F2Dot14 : uint32 { } errordomain BadFormat {@@ -4789,7 +4789,7 @@ class DirectoryTable : Table { } /** Largest power of two less than max. */ -public static uint16 largest_pow2 (uint16 max) { +internal static uint16 largest_pow2 (uint16 max) { uint16 x = 1; uint16 l = 0; @@ -4801,7 +4801,7 @@ public static uint16 largest_pow2 (uint16 max) { return l; } -public static uint16 largest_pow2_exponent (uint16 max) { +internal static uint16 largest_pow2_exponent (uint16 max) { uint16 exp = 0; uint16 l = 0; uint16 x = 0; @@ -201,10 +201,8 @@ class Path { /** Line points relative to center. */ public static void get_line_points (EditPoint e, EditPoint en, out double xa, out double ya, out double xb, out double yb) {- Glyph g = MainWindow.get_current_glyph ();- - double xc = g.allocation.width / 2.0;- double yc = g.allocation.height / 2.0;+ double xc = Glyph.xc ();+ double yc = Glyph.yc (); xa = xc + en.x; ya = yc - en.y;@@ -16,7 +16,7 @@ */ namespace Supplement { -class Preferences {+internal class Preferences { static HashTable<string, string> data; @@ -16,23 +16,25 @@ */ using Gtk; +using Supplement; namespace Supplement { -class Supplement { - public static Argument args; - public static bool experimental = false; - public static bool show_coordinates = false; - public static bool fatal_wanings = false; - public static bool win32 = false; +internal class Supplement { + internal static Argument args; + internal static bool experimental = false; + internal static bool show_coordinates = false; + internal static bool fatal_wanings = false; + internal static bool win32 = false; - public static Font current_font; - - public static Font get_current_font () { + internal static Font current_font; + internal static Glyph current_glyph; + + internal static Font get_current_font () { return current_font; } - public static void fatal_warning (string? log_domain, LogLevelFlags log_levels, string message) { + internal static void fatal_warning (string? log_domain, LogLevelFlags log_levels, string message) { bool fatal = true; if (log_domain != null) { @@ -43,11 +45,11 @@ class Supplement { assert (!fatal); } - public static void new_font () { + internal static void new_font () { current_font = new Font (); } - public static File get_thumbnail_directory () { + internal static File get_thumbnail_directory () { File thumbnails = get_settings_directory ().get_child ("thumbnails"); if (!thumbnails.query_exists ()) { @@ -57,7 +59,7 @@ class Supplement { return thumbnails; } - public static File get_settings_directory () { + internal static File get_settings_directory () { File home = File.new_for_path (Environment.get_home_dir ()); File settings = home.get_child (".birdfont"); @@ -68,7 +70,7 @@ class Supplement { return settings; } - public static File get_backup_directory () { + internal static File get_backup_directory () { File settings = get_settings_directory (); File backup = settings.get_child ("backup"); @@ -79,11 +81,11 @@ class Supplement { return backup; } - public static bool has_argument (string param) { + internal static bool has_argument (string param) { return args.has_argument (param); } - public static string? get_argument (string param) { + internal static string? get_argument (string param) { return args.get_argument (param); } } @@ -325,7 +325,7 @@ class Svg { } -public static string round (double p) {+internal static string round (double p) { string v = @"$p"; if (v.index_of ("e") != -1) {@@ -600,6 +600,7 @@ class Toolbox : DrawingArea { } add_new_grid ();+ add_new_grid (); move (0, 0); @@ -678,7 +679,7 @@ class Toolbox : DrawingArea { } public void remove_all_grid_buttons () {- while (grid_expander.tool.length () > 2) {+ while (grid_expander.tool.length () > 0) { grid_expander.tool.remove_link (grid_expander.tool.last ()); } @@ -59,9 +59,6 @@ class VersionList : DropMenu { public void add_new_version () { Glyph g = get_current (); Glyph new_version = g.copy ();- TabBar tb = MainWindow.get_tab_bar ();- - tb.close_background_tab_by_name (g.name); add_glyph (new_version); } @@ -70,8 +67,7 @@ class VersionList : DropMenu { int i = ma.index; return_if_fail (0 <= i < glyphs.length ());- - MainWindow.get_tab_bar ().close_by_name (g.name);+ current_version = i; return_if_fail (ma.parent != null);@@ -3,6 +3,7 @@ BIRDFONT = [ 'Font.vala', 'BackgroundTool.vala', 'BackgroundSelection.vala', + 'Birdfont.vala', 'ExportTool.vala', 'FontDisplay.vala', 'CharDatabase.vala', @@ -56,7 +57,7 @@ BIRDFONT = [ 'TooltipArea.vala', 'UniRange.vala', 'VersionList.vala', - 'ZoomTool.vala' + 'ZoomTool.vala', ] BIRDFONT_MAIN = [ @@ -72,16 +73,58 @@ PARAM = [ '--disable-warnings', '--enable-experimental', '--enable-experimental-non-null', - '--vapidir=../../' - '--Xcc=-lm' + '--vapidir=./' ] def build (bld): - bld.program ( + + bld.shlib ( target = 'birdfont', param = PARAM, packages = 'gtk+-2.0 libxml-2.0', uselib = 'GTK GLIB GIO XML WEB', - source = BIRDFONT + BIRDFONT_MAIN + source = BIRDFONT, + name = "libbirdfont" + ) + + bld ( + rule = "valac -C ./src/birdfont.vapi ../src/Main.vala -X ../build/src/libbirdfont.so -X ../build/src/birdfont.h --pkg gtk+-2.0 --pkg libxml-2.0 --pkg gdk-2.0 --pkg webkit-1.0" + ) + + bld ( + rule = "valac -C ./src/birdfont.vapi ../src/BirdfontExport.vala -X ../build/src/libbirdfont.so -X ../build/src/birdfont.h --pkg gtk+-2.0 --pkg libxml-2.0 --pkg gdk-2.0 --pkg webkit-1.0" ) + bld ( + rule = "mv src/birdfont.h ./", + depends = "libbirdfont", + name = "birdfont_h" + ) + + bld ( + rule = 'gcc ../build/Main.c -L ../build/src -l birdfont -o ${TGT} \ + $(pkg-config --cflags --libs glib-2.0) \ + $(pkg-config --cflags --libs libxml-2.0) \ + $(pkg-config --cflags --libs gio-2.0) \ + $(pkg-config --cflags --libs libsoup-2.4) \ + $(pkg-config --cflags --libs gtk+-2.0) \ + $(pkg-config --cflags --libs webkit-1.0)', + source = ['Main.c'], + target = 'birdfont', + depends = 'birdfont_h' + ) + + bld ( + rule = 'gcc ../build/BirdfontExport.c -L ../build/src -l birdfont -o ${TGT} \ + $(pkg-config --cflags --libs glib-2.0) \ + $(pkg-config --cflags --libs libxml-2.0) \ + $(pkg-config --cflags --libs gio-2.0) \ + $(pkg-config --cflags --libs libsoup-2.4) \ + $(pkg-config --cflags --libs gtk+-2.0) \ + $(pkg-config --cflags --libs webkit-1.0)', + source = ['Main.c'], + target = 'birdfont-export', + depends = 'birdfont_h' + ) + + bld.install_files('${PREFIX}/bin/', ['birdfont', 'birdfont-export']) @@ -88,7 +88,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 ./src/*.c \+ bld(rule="""i686-w64-mingw32-gcc -c ./Main.c ./src/*.c \ -s \ -mthreads \ $(i686-w64-mingw32-pkg-config --cflags --libs glib-2.0) \@@ -1,4 +1,4 @@-VERSION = '0.2.1' +VERSION = '0.3.0' APPNAME = 'birdfont' top = '.' @@ -45,7 +45,7 @@ def write_config (): f = open('./src/Config.vala', 'w+') f.write("// Don't edit this file – it's generated by wscript\n") f.write("namespace Supplement {\n") - f.write(" public static const string VERSION = \"") + f.write(" internal static const string VERSION = \"") f.write(VERSION) f.write("\""); f.write(";\n")