The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Check if the folder is writable

These changes was commited to the Birdfont repository Fri, 22 Sep 2017 16:09:21 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 22 Sep 2017 16:09:21 +0000 (18:09 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 22 Sep 2017 16:09:21 +0000 (18:09 +0200)
commit c4381b6b6e8321ad020bcbd0016f37dff885dbae
tree d25627fa6615d6bc2f8fbdca868e9e924154caf1
parent 6e980f5a1574258751e98bb68049e0548b838da9
Check if the folder is writable

libbirdfont/ExportTool.vala
libbirdfont/ExportUtils.vala
libbirdfont/OpenFontFormat/PostTable.vala
resources/linux/birdfont-export.1
--- a/libbirdfont/ExportTool.vala +++ b/libbirdfont/ExportTool.vala @@ -602,8 +602,25 @@ warning (@"EOF conversion falied, $ttf -> $eot"); critical (@"$(e.message)"); } + } + + static bool can_write (File folder) { + File test = get_child (folder, "text.tmp"); + bool writable = false; + + try { + writable = FileUtils.set_contents ((!) test.get_path (), "test"); + + if (writable) { + FileUtils.remove ((!) test.get_path ()); + } + } catch (GLib.Error e) { + writable = false; + } + + return writable; } } }
--- a/libbirdfont/ExportUtils.vala +++ b/libbirdfont/ExportUtils.vala @@ -17,6 +17,7 @@ stdout.printf (t_("Usage:")); stdout.printf (arg[0]); stdout.printf (" [" + t_("OPTION") + "...] " + t_("FILE") +"\n"); + stdout.printf (" --filter [CHARACTERS] " + t_("include only these characters") + "\n"); stdout.printf ("-h, --help " + t_("print this message") + "\n"); stdout.printf ("-o, --output [DIRECTORY] " + t_("write files to this directory") + "\n"); stdout.printf ("-s, --svg " + t_("write svg file") + "\n"); @@ -28,6 +29,7 @@ public static int run_export (string[] arg) { string output_directory = "."; string file_name = ""; + string filter_characters = ""; bool specific_formats = false; bool write_ttf = false; bool write_svg = false; @@ -44,7 +46,7 @@ Theme.set_default_colors (); BirdFont.current_font = BirdFont.new_font (); - BirdFont.current_glyph_collection = new GlyphCollection.with_glyph ( '\0', "null"); + BirdFont.current_glyph_collection = new GlyphCollection.with_glyph ('\0', "null"); main_window = new MainWindow (); // FIXME: create a option for this and add structure the log messages @@ -82,7 +84,13 @@ specific_formats = true; continue; } - + + if (arg[i] == "--filter" && i + 1 < arg.length) { + filter_characters = arg[i + 1]; + i++; + continue; + } + if (arg[i].has_prefix ("-")) { print_export_help (arg); return 1; @@ -122,6 +130,16 @@ } return 1; + } + + if (filter_characters != "") { + stdout.printf ("Exporting only %s\n", filter_characters); + + + int characters_count = filter_characters.char_count (); + for (int i = 0; i < characters_count; i++) { + filter_characters.get_char (filter_characters.index_of_nth_char (i)); + } } directory = File.new_for_path (output_directory);
--- a/libbirdfont/OpenFontFormat/PostTable.vala +++ b/libbirdfont/OpenFontFormat/PostTable.vala @@ -1101,8 +1101,6 @@ assert (names.size == 0); add_standard_names (); - - print ("Adding post names\n"); for (int i = 1; i < glyf_table.glyphs.size; i++) { gc = glyf_table.glyphs.get (i);
--- a/resources/linux/birdfont-export.1 +++ b/resources/linux/birdfont-export.1 @@ -11,6 +11,9 @@ See http://birdfont.org for use cases. .SH OPTIONS .TP 5 + \--filter [characters] + Include only these characters + .TP \-h, \--help Print command line options. .TP