Commit 3f9feec
parse svg files
Changed files (6)
modifiedbirdfont/GtkWindow.valamodifieddodo.pymodifiedlibbirdfont/ExportTool.valaaddedlibbirdfont/ImportSvg.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/Supplement.vala
Diff
@@ -297,7 +297,13 @@ public class GtkWindow : Gtk.Window, NativeWindow { Gtk.MenuItem export_svg_item = new Gtk.MenuItem.with_mnemonic (_("_Export glyph as SVG")); edit_menu.append (export_svg_item); export_svg_item.activate.connect (() => { ExportTool.export_current_glyph (); }); - + + if (Supplement.experimental) {+ Gtk.MenuItem import_svg_item = new Gtk.MenuItem.with_mnemonic (_("_Import SVG"));+ edit_menu.append (import_svg_item);+ import_svg_item.activate.connect (() => { ImportSvg.import (); }); + }+ // Tab Gtk.MenuItem next_tab_item = new Gtk.MenuItem.with_mnemonic (_("_Next tab")); tab_menu.append (next_tab_item);@@ -30,6 +30,7 @@ LIBS = [ ] + def task_build (): if not os.path.exists ("build/configured"): print ("Project is not configured")@@ -106,3 +107,4 @@ def task_distclean (): return { 'actions': ['rm -rf build dodo.pyc libbirdfont/Config.vala'], }+@@ -101,8 +101,7 @@ public class ExportTool : Tool { os.put_string (@"style=\"fill:#000000;stroke-width:0px\" "); os.put_string (@"d=\"$(glyph_svg)\" id=\"path_$(name)$(pid++)\" />\n"); - os.put_string ("""</g>- + os.put_string ("""</g> </svg>"""); } catch (Error e) {new file mode 100644@@ -0,0 +1,96 @@+/*+ 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 Xml;++namespace Supplement {+ +public class ImportSvg {+ public ImportSvg () {+ }+ + public static void import () {+ Xml.Doc* doc;+ Xml.Node* root = null;+ Xml.Node* node;+ string? p;+ string path;+ + p = MainWindow.file_chooser ("Import");++ if (p == null) {+ return;+ }++ path = (!) p;++ Parser.init ();++ doc = Parser.parse_file (path);+ root = doc->get_root_element ();+ + if (root == null) {+ delete doc;+ return;+ }++ node = root;+ + for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {+ if (iter->name == "g") {+ parse_layer (iter);+ }+ }+ + delete doc;+ Parser.cleanup (); + }+ + private static void parse_layer (Xml.Node* node) {+ string attr_name = "";+ string attr_content;+ + return_if_fail (node != null);+ + for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {+ if (iter->name == "path") {+ parse_path (iter);+ }+ }+ }+ + private static void parse_path (Xml.Node* node) {+ string attr_name = "";+ string attr_content;+ + for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {+ attr_name = prop->name;+ attr_content = prop->children->content;+ + if (attr_name == "d") {+ parse_svg_data (attr_content);+ }+ }+ }+ + private static void parse_svg_data (string data) {+ }+ + static void parse_c (string[] data, int index, Path p, double posx, double posy) {+ }+}++}@@ -58,7 +58,7 @@ public class Path { private static ImageSurface? selected_edit_point_image = null; private static ImageSurface? active_selected_edit_point_image = null; - Path quadratic_path; // quadratic points for ttf export+ Path quadratic_path; // quadratic points for TrueType export public Path () { if (edit_point_image == null) {@@ -24,7 +24,7 @@ namespace Supplement { public class Supplement { public static Argument args; - internal static bool experimental = false; + public static bool experimental = false; internal static bool show_coordinates = false; internal static bool fatal_wanings = false; public static bool win32 = false;