Clone in a terminal:
Commit 2c8c9a4
Johan Mattsson - 2014-09-25T17:26:38+00:00
2c8c9a4ba057e3a299785284689f9dcc3e4f2457johan.mattsson.m@gmail.com

Merge branch 'master' of gitorious.org:birdfont/birdfont

Changed files (16)

Diff

diff --git a/dodo.py b/dodo.pyindex 7fd974f..fe96c41 100644--- a/dodo.py+++ b/dodo.py@@ -30,6 +30,7 @@ from scripts import config DOIT_CONFIG = {     'default_tasks': [         'build',+        'libbirdxml',         'libbirdfont',         'birdfont',         'birdfont_autotrace',@@ -43,7 +44,6 @@ DOIT_CONFIG = { # external Vala libs LIBS = [     'glib-2.0',-    'libxml-2.0',     'gio-2.0',     'cairo',     'gdk-pixbuf-2.0',@@ -53,6 +53,10 @@ LIBS = [     'libgit2'     ] +LIBBIRD_XML_LIBS = [+    'glib-2.0'+    ]+ def task_build ():     if not os.path.exists ("build/configured"):         print ("Project is not configured")@@ -83,34 +87,43 @@ valac_options = [ 	'--target-glib=2.34', # see bug 0000004 	'--define=LINUX' 	]-libbird = Vala(src='libbirdfont', build='build', library='birdfont', so_version=version.SO_VERSION, pkg_libs=LIBS)++libbirdxml = Vala(src='libbirdxml', build='build', library='birdxml', so_version=version.LIBBIRDXML_SO_VERSION, pkg_libs=LIBBIRD_XML_LIBS)+def task_libbirdxml():+    yield libbirdxml.gen_c(valac_options)+    yield libbirdxml.gen_o(['-fPIC'])+    yield libbirdxml.gen_so()+    yield libbirdxml.gen_ln()+    ++libbird = Vala(src='libbirdfont', build='build', library='birdfont', so_version=version.SO_VERSION, pkg_libs=LIBS, vala_deps=[libbirdxml]) def task_libbirdfont():     yield libbird.gen_c(valac_options)-    yield libbird.gen_o(['-fPIC', """-D 'GETTEXT_PACKAGE="birdfont"'"""])+    yield libbird.gen_o(['-fPIC -I./build/', """-D 'GETTEXT_PACKAGE="birdfont"'"""])     yield libbird.gen_so()     yield libbird.gen_ln()   def task_birdfont():-    bird = Vala(src='birdfont', build='build', pkg_libs=LIBS, vala_deps=[libbird])+    bird = Vala(src='birdfont', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdxml])     yield bird.gen_c(valac_options)     yield bird.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """])   def task_birdfont_autotrace():-     exp = Vala(src='birdfont-autotrace', build='build', pkg_libs=LIBS, vala_deps=[libbird])+     exp = Vala(src='birdfont-autotrace', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdxml])      yield exp.gen_c(valac_options)      yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """])   def task_birdfont_export():-     exp = Vala(src='birdfont-export', build='build', pkg_libs=LIBS, vala_deps=[libbird])+     exp = Vala(src='birdfont-export', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdxml])      yield exp.gen_c(valac_options)      yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """])   def task_birdfont_import():-     exp = Vala(src='birdfont-import', build='build', pkg_libs=LIBS, vala_deps=[libbird])+     exp = Vala(src='birdfont-import', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdxml])      yield exp.gen_c(valac_options)      yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """]) diff --git a/install.py b/install.pyindex b420999..3a9b05c 100755--- a/install.py+++ b/install.py@@ -1,6 +1,6 @@ #!/usr/bin/python  """-Copyright (C) 2013 Johan Mattsson+Copyright (C) 2013 2014 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@@ -102,13 +102,19 @@ install ('build/bin/birdfont-import', '/bin', 755)  #library if not options.libdir:-	p = platform.machine()- 	if p == 'i386' or p == 's390' or p == 'ppc' or p == 'armv7hl':- 		libdir = '/lib'- 	elif p == 'x86_64' or p == 's390x' or p == 'ppc64':- 		libdir = '/lib64'- 	else:-		libdir = '/lib'+	+	if platform.dist()[0] == 'Ubuntu' or platform.dist()[0] == 'Debian':+		process = subprocess.Popen(['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], stdout=subprocess.PIPE)+		out, err = process.communicate()+		libdir = '/lib/' + out.rstrip ('\n')+	else:+		p = platform.machine()+		if p == 'i386' or p == 's390' or p == 'ppc' or p == 'armv7hl':+			libdir = '/lib'+		elif p == 'x86_64' or p == 's390x' or p == 'ppc64':+			libdir = '/lib64'+		else:+			libdir = '/lib' else: 	libdir = options.libdir @@ -125,8 +131,25 @@ elif os.path.isfile ('build/bin/libbirdfont.' + version.SO_VERSION + '.dylib'): 	link (libdir, 'libbirdfont.' + version.SO_VERSION + '.dylib', ' libbirdfont.dylib.' + version.SO_VERSION_MAJOR) 	link (libdir, 'libbirdfont.' + version.SO_VERSION + '.dylib', ' libbirdfont.dylib') else:-	print ("Can not find libbirdfont.")+	print ("Can't find libbirdfont.") 	exit (1)+++if os.path.isfile ('build/bin/libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION):+        install ('build/bin/libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, libdir, 644)+        link (libdir, 'libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, ' libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION_MAJOR)+        link (libdir, 'libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, ' libbirdxml.so')+elif os.path.isfile ('build/libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION):+        install ('build/libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, libdir, 644)+        link (libdir, 'libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, ' libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION_MAJOR)+        link (libdir, 'libbirdxml.so.' + version.LIBBIRDXML_SO_VERSION, ' libbirdxml.so')+elif os.path.isfile ('build/bin/libbirdxml.' + version.LIBBIRDXML_SO_VERSION + '.dylib'):+        install ('build/bin/libbirdxml.' + version.LIBBIRDXML_SO_VERSION + '.dylib', libdir, 644)+        link (libdir, 'libbirdxml.' + version.LIBBIRDXML_SO_VERSION + '.dylib', ' libbirdxml.dylib.' + version.LIBBIRDXML_SO_VERSION_MAJOR)+        link (libdir, 'libbirdxml.' + version.LIBBIRDXML_SO_VERSION + '.dylib', ' libbirdxml.dylib')+else:+        print ("Can't find libbirdxml.")+ 	 #manpages if not nogzip:diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 57006f9..25f1865 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -11,7 +11,7 @@     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      Lesser General Public License for more details. */-using Xml;+using Bird;  namespace BirdFont { @@ -31,38 +31,30 @@ class BirdFontFile : GLib.Object { 	 * @param path path to a valid .bf file 	 */ 	public bool load (string path) {-		TextReader tr;+		string xml_data;+		XmlParser parser; 		bool ok;-		-		Parser.init ();+	+		FileUtils.get_contents(path, out xml_data); 		 		font.background_images.clear ();-		 		font.font_file = path;-		tr = new TextReader.filename (path);-		-		if (is_null (tr)) {-			warning (@"Failed to create TextReader for path: $path");-		}-		-		ok = load_xml (tr); 		-		// This causes a crash on windows-		// Parser.cleanup ();+		parser = new XmlParser (xml_data);+		ok = load_xml (parser); 				 		return ok; 	}  	public bool load_part (string bfp_file) {-		TextReader tr;+		string xml_data;+		XmlParser parser; 		bool ok;-		Parser.init ();-		tr = new TextReader.filename (bfp_file);-		ok = load_xml (tr);+	+		FileUtils.get_contents(bfp_file, out xml_data);+		parser = new XmlParser (xml_data);+		ok = load_xml (parser); 		-		// This causes a crash on windows-		// Parser.cleanup ();-				 		return ok; 	} @@ -70,33 +62,23 @@ class BirdFontFile : GLib.Object { 	 * @param xml_data data for a valid .bf file 	 */ 	public bool load_data (string xml_data) {-		TextReader tr; 		bool ok;+		XmlParser parser; 		-		Parser.init (); 		font.font_file = "typeface.bf";-		tr = new TextReader.for_doc (xml_data, "");-		ok = load_xml (tr);-		Parser.cleanup ();+		parser = new XmlParser (xml_data);+		ok = load_xml (parser); 		 		return ok; 	} -	private bool load_xml (TextReader tr) {+	private bool load_xml (XmlParser parser) { 		bool ok = true;-		Xml.Node* root; 		-		tr.read ();-		root = tr.expand ();--		if (!is_null (root)) {-			create_background_files (root);-			ok = parse_file (root);-		} else {-			warning ("No root element");-		}+		create_background_files (parser.get_next_tag ()); 		-		tr.close ();+		parser.reparse ();+		ok = parse_file (parser.get_next_tag ()); 		 		return ok; 	}@@ -593,98 +575,83 @@ class BirdFontFile : GLib.Object { 		}			 	} -	private bool parse_file (Xml.Node* root) {-		Xml.Node* node = root;-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {+	private bool parse_file (Tag tag) {+		Tag t;+		+		tag.reparse ();+		while (tag.has_more_tags ()) {+			t = tag.get_next_tag (); -			// this is a backup file set path to the original -			if (iter->name == "backup") {-				font.font_file = iter->children->content;-			}-				-			// old glyph format-			if (iter->name == "glyph") {-				parse_ffi_glyph (iter);+			// this is a backup file, but path pointing to the original file+			if (t.get_name () == "backup") {+				font.font_file = t.get_content (); 			} 			-			// new glyph format-			if (iter->name == "collection") {-				parse_glyph_collection (iter);-			}--			// horizontal lines in the old format-			if (iter->name == "lines") {-				parse_font_boundaries (iter);+			// glyph format+			if (t.get_name () == "collection") {+				parse_glyph_collection (t); 			} 			 			// horizontal lines in the new format-			if (iter->name == "horizontal") {-				parse_horizontal_lines (iter);+			if (t.get_name () == "horizontal") {+				parse_horizontal_lines (t); 			}			 			 			// grid buttons-			if (iter->name == "grid") {-				parse_grid (iter);+			if (t.get_name () == "grid") {+				parse_grid (t); 			} -			if (iter->name == "background") {-				parse_background (iter);-			}-			-			if (iter->name == "images") {-				parse_background_selection (iter);+			if (t.get_name () == "background") {+				parse_background (t); 			} -			if (iter->name == "postscript_name" && iter->children != null) {-				font.postscript_name = iter->children->content;+			if (t.get_name () == "postscript_name") {+				font.postscript_name = t.get_content (); 			} 			-			if (iter->name == "name" && iter->children != null) {-				font.name = iter->children->content;+			if (t.get_name () == "name") {+				font.name = t.get_content (); 			} -			if (iter->name == "subfamily" && iter->children != null) {-				font.subfamily = iter->children->content;+			if (t.get_name () == "subfamily") {+				font.subfamily = t.get_content (); 			} -			if (iter->name == "bold" && iter->children != null) {-				font.bold = bool.parse (iter->children->content);+			if (t.get_name () == "bold") {+				font.bold = bool.parse (t.get_content ()); 			} 			-			if (iter->name == "italic" && iter->children != null) {-				font.italic = bool.parse (iter->children->content);+			if (t.get_name () == "italic") {+				font.italic = bool.parse (t.get_content ()); 			} 			-			if (iter->name == "full_name" && iter->children != null) {-				font.full_name = iter->children->content;+			if (t.get_name () == "full_name") {+				font.full_name = t.get_content (); 			} 			-			if (iter->name == "unique_identifier" && iter->children != null) {-				font.unique_identifier = iter->children->content;+			if (t.get_name () == "unique_identifier") {+				font.unique_identifier = t.get_content (); 			} -			if (iter->name == "version" && iter->children != null) {-				font.version = iter->children->content;+			if (t.get_name () == "version") {+				font.version = t.get_content (); 			} -			if (iter->name == "description" && iter->children != null) {-				font.description = iter->children->content;+			if (t.get_name () == "description") {+				font.description = t.get_content (); 			} 			-			if (iter->name == "copyright" && iter->children != null) {-				font.copyright = iter->children->content;-			}-						-			if (iter->name == "hkern") {-				parse_old_kerning (iter);+			if (t.get_name () == "copyright") {+				font.copyright = t.get_content (); 			} -			if (iter->name == "kerning") {-				parse_kerning (iter);+			if (t.get_name () == "kerning") {+				parse_kerning (t); 			} -			if (iter->name == "spacing") {-				parse_spacing_class (iter);+			if (t.get_name () == "spacing") {+				parse_spacing_class (t); 			} 									 			TooltipArea.show_text (t_("Loading XML data."));@@ -694,15 +661,18 @@ class BirdFontFile : GLib.Object { 		return true; 	} 	-	private void create_background_files (Xml.Node* root) requires (root != null) {-		for (Xml.Node* iter = root->children; iter != null; iter = iter->next) {			-			if (iter->name == "name" && iter->children != null) {-				font.set_name (iter->children->content);-			}+	private void create_background_files (Tag root) {+		Tag child;+		while (root.has_more_tags ()) {+			child = root.get_next_tag (); 			-			if (iter->name == "background-image") {-				parse_background_image (iter);+			if (child.get_name () == "name") {+				font.set_name (child.get_content ()); 			}++			if (child.get_name () == "background-image") {+				parse_background_image (child);+			}			 		} 	} @@ -725,56 +695,54 @@ class BirdFontFile : GLib.Object { 		return GlyphRange.get_serialized_char (c); 	} 	-	private void parse_spacing_class (Xml.Node* node) {-		string attr_name;-		string attr_content;+	private void parse_spacing_class (Tag tag) { 		string first, next; 		SpacingClassTab spacing_class_tab = MainWindow.get_spacing_class_tab ();+		Attribute attr; 		 		first = ""; 		next = ""; 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "first") {-				first = (!) Font.to_unichar (attr_content).to_string ();+			if (attr.get_name () == "first") {+				first = (!) Font.to_unichar (attr.get_content ()).to_string (); 			} -			if (attr_name == "next") {-				next = (!) Font.to_unichar (attr_content).to_string ();+			if (attr.get_name () == "next") {+				next = (!) Font.to_unichar (attr.get_content ()).to_string (); 			}		 		} 		 		spacing_class_tab.add_class (first, next); 	} 	-	private void parse_kerning (Xml.Node* node) {-		string attr_name;-		string attr_content;+	private void parse_kerning (Tag tag) { 		GlyphRange range_left, range_right; 		double hadjustment = 0; 		KerningRange kerning_range;+		Attribute attr; 		 		try { 			range_left = new GlyphRange (); 			range_right = new GlyphRange ();-				-			for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-				attr_name = prop->name;-				attr_content = prop->children->content;-				-				if (attr_name == "left") {-					range_left.parse_ranges (unserialize (attr_content));+			+			tag.reparse ();+			while (tag.has_more_attributes ()) {+				attr = tag.get_next_attribute ();++				if (attr.get_name () == "left") {+					range_left.parse_ranges (unserialize (attr.get_content ())); 				} -				if (attr_name == "right") {-					range_right.parse_ranges (unserialize (attr_content));+				if (attr.get_name () == "right") {+					range_right.parse_ranges (unserialize (attr.get_content ())); 				} -				if (attr_name == "hadjustment") {-					hadjustment = double.parse (attr_content);+				if (attr.get_name () == "hadjustment") {+					hadjustment = double.parse (attr.get_content ()); 				}				 			} 			@@ -797,55 +765,8 @@ class BirdFontFile : GLib.Object { 		} 	} 	-	private void parse_old_kerning (Xml.Node* node) {-		string attr_name;-		string attr_content;-		string left = "";-		string right = "";-		string kern = "";-		GlyphRange grr, grl;--		StringBuilder b;-		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;-			-			if (attr_name == "left") {-				b = new StringBuilder ();-				b.append_unichar (Font.to_unichar (attr_content));-				left = @"$(b.str)";-			}--			if (attr_name == "right") {-				b = new StringBuilder ();-				b.append_unichar (Font.to_unichar (attr_content));-				right = @"$(b.str)";-			}-			-			if (attr_name == "kerning") {-				kern = attr_content;-			}-		}--		try {-			grl = new GlyphRange ();-			grl.parse_ranges (left);--			grr = new GlyphRange ();-			grr.parse_ranges (right);-			-			KerningClasses.get_instance ().set_kerning (grl, grr, double.parse (kern));	-		} catch (MarkupError e) {-			warning (e.message);-		}-	}-	-	private void parse_background_image (Xml.Node* node) -		requires (node != null)-	{-		string attr_name;-		string attr_content;+	private void parse_background_image (Tag tag) {+		Attribute attr; 		 		string file = ""; 		string data = "";@@ -855,20 +776,16 @@ class BirdFontFile : GLib.Object { 		FileOutputStream file_stream; 		DataOutputStream png_stream; 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			return_if_fail (!is_null (prop->name));-			return_if_fail (!is_null (prop->children));-			return_if_fail (!is_null (prop->children->content));-			-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "sha1") {-				file = attr_content;+			if (attr.get_name () == "sha1") {+				file = attr.get_content (); 			}-			-			if (attr_name == "data") {-				data = attr_content;++			if (attr.get_name () == "data") {+				data = attr.get_content (); 			} 		} @@ -899,125 +816,75 @@ class BirdFontFile : GLib.Object { 		} 	} 	-	private void parse_background (Xml.Node* node) -		requires (node != null)-	{-		string attr_name;-		string attr_content;-				-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			-			return_if_fail (!is_null (prop->name));-			return_if_fail (!is_null (prop->children));-			return_if_fail (!is_null (prop->children->content));-			-			attr_name = prop->name;-			attr_content = prop->children->content;+	private void parse_background (Tag tag) {+		Attribute attr;+		+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "scale") {-				font.background_scale = attr_content;+			if (attr.get_name () == "scale") {+				font.background_scale = attr.get_content (); 			} 		} 	} 	-	private void parse_background_selection (Xml.Node* node) {-		string attr_name = "";-		string attr_content;+	private void parse_grid (Tag tag) {+		Attribute attr; 		-		return_if_fail (node != null);-				-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "img") {-				for (Xml.Attr* prop = iter->properties; prop != null; prop = prop->next) {-					attr_name = prop->name;-					attr_content = prop->children->content;-					-					if (attr_name == "src") {-						font.background_images.add (attr_content);-					}-				}-			}-		}-	}-	-	private void parse_grid (Xml.Node* node) {-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			string attr_name = prop->name;-			string attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "width") {-				font.grid_width.add (attr_content);+			if (attr.get_name () == "width") {+				font.grid_width.add (attr.get_content ()); 			} 		}		 	} 	-	private void parse_horizontal_lines (Xml.Node* node) {-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "top_limit" && "" != iter->children->content) {-				font.top_limit = parse_double_from_node (iter);+	private void parse_horizontal_lines (Tag tag) {+		Tag t;+		+		tag.reparse ();+		while (tag.has_more_tags ()) {+			t = tag.get_next_tag ();+			if (t.get_name () == "top_limit" && t.get_content () != "") {+				font.top_limit = parse_double_from_node (t); 			} 			-			if (iter->name == "top_position" && "" != iter->children->content) {-				font.top_position = parse_double_from_node (iter);+			if (t.get_name () == "top_position" && t.get_content () != "") {+				font.top_position = parse_double_from_node (t); 			} 			-			if (iter->name == "x-height" && "" != iter->children->content) {-				font.xheight_position = parse_double_from_node (iter);+			if (t.get_name () == "x-height" && t.get_content () != "") {+				font.xheight_position = parse_double_from_node (t); 			} 			-			if (iter->name == "base_line" && "" != iter->children->content) {-				font.base_line = parse_double_from_node (iter);+			if (t.get_name () == "base_line" && t.get_content () != "") {+				font.base_line = parse_double_from_node (t); 			} 			-			if (iter->name == "bottom_position" && "" != iter->children->content) {-				font.bottom_position = parse_double_from_node (iter);+			if (t.get_name () == "bottom_position" && t.get_content () != "") {+				font.bottom_position = parse_double_from_node (t); 			} 			-			if (iter->name == "bottom_limit" && "" != iter->children->content) {-				font.bottom_limit = parse_double_from_node (iter);+			if (t.get_name () == "bottom_limit" && t.get_content () != "") {+				font.bottom_limit = parse_double_from_node (t); 			} 		}	 	} 	-	/** @deprecated horizontal in older .bf files */-	private void parse_font_boundaries (Xml.Node* node) {-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "top_limit" && "" != iter->children->content) {-				font.top_limit = -parse_double_from_node (iter);-			}-			-			if (iter->name == "top_position" && "" != iter->children->content) {-				font.top_position = -parse_double_from_node (iter);-			}-			-			if (iter->name == "x-height" && "" != iter->children->content) {-				font.xheight_position = -parse_double_from_node (iter);-			}-			-			if (iter->name == "base_line" && "" != iter->children->content) {-				font.base_line = -parse_double_from_node (iter);-			}-			-			if (iter->name == "bottom_position" && "" != iter->children->content) {-				font.bottom_position = -parse_double_from_node (iter);-			}-			-			if (iter->name == "bottom_limit" && "" != iter->children->content) {-				font.bottom_limit = -parse_double_from_node (iter);-			}-		}			-	}-	-	private double parse_double_from_node (Xml.Node* iter) {+	private double parse_double_from_node (Tag tag) { 		double d;-		bool r = double.try_parse (iter->children->content, out d);+		bool r = double.try_parse (tag.get_content (), out d);+		string s; 		 		if (unlikely (!r)) {-			string? s = iter->content;-			if (s == null) {-				warning (@"Content is null for node $(iter->name)\n");+			s = tag.get_content ();+			if (s == "") {+				warning (@"No content for node\n"); 			} else {-				warning (@"Failed to parse double for \"$(iter->content)\"\n");+				warning (@"Failed to parse double for \"$(tag.get_content ())\"\n"); 			} 		} 		@@ -1025,23 +892,22 @@ class BirdFontFile : GLib.Object { 	}  	/** Parse the new glyph format */-	private void parse_glyph_collection (Xml.Node* node) {+	private void parse_glyph_collection (Tag tag) { 		unichar unicode = 0; 		GlyphCollection gc; 		GlyphCollection? current_gc; 		bool new_glyph_collection;-		string attr_name;-		string attr_content; 		StringBuilder b; 		string name = ""; 		int selected_id = -1;-				-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;-			-			if (attr_name == "unicode") {-				unicode = Font.to_unichar (attr_content);+		Attribute attribute;+		Tag t;+		+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attribute = tag.get_next_attribute ();+			if (attribute.get_name () == "unicode") {+				unicode = Font.to_unichar (attribute.get_content ()); 				b = new StringBuilder (); 				b.append_unichar (unicode); 				name = b.str;@@ -1056,16 +922,22 @@ class BirdFontFile : GLib.Object { 		new_glyph_collection = (current_gc == null); 		gc = (!new_glyph_collection) ? (!) current_gc : new GlyphCollection (unicode, name); -		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "selected") {-				selected_id = parse_selected (iter);+		tag.reparse ();+		while (tag.has_more_tags ()) {+			t = tag.get_next_tag ();+			+			if (t.get_name () == "selected") {+				selected_id = parse_selected (t); 				gc.set_selected_version (selected_id); 			} 		}-				-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "glyph") {-				parse_glyph (iter, gc, name, unicode, selected_id);+		+		tag.reparse ();			+		while (tag.has_more_tags ()) {+			t = tag.get_next_tag ();+			+			if (t.get_name () == "glyph") {+				parse_glyph (t, gc, name, unicode, selected_id); 			} 		} 		@@ -1074,18 +946,17 @@ class BirdFontFile : GLib.Object { 		} 	} -	private int parse_selected (Xml.Node* node) {-		string attr_name;-		string attr_content;+	private int parse_selected (Tag tag) { 		int id = 1; 		bool has_selected_tag = false;+		Attribute attribute; -		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;-			-			if (attr_name == "id") {-				id = int.parse (attr_content);+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attribute = tag.get_next_attribute ();++			if (attribute.get_name () == "id") {+				id = int.parse (attribute.get_content ()); 				has_selected_tag = true; 				break; 			}@@ -1098,47 +969,49 @@ class BirdFontFile : GLib.Object { 		return id; 	} -	private void parse_glyph (Xml.Node* node, GlyphCollection gc, string name, unichar unicode, int selected_id) {	-		string attr_name;-		string attr_content;+	private void parse_glyph (Tag tag, GlyphCollection gc, string name, unichar unicode, int selected_id) {	 		Glyph glyph = new Glyph (name, unicode); 		Path path; 		bool selected = false; 		bool has_id = false; 		int id = 1;+		Attribute attr;+		Tag t; 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "left") {-				glyph.left_limit = double.parse (attr_content);+			if (attr.get_name () == "left") {+				glyph.left_limit = double.parse (attr.get_content ()); 			} 			-			if (attr_name == "right") {-				glyph.right_limit = double.parse (attr_content);+			if (attr.get_name () == "right") {+				glyph.right_limit = double.parse (attr.get_content ()); 			}  			// id is unique within the glyph collection-			if (attr_name == "id") {-				id = int.parse (attr_content);+			if (attr.get_name () == "id") {+				id = int.parse (attr.get_content ()); 				has_id = true; 			}  			// old way of selecting a glyph in the version list-			if (attr_name == "selected") {-				selected = bool.parse (attr_content);+			if (attr.get_name () == "selected") {+				selected = bool.parse (attr.get_content ()); 			} 		} 		-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "path") {-				path = parse_path (iter);+		tag.reparse ();+		while (tag.has_more_tags ()) {+			t = tag.get_next_tag ();+			if (t.get_name () == "path") {+				path = parse_path (t); 				glyph.add_path (path); 			} 			-			if (iter->name == "background") {-				parse_background_scale (glyph, iter);+			if (t.get_name () == "background") {+				parse_background_scale (glyph, t); 			} 		} @@ -1146,33 +1019,32 @@ class BirdFontFile : GLib.Object { 		gc.insert_glyph (glyph, selected || selected_id == id); 	} -	private Path parse_path (Xml.Node* node) {	-		string attr_name;-		string attr_content;+	private Path parse_path (Tag tag) {	 		Path path = new Path ();+		Attribute attr; 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "data") {-				path = parse_path_data (attr_content);+			if (attr.get_name () == "data") {+				path = parse_path_data (attr.get_content ()); 			} 		} -		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); -			if (attr_name == "stroke") {-				path.set_stroke (double.parse (attr_content));+			if (attr.get_name () == "stroke") {+				path.set_stroke (double.parse (attr.get_content ())); 			} -			if (attr_name == "skew") {-				path.skew = (double.parse (attr_content));-			}			+			if (attr.get_name () == "skew") {+				path.skew = double.parse (attr.get_content ());+			}	+		} 			-		}		 		if (path.points.size == 0) { 			warning ("Empty path"); 		}@@ -1462,110 +1334,19 @@ class BirdFontFile : GLib.Object { 		return 0; 	} 	-	/** Parse one glyph in the old ffi format. */-	private void parse_ffi_glyph (Xml.Node* node) {-		string name = "";-		int left = 0;-		int right = 0;-		unichar uni = 0;-		int version = 0;-		bool selected = false;-		Glyph g;-		GlyphCollection? gc;-		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			string attr_name = prop->name;-			string attr_content = prop->children->content;-			StringBuilder b;-			-			if (attr_name == "unicode") {-				uni = Font.to_unichar (attr_content);-				b = new StringBuilder ();-				b.append_unichar (uni);-				name = b.str;-			}--			if (attr_name == "left") {-				left = int.parse (attr_content);-			}-			-			if (attr_name == "right") {-				right = int.parse (attr_content);-			}-			-			if (attr_name == "version") {-				version = int.parse (attr_content);-			}-			-			if (attr_name == "selected") {-				selected = bool.parse (attr_content);-			}-		}--		g = new Glyph (name, uni);-		-		g.left_limit = left;-		g.right_limit = right;--		parse_content (g, node);-		-		gc = font.get_glyph_collection (g.get_name ());-		-		if (g.get_name () == "") {-			warning ("No name set for glyph.");-		}-				-		if (gc == null) {-			gc = new GlyphCollection (uni, name);-			((!) gc).insert_glyph (g, selected);-			font.add_glyph_collection ((!) gc);-		} else {-			((!)gc).insert_glyph (g, selected);-		}-	}-	-	/** Parse visual objects and paths -	 * @deprecated ffi format use bf-	 */-	private void parse_content (Glyph g, Xml.Node* node) {-		Xml.Node* i;-		return_if_fail (node != null);-		-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "object") {-				Path p = new Path ();-				-				for (i = iter->children; i != null; i = i->next) {-					if (i->name == "point") {-						parse_point (p, i);-					}					-				}--				p.close ();-				g.add_path (p);-			}-			-			if (iter->name == "background") {-				parse_background_scale (g, iter);-			}-		}-	}-	-	private void parse_background_scale (Glyph g, Xml.Node* node) {+	private void parse_background_scale (Glyph g, Tag tag) { 		BackgroundImage img; 		BackgroundImage? new_img = null;-		-		string attr_name = "";-		string attr_content;+		Attribute attr; 		 		File img_file = font.get_backgrounds_folder ().get_child ("parts"); 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "sha1") {-				img_file = img_file.get_child (attr_content + ".png");+			if (attr.get_name () == "sha1") {+				img_file = img_file.get_child (attr.get_content () + ".png");  				if (!img_file.query_exists ()) { 					warning (@"Background file has not been created yet. $((!) img_file.get_path ())");@@ -1577,121 +1358,39 @@ class BirdFontFile : GLib.Object { 		} 		 		if (unlikely (new_img == null)) {-			warning (@"No source for image found for $attr_name in $(g.name)");+			warning ("No source for image found."); 			return; 		} 	 		img = (!) new_img; 	-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();	+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 							-			if (attr_name == "x") {-				img.img_x = double.parse (attr_content);+			if (attr.get_name () == "x") {+				img.img_x = double.parse (attr.get_content ()); 			} 			-			if (attr_name == "y") {-				img.img_y = double.parse (attr_content);+			if (attr.get_name () == "y") {+				img.img_y = double.parse (attr.get_content ()); 			}	 -			if (attr_name == "scale_x") {-				img.img_scale_x = double.parse (attr_content);+			if (attr.get_name () == "scale_x") {+				img.img_scale_x = double.parse (attr.get_content ()); 			} -			if (attr_name == "scale_y") {-				img.img_scale_y = double.parse (attr_content);+			if (attr.get_name () == "scale_y") {+				img.img_scale_y = double.parse (attr.get_content ()); 			} 						-			if (attr_name == "rotation") {-				img.img_rotation = double.parse (attr_content);+			if (attr.get_name () == "rotation") {+				img.img_rotation = double.parse (attr.get_content ()); 			} 		} 		 		img.set_position (img.img_x, img.img_y);	 	}-	-	private void parse_point (Path p, Xml.Node* iter) {-		double x = 0;-		double y = 0;-		-		double angle_right = 0;-		double angle_left = 0;-		-		double length_right = 0;-		double length_left = 0;-		-		PointType type_right = PointType.LINE_CUBIC;-		PointType type_left = PointType.LINE_CUBIC;-		-		bool tie_handles = false;-		-		EditPoint ep;-		-		for (Xml.Attr* prop = iter->properties; prop != null; prop = prop->next) {-			string attr_name = prop->name;-			string attr_content = prop->children->content;-						-			if (attr_name == "x") x = double.parse (attr_content);-			if (attr_name == "y") y = double.parse (attr_content);--			if (attr_name == "right_type" && attr_content == "linear") {-				type_right = PointType.LINE_CUBIC;-			}	--			if (attr_name == "left_type" && attr_content == "linear") {-				type_left = PointType.LINE_CUBIC;-			}	--			if (attr_name == "right_type" && attr_content == "quadratic") {-				type_right = PointType.QUADRATIC;-			}	--			if (attr_name == "left_type" && attr_content == "quadratic") {-				type_left = PointType.QUADRATIC;-			}--			if (attr_name == "right_type" && attr_content == "cubic") {-				type_right = PointType.CUBIC;-			}	--			if (attr_name == "left_type" && attr_content == "cubic") {-				type_left = PointType.CUBIC;-			}-			-			if (attr_name == "right_angle") angle_right = double.parse (attr_content);-			if (attr_name == "right_length") length_right = double.parse (attr_content);-			if (attr_name == "left_angle") angle_left = double.parse (attr_content);-			if (attr_name == "left_length") length_left = double.parse (attr_content);-			-			if (attr_name == "tie_handles") tie_handles = bool.parse (attr_content);-		}-	-		// backward compabtility-		if (type_right == PointType.LINE_CUBIC && length_right != 0) {-			type_right = PointType.CUBIC;-		}--		if (type_left == PointType.LINE_CUBIC && length_left != 0) {-			type_left = PointType.CUBIC;-		}-		-		ep = new EditPoint (x, y);-					-		ep.right_handle.angle = angle_right;-		ep.right_handle.length = length_right;-		ep.right_handle.type = type_right;-		-		ep.left_handle.angle = angle_left;-		ep.left_handle.length = length_left;-		ep.left_handle.type = type_left;-		-		ep.tie_handles = tie_handles;-		-		ep.type = type_right;-		-		p.add_point (ep);-	} }  }diff --git a/libbirdfont/Kerning.vala b/libbirdfont/Kerning.valaindex ab0ee52..f32d43a 100644--- a/libbirdfont/Kerning.vala+++ b/libbirdfont/Kerning.vala@@ -13,7 +13,7 @@ */  using Cairo;-using Xml;+using Bird;  namespace BirdFont { diff --git a/libbirdfont/KerningClasses.vala b/libbirdfont/KerningClasses.valaindex 67d633c..d702266 100644--- a/libbirdfont/KerningClasses.vala+++ b/libbirdfont/KerningClasses.vala@@ -13,7 +13,7 @@ */  using Cairo;-using Xml;+using Bird; using Math; using Gee; diff --git a/libbirdfont/OpenFontFormat/KerningPair.vala b/libbirdfont/OpenFontFormat/KerningPair.valaindex d3f635b..740521b 100644--- a/libbirdfont/OpenFontFormat/KerningPair.vala+++ b/libbirdfont/OpenFontFormat/KerningPair.vala@@ -13,7 +13,7 @@ */  using Cairo;-using Xml;+using Bird;  namespace BirdFont { diff --git a/libbirdfont/SvgFont.vala b/libbirdfont/SvgFont.valaindex 6e3bd8c..e468c21 100644--- a/libbirdfont/SvgFont.vala+++ b/libbirdfont/SvgFont.vala@@ -12,7 +12,7 @@     Lesser General Public License for more details. */ -using Xml;+using Bird;  namespace BirdFont { @@ -27,44 +27,48 @@ class SvgFont : GLib.Object { 	 	/** Load svg font from file. */ 	public void load (string path) {-		Xml.Doc* doc;-		Xml.Node* root = null;-		-		Parser.init ();-		doc = Parser.parse_file (path);-		root = doc->get_root_element ();-		return_if_fail (root != null);-		parse_svg_font (root);-		delete doc;-		Parser.cleanup ();	+		string data;+		XmlParser xml_parser;+		try {+			FileUtils.get_contents (path, out data);+			xml_parser = new XmlParser (data);+			parse_svg_font (xml_parser.get_next_tag ());+		} catch (GLib.Error e) {+			warning (e.message);+		} 	} 	-	void parse_svg_font (Xml.Node* node) {-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "defs") {-				parse_svg_font (iter);+	void parse_svg_font (Tag tag) {+		Tag t;+		+		tag.reparse ();+		while (tag.has_more_tags ()) {+			t = tag.get_next_tag ();+			+			if (t.get_name () == "defs") {+				parse_svg_font (t); 			} 			-			if (iter->name == "font") {-				parse_font_tag (iter);-				parse_svg_font (iter);+			if (t.get_name () == "font") {+				parse_font_tag (t);+				parse_svg_font (t); 			} -			if (iter->name == "font-face") {-				parse_font_limits (iter);+			if (t.get_name () == "font-face") {+				parse_font_limits (t); 			} -			if (iter->name == "hkern") {-				parse_hkern (iter);+			if (t.get_name () == "hkern") {+				parse_hkern (t); 			} 									-			if (iter->name == "glyph") {-				parse_glyph (iter);+			if (t.get_name () == "glyph") {+				parse_glyph (t); 			} 		}		 	} -	void parse_hkern (Xml.Node* node) {+	void parse_hkern (Tag tag) { 		string left = ""; 		string right = ""; 		string left_name = "";@@ -72,35 +76,34 @@ class SvgFont : GLib.Object { 		double kerning = 0; 		unichar l, r; 		StringBuilder sl, sr;-		string attr_name = "";-		string attr_content; 		GlyphRange grr, grl;+		Attribute attr; 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			 			// left-			if (attr_name == "u1") {-				left = attr_content;+			if (attr.get_name () == "u1") {+				left = attr.get_content (); 			}	 					 			// right	-			if (attr_name == "u2") {-				right = attr_content;+			if (attr.get_name () == "u2") {+				right = attr.get_content (); 			} -			if (attr_name == "g1") {-				left_name = attr_content;+			if (attr.get_name () == "g1") {+				left_name = attr.get_content (); 			} 			-			if (attr_name == "g2") {-				right_name = attr_content;+			if (attr.get_name () == "g2") {+				right_name = attr.get_content (); 			} 				 			// kerning-			if (attr_name == "k") {-				kerning = double.parse (attr_content) * units;+			if (attr.get_name () == "k") {+				kerning = double.parse (attr.get_content ()) * units; 			} 		} 				@@ -131,31 +134,30 @@ class SvgFont : GLib.Object { 		} 	} -	void parse_font_limits (Xml.Node* node) {-		string attr_name = "";-		string attr_content;+	void parse_font_limits (Tag tag) { 		double top_limit = 0; 		double bottom_limit = 0;+		Attribute attr; 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "units-per-em") {-				units = 100.0 / double.parse (attr_content);+			if (attr.get_name () == "units-per-em") {+				units = 100.0 / double.parse (attr.get_content ()); 			}	 		} -		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 					-			if (attr_name == "ascent") {-				top_limit = double.parse (attr_content);+			if (attr.get_name () == "ascent") {+				top_limit = double.parse (attr.get_content ()); 			} 			-			if (attr_name == "descent") {-				bottom_limit = double.parse (attr_content);+			if (attr.get_name () == "descent") {+				bottom_limit = double.parse (attr.get_content ()); 			}		 		} 		@@ -166,20 +168,19 @@ class SvgFont : GLib.Object { 		font.top_limit = top_limit; 	} 	-	void parse_font_tag (Xml.Node* node) {-		string attr_name = "";-		string attr_content;+	void parse_font_tag (Tag tag) {+		Attribute attr; 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "horiz-adv-x") {-				font_advance = double.parse (attr_content);+			if (attr.get_name () == "horiz-adv-x") {+				font_advance = double.parse (attr.get_content ()); 			} 						-			if (attr_name == "id") {-				font.set_name (attr_content);+			if (attr.get_name () == "id") {+				font.set_name (attr.get_content ()); 			} 		} 	}@@ -224,9 +225,7 @@ class SvgFont : GLib.Object { 		return v.char_count () > 1; 	} 	-	void parse_glyph (Xml.Node* node) {-		string attr_name = "";-		string attr_content;+	void parse_glyph (Tag tag) { 		unichar unicode_value = 0; 		string glyph_name = ""; 		string svg = "";@@ -235,36 +234,37 @@ class SvgFont : GLib.Object { 		double advance = font_advance; 		string ligature = ""; 		SvgParser parser = new SvgParser ();+		Attribute attr;  		parser.set_format (SvgFormat.INKSCAPE); -		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); -			if (attr_name == "unicode") {-				unicode_value = get_unichar (attr_content);+			if (attr.get_name () == "unicode") {+				unicode_value = get_unichar (attr.get_content ()); 				 				if (glyph_name == "") {-					glyph_name = attr_content;+					glyph_name = attr.get_content (); 				} 				-				if (is_ligature (attr_content)) {-					ligature = attr_content;+				if (is_ligature (attr.get_content ())) {+					ligature = attr.get_content (); 				} 			} 			 			// svg data-			if (attr_name == "d") {-				svg = attr_content;+			if (attr.get_name () == "d") {+				svg = attr.get_content (); 			} 			-			if (attr_name == "glyph-name") {-				glyph_name = attr_content;+			if (attr.get_name () == "glyph-name") {+				glyph_name = attr.get_content (); 			} -			if (attr_name == "horiz-adv-x") {-				advance = double.parse (attr_content);+			if (attr.get_name () == "horiz-adv-x") {+				advance = double.parse (attr.get_content ()); 			} 		} diff --git a/libbirdfont/SvgParser.vala b/libbirdfont/SvgParser.valaindex 0f05d67..05bca81 100644--- a/libbirdfont/SvgParser.vala+++ b/libbirdfont/SvgParser.vala@@ -11,7 +11,8 @@     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      Lesser General Public License for more details. */-using Xml;++using Bird; using Math;  namespace BirdFont {@@ -52,13 +53,12 @@ public class SvgParser { 	public static void import_svg_data (string xml_data, SvgFormat format = SvgFormat.NONE) { 		PathList path_list = new PathList (); 		Glyph glyph; -		Xml.Node* root = null; 		string[] lines = xml_data.split ("\n");-		string xml_document; 		bool has_format = false; 		StringBuilder sb = new StringBuilder (); 		SvgParser parser = new SvgParser ();-		TextReader tr;+		XmlParser xmlparser;+		Tag root; 		 		foreach (string l in lines) { 			if (l.index_of ("Illustrator") > -1 || l.index_of ("illustrator") > -1) {@@ -69,51 +69,22 @@ public class SvgParser { 			if (l.index_of ("Inkscape") > -1 || l.index_of ("inkscape") > -1) { 				parser.set_format (SvgFormat.INKSCAPE); 				has_format = true;-			}	-			-			// FIXME: libxml2 (2.7.8) refuses to parse svg files created with Adobe Illustrator on -			// windows. This is a way around it.-			if (l.index_of ("<!") == -1 -				&& l.index_of ("]>") == -1-				&& l.index_of ("http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd") == -1) {-				sb.append (l);-				sb.append ("\n"); 			} 		} 		 		if (format != SvgFormat.NONE) { 			parser.set_format (format); 		}-		-		xml_document = sb.str;-		-		// Remove Inkscape specific namespaces-		xml_document = replace (xml_document, "<metadata", "</metadata>", "");-		xml_document = replace (xml_document, "<sodipodi:namedview", "</sodipodi:namedview>", "");-		xml_document = xml_document.replace ("inkscape:", "");-		-		// CS6 compability-		xml_document = replace (xml_document, "<svg", ">", "<svg>");-		xml_document = replace (xml_document, "<foreignObject", "</foreignObject>", "");-		xml_document = replace (xml_document, "<i:pgf", "</i:pgf>", "");-		xml_document = xml_document.replace ("i:", "");-		xml_document = xml_document.replace ("sodipodi:", "");-		+ 		// parse the file 		if (!has_format) { 			warn_if_test ("No format identifier found in SVG parser.\n"); 		} -		Parser.init ();+		xmlparser = new XmlParser (xml_data); 		-		tr = new TextReader.for_doc (xml_document, "");-		tr.read ();-		root = tr.expand ();-				-		if (root == null) {-			warning ("Failed to load SVG file");-			return;-		}+		xmlparser.reparse ();+		root = xmlparser.get_next_tag ();  		path_list = parser.parse_svg_file (root); 	@@ -156,66 +127,65 @@ public class SvgParser { 		import_svg_data (svg_data); 	} 	-	private PathList parse_svg_file (Xml.Node* root) {-		Xml.Node* node;+	private PathList parse_svg_file (Tag tag) {+		Tag t; 		PathList pl = new PathList (); 		-		node = root;-		-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "g") {-				parse_layer (iter, pl);+		tag.reparse ();+		while (tag.has_more_tags ()) {+			t = tag.get_next_tag ();+			+			if (t.get_name () == "g") {+				parse_layer (t, pl); 			} -			if (iter->name == "switch") {-				parse_layer (iter, pl);+			if (t.get_name () == "switch") {+				parse_layer (t, pl); 			} 						-			if (iter->name == "path") {-				parse_path (iter, pl);+			if (t.get_name () == "path") {+				parse_path (t, pl); 			} 			-			if (iter->name == "polygon") {-				parse_polygon (iter, pl);+			if (t.get_name () == "polygon") {+				parse_polygon (t, pl); 			} 		} 		 		return pl; 	} 	-	private void parse_layer (Xml.Node* node, PathList pl) {-		string attr_name = "";-		string attr_content = "";+	private void parse_layer (Tag tag, PathList pl) { 		PathList layer = new PathList ();+		Tag t;+		Attribute attr; 		-		return_if_fail (node != null);-		return_if_fail (node->children != null);-		-		for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-			if (iter->name == "path") {-				parse_path (iter, layer);+		tag.reparse ();+		while (tag.has_more_tags ()) {+			t = tag.get_next_tag ();+			+			if (t.get_name () == "path") {+				parse_path (t, layer); 			} 			-			if (iter->name == "g") {-				parse_layer (iter, layer);+			if (t.get_name () == "g") {+				parse_layer (t, layer); 			} 			-			if (iter->name == "polygon") {-				parse_polygon (iter, layer);+			if (t.get_name () == "polygon") {+				parse_polygon (t, layer); 			} 		} 		-		if (!is_null (node) && !is_null (node->properties)) {-			for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-				attr_name = prop->name;-				attr_content = prop->children->content;-				-				if (attr_name == "transform") {-					transform (attr_content, layer);-				}+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute ();+			+			if (attr.get_name () == "transform") {+				transform (attr.get_content (), layer); 			} 		}-		+ 		pl.append (layer); 	} 	@@ -374,45 +344,44 @@ public class SvgParser { 		return param;			 	} 		-	private void parse_polygon (Xml.Node* node, PathList pl) {-		string attr_name = "";-		string attr_content;+	private void parse_polygon (Tag tag, PathList pl) { 		Glyph glyph = MainWindow.get_current_glyph (); 		Path p;+		Attribute attr;+		+		tag.reparse ();+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;-			-			if (attr_name == "points") {-				p = parse_polygon_data (attr_content, glyph);+			if (attr.get_name () == "points") {+				p = parse_polygon_data (attr.get_content (), glyph); 				pl.add (p); 			} 		}		 	} 	-	private void parse_path (Xml.Node* node, PathList pl) {-		string attr_name = "";-		string attr_content;+	private void parse_path (Tag tag, PathList pl) { 		Glyph glyph = MainWindow.get_current_glyph (); 		PathList path_list = new PathList ();+		Tag t;+		Attribute attr;+		+		tag.reparse ();	+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;-			-			if (attr_name == "d") {-				path_list = parse_svg_data (attr_content, glyph);+			if (attr.get_name () == "d") {+				path_list = parse_svg_data (attr.get_content (), glyph); 				pl.append (path_list); 			} 		} 		-		for (Xml.Attr* prop = node->properties; prop != null; prop = prop->next) {-			attr_name = prop->name;-			attr_content = prop->children->content;+		tag.reparse ();	+		while (tag.has_more_attributes ()) {+			attr = tag.get_next_attribute (); 			-			if (attr_name == "transform") {-				transform (attr_content, path_list);+			if (attr.get_name () == "transform") {+				transform (attr.get_content (), path_list); 			} 		} 	}diff --git a/libbirdxml/Attributes.vala b/libbirdxml/Attributes.valanew file mode 100644index 0000000..e808b1e--- /dev/null+++ b/libbirdxml/Attributes.vala@@ -0,0 +1,47 @@+/*+    Copyright (C) 2014 Johan Mattsson++    This library is free software; you can redistribute it and/or modify +    it under the terms of the GNU Lesser General Public License as +    published by the Free Software Foundation; either version 3 of the +    License, or (at your option) any later version.++    This library 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 +    Lesser General Public License for more details.+*/+namespace Bird {++public class Attribute : GLib.Object {+	+	public string ns;+	public string name;+	public string content;+	+	internal Attribute (string ns, string name, string content) {+		this.ns = ns;+		this.name = name;+		this.content = content;+	}++	internal Attribute.empty () {+		this.ns = "";+		this.name = "";+		this.content = "";+	}+	+	public string get_namespace () {+		return ns;+	}+	+	public string get_name () {+		return name;+	}++	public string get_content () {+		return content;+	}+}++}diff --git a/libbirdxml/Tag.vala b/libbirdxml/Tag.valanew file mode 100644index 0000000..a4e2fc8--- /dev/null+++ b/libbirdxml/Tag.vala@@ -0,0 +1,333 @@+/*+    Copyright (C) 2014 Johan Mattsson++    This library is free software; you can redistribute it and/or modify +    it under the terms of the GNU Lesser General Public License as +    published by the Free Software Foundation; either version 3 of the +    License, or (at your option) any later version.++    This library 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 +    Lesser General Public License for more details.+*/++namespace Bird {++public class Tag : GLib.Object {+	+	int tag_index; +	int attribute_index;+	+	bool has_tags;+	bool has_attributes;+	+	string name;+	string data;+	string attributes;+	+	Tag? next_tag = null;+	Attribute? next_attribute = null;+	+	internal Tag (string name, string attributes, string content) {+		this.name = name;+		this.data = content;+		this.attributes = attributes;+		reparse ();+	}+	+	internal Tag.empty () {+		data = "";+		attributes = "";+		name = "";+	}++	/** Reset the parser and start from the beginning XML tag. */+	public void reparse () {+		tag_index = 0;+		attribute_index = 0;+		next_tag = obtain_next_tag ();+		next_attribute = obtain_next_attribute ();+	}++	/** @return the name of this tag. */+	public string get_name () {+		return name;+	}++	/** @return data between the starty and end tag. */+	public string get_content () {+		return data;+	}++	/** @return true if there is one more tags left */+	public bool has_more_tags () {+		return has_tags;+	}+	+	/** @return the next tag. **/+	public Tag get_next_tag () {+		Tag r = next_tag == null ? new Tag.empty () : (!) next_tag;+		next_tag = obtain_next_tag ();+		return r;+	}++	/** @return true is there is one or more attributes to obtain with get_next_attribute */+	public bool has_more_attributes () {+		return has_attributes;+	}+	+	/** @return next attribute. */+	public Attribute get_next_attribute () {+		Attribute r = next_attribute == null ? new Attribute.empty () : (!) next_attribute;+		next_attribute = obtain_next_attribute ();+		return r;+	}+	+	Tag obtain_next_tag () {+		int end_tag_index;+		Tag tag;+		+		tag = find_next_tag (tag_index, out end_tag_index);+		+		if (end_tag_index != -1) {+			tag_index = end_tag_index;+			has_tags = true;+		} else {+			has_tags = false;+		}+		+		return tag;+	}+	+	Tag find_next_tag (int start, out int end_tag_index) {+		int index;+		unichar c;+		int separator;+		int end;+		int closing_tag;++		string name;+		string attributes;+		string content;+	+		index = start;+		end_tag_index = -1;+		while (data.get_next_char (ref index, out c)) {+			if (c == '<') {+				separator = find_next_separator (index);++				if (separator < 0) {+					warning ("Expecting a separator after index %d.", index);+					return new Tag.empty ();+				}+				+				name = data.substring (index, separator - index);+				+				if (name.has_prefix ("!")) {+					continue;+				}+				+				end = data.index_of (">", start);+				attributes = data.substring (separator, end - separator);+				+				if (attributes.has_suffix ("/")) {+					content = "";+					end_tag_index = data.index_of (">", index);+					data.get_next_char (ref end_tag_index, out c);+				} else {+					data.get_next_char (ref end, out c); // skip >+					closing_tag = find_closing_tag (name, end);+					content = data.substring (end, closing_tag - end);+					end_tag_index = data.index_of (">", closing_tag);+					data.get_next_char (ref end_tag_index, out c);+				}+				+				return new Tag (name, attributes, content);	+			}+		}+		+		return new Tag.empty ();+	}+	+	int find_next_separator (int start) {+		int index = start;+		int previous_index = start;+		unichar c;+		+		while (true) {+			+			previous_index = index;+			if (!data.get_next_char (ref index, out c)) {+				break;+			}+			+			if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '>' || c == '/') {+				return previous_index;+			}+		}+		+		return -1;+	}+	+	int find_closing_tag (string name, int start) {+		int index = start;+		int slash_index = start;+		int previous_index;+		unichar c;+		int start_count = 0;+		+		while (true) {+			previous_index = index;+			if (!data.get_next_char (ref index, out c)) {+				break;+			}+			+			if (c == '<') {+				slash_index = index;+				data.get_next_char (ref slash_index, out c);+				if (c == '/' && is_tag (name, slash_index)) {+					if (start_count == 0) {+						return previous_index;+					} else {+						start_count--;+						if (start_count == 0) {+							return previous_index;+						}+					}+				} else if (is_tag (name, index)) {+					start_count++;					+				}+			}+		}+		+		warning (@"No closing tag for $(name).");+		return -1;+	}+	+	bool is_tag (string name, int start) {+		int index = 0;+		int data_index = start;+		unichar c;+		unichar c_data;+		+		while (name.get_next_char (ref index, out c)) {+			if (data.get_next_char (ref data_index, out c_data)) {+				if (c_data != c) {+					return false;+				}+			}+		}+		+		+		if (data.get_next_char (ref data_index, out c_data)) {+			return c_data == '>' || c_data == ' ' || c_data == '\t' +				|| c_data == '\n' || c_data == '\r' || c_data == '/';+		}+		+		return false;+	}++	Attribute obtain_next_attribute () {+		int previous_index;+		int index = attribute_index;+		int name_start;+		string attribute_name;		+		string ns;+		string content;+		int ns_separator;+		int content_start;+		int content_stop;+		unichar quote;+		unichar c;+		+		// skip space and other separators+		while (true) {+			previous_index = index;+			+			if (!attributes.get_next_char (ref index, out c)) {+				has_attributes = false;+				return new Attribute.empty ();+			}+			+			if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '/')) {+				break;+			}+		}+		+		name_start = previous_index;++		// read attribute name+		while (true) {+			previous_index = index;+			if (!attributes.get_next_char (ref index, out c)) {+				warning (@"Unexpected end of attributes in tag $(this.name)");+				has_attributes = false;+				return new Attribute.empty ();+			}+			+			if (c == ' ' || c == '\t' || c == '=' || c == '\n' || c == '\r') {+				break;+			}+		}+		+		attribute_name = attributes.substring (name_start, previous_index - name_start);+		index = name_start + attribute_name.length;+		ns = "";+		ns_separator = attribute_name.index_of (":");+		if (ns_separator != -1) {+			ns = attribute_name.substring (0, ns_separator);+			attribute_name = attribute_name.substring (ns_separator + 1);+		}+		+		// equal sign and space around it+		while (attributes.get_next_char (ref index, out c)) {+			if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {+				if (c == '=') {+					break;+				} else {+					has_attributes = false;+					warning (@"Expecting equal sign for attribute $(attribute_name).");+					return new Attribute.empty ();+				}+			}+		}+		+		while (attributes.get_next_char (ref index, out c)) {+			if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {+				if (c == '"' || c == '\'') {+					break;+				} else {+					has_attributes = false;+					warning (@"Expecting quote for attribute $(attribute_name).");+					return new Attribute.empty ();+				}+			}+		}+		+		quote = c;+		content_start = index;+		+		while (true) {+			if (!attributes.get_next_char (ref index, out c)) {+				has_attributes = false;+				warning (@"Expecting end quote for attribute $(attribute_name).");+				return new Attribute.empty ();+			}+			+			if (c == quote) {+				break;+			}+		}+		+		content_stop = index - 1;+		content = attributes.substring (content_start, content_stop - content_start);+		+		has_attributes = true;+		+		attribute_index = content_stop + 1;+		return new Attribute (ns, attribute_name, content);+	}+}++}diff --git a/libbirdxml/Xml.vala b/libbirdxml/Xml.valanew file mode 100644index 0000000..903d4fe--- /dev/null+++ b/libbirdxml/Xml.vala@@ -0,0 +1,75 @@+/*+    Copyright (C) 2014 Johan Mattsson++    This library is free software; you can redistribute it and/or modify +    it under the terms of the GNU Lesser General Public License as +    published by the Free Software Foundation; either version 3 of the +    License, or (at your option) any later version.++    This library 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 +    Lesser General Public License for more details.+*/+namespace Bird {++/** A small xml parser originally written for the BirdFont project. */+public class XmlParser : GLib.Object {+	+	Tag root;+	string data;++	public XmlParser (string data) {+		this.data = data;+		reparse ();+	}+	+	/** Reset the parser and start from the beginning of the XML document. */+	public void reparse () {+		int root_index;+		+		root_index = find_root_tag ();+		if (root_index == -1) {+			warning ("No root tag found.");+			root = new Tag.empty ();+		} else {+			root = new Tag ("", "", data.substring (root_index));+		}+	}+	+	/** @return the root tag. **/+	public Tag get_next_tag () {+		return root.get_next_tag ();+	}+	+	/** @return true if there is one more tags left */+	public bool has_more_tags () {+		return root.has_more_tags ();+	}+		+	int find_root_tag () {+		int index = 0;+		int prev_index = 0;+		int modifier = 0;+		unichar c;+		+		while (true) {+			prev_index = index;+			if (!data.get_next_char (ref index, out c)) {+				break;+			}+			+			if (c == '<') {+				modifier = index;+				data.get_next_char (ref modifier, out c);+				if (c != '?' && c != '[' && c != '!') {+					return prev_index;+				} +			}+		}+		+		return -1;+	}	+}++}diff --git a/scripts/build.py b/scripts/build.pyindex e6da25f..bd8d1f1 100644--- a/scripts/build.py+++ b/scripts/build.py@@ -44,10 +44,10 @@ def libbirdfont(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull  		libbirdfont/*.vala \ 		libbirdfont/OpenFontFormat/*.vala \ 		--pkg """ + config.GEE + """ \-		--pkg libxml-2.0 \ 		--pkg gio-2.0 \ 		--pkg cairo \-		--pkg gdk-pixbuf-2.0+		--pkg gdk-pixbuf-2.0 \+		--pkg libbirdxml \ 		""")  	#copy c sources @@ -61,7 +61,6 @@ def libbirdfont(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull  			-fPIC \ 			-D 'GETTEXT_PACKAGE="birdfont"' \ 			$(pkg-config --cflags """ + config.GEE + """) \-			$(pkg-config --cflags libxml-2.0) \ 			$(pkg-config --cflags gio-2.0) \ 			$(pkg-config --cflags cairo) \ 			$(pkg-config --cflags glib-2.0) \@@ -80,7 +79,6 @@ def libbirdfont(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull  			build/libbirdfont/*.o \ 			$(freetype-config --libs) \ 			$(pkg-config --libs """ + config.GEE + """) \-			$(pkg-config --libs libxml-2.0) \ 			$(pkg-config --libs gio-2.0) \ 			$(pkg-config --libs cairo) \ 			$(pkg-config --libs glib-2.0) \@@ -109,8 +107,63 @@ def libbirdfont(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull  		run("cp resources/linux/birdfont-import.1 build/") 		run("gzip build/birdfont-import.1")  				++def libbirdxml(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True):+	#libbirdfont+	run("mkdir -p build/libbirdxml")+	run("mkdir -p build/bin")++	experimentalNonNull = ""+	if nonNull:+		experimentalNonNull = "--enable-experimental-non-null"++	run(valac + """\+		-C \+		""" + valaflags + """ \+		--vapidir=./ \+		--basedir build/libbirdxml/ \+		""" + experimentalNonNull + """ \+		--enable-experimental \+		--library libbirdxml \+		-H build/libbirdxml/birdxml.h \+		libbirdxml/*.vala \+		""")+		+	if cc == "":+		print ("Skipping compilation");+	else:+		run(cc + " " + cflags + """ \+			-c build/libbirdxml/*.c \+			-fPIC \+			$(pkg-config --cflags glib-2.0) \+			""")+			+		run("mv ./*.o build/libbirdxml/ ")++		if library.endswith (".dylib"):+			sonameparam = "" # gcc on mac os does not have the soname parameter+		else:+			sonameparam = "-Wl,-soname," + library+		+		run(cc + " " + ldflags + """ \+			-shared \+			""" + sonameparam + """ \+			build/libbirdxml/*.o \+			$(pkg-config --libs glib-2.0) \+			-o """ + library)+		run("mv " + library + " build/bin/")+		+		if os.path.exists("build/bin/libbirdxml.so"):+			run ("cd build/bin && unlink libbirdxml.so")++		# create link to the versioned library+		if library.find ('.so') > -1:+			run ("""cd build/bin && ln -sf """ + library + " libbirdxml.so")+		elif library.find ('.dylib') > -1:+			run ("""cd build/bin && ln -sf """ + library + " libbirdxml.dylib")+ 		 	-def birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True):+def birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 	# birdfont-export 	run("mkdir -p build/birdfont-export") @@ -125,7 +178,6 @@ def birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, library, nonN 		--define=MAC birdfont-export/* \ 		--vapidir=./ \ 		--pkg """ + config.GEE + """ \-		--pkg libxml-2.0 \ 		--pkg gio-2.0  \ 		--pkg cairo \ 		--pkg gdk-pixbuf-2.0 \@@ -137,7 +189,6 @@ def birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, library, nonN 		-c ./build/libbirdfont/birdfont.h build/birdfont-export/*.c \ 		-D 'GETTEXT_PACKAGE="birdfont"' \ 		$(pkg-config --cflags """ + config.GEE + """) \-		$(pkg-config --cflags libxml-2.0) \ 		$(pkg-config --cflags gio-2.0) \ 		$(pkg-config --cflags cairo) \ 		$(pkg-config --cflags glib-2.0) \@@ -150,7 +201,6 @@ def birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, library, nonN 		-Lbuild/bin/ -lbirdfont \ 		-lm \ 		$(pkg-config --libs """ + config.GEE + """) \-		$(pkg-config --libs libxml-2.0) \ 		$(pkg-config --libs gio-2.0) \ 		$(pkg-config --libs cairo) \ 		$(pkg-config --libs glib-2.0) \@@ -172,7 +222,7 @@ def birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, library, nonN 	run("touch build/installed") 	run("touch build/configured") -def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True):+def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 	# birdfont-import 	run("mkdir -p build/birdfont-import") @@ -187,7 +237,6 @@ def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, library, nonN 		--define=MAC birdfont-import/* \ 		--vapidir=./ \ 		--pkg """ + config.GEE + """ \-		--pkg libxml-2.0 \ 		--pkg gio-2.0  \ 		--pkg cairo \ 		--pkg gdk-pixbuf-2.0 \@@ -199,7 +248,6 @@ def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, library, nonN 		-c ./build/libbirdfont/birdfont.h build/birdfont-import/*.c \ 		-D 'GETTEXT_PACKAGE="birdfont"' \ 		$(pkg-config --cflags """ + config.GEE + """) \-		$(pkg-config --cflags libxml-2.0) \ 		$(pkg-config --cflags gio-2.0) \ 		$(pkg-config --cflags cairo) \ 		$(pkg-config --cflags glib-2.0) \@@ -212,14 +260,13 @@ def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, library, nonN 		-Lbuild/bin/ -lbirdfont \ 		-lm \ 		$(pkg-config --libs """ + config.GEE + """) \-		$(pkg-config --libs libxml-2.0) \ 		$(pkg-config --libs gio-2.0) \ 		$(pkg-config --libs cairo) \ 		$(pkg-config --libs glib-2.0) \ 		$(pkg-config --libs gdk-pixbuf-2.0) \ 		-o ./build/bin/birdfont-import""") -def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True):+def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 	# birdfont-autotrace 	run("mkdir -p build/birdfont-autotrace") @@ -234,7 +281,6 @@ def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, library, n 		--define=MAC birdfont-autotrace/* \ 		--vapidir=./ \ 		--pkg """ + config.GEE + """ \-		--pkg libxml-2.0 \ 		--pkg gio-2.0  \ 		--pkg cairo \ 		--pkg gdk-pixbuf-2.0 \@@ -246,7 +292,6 @@ def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, library, n 		-c ./build/libbirdfont/birdfont.h build/birdfont-autotrace/*.c \ 		-D 'GETTEXT_PACKAGE="birdfont"' \ 		$(pkg-config --cflags """ + config.GEE + """) \-		$(pkg-config --cflags libxml-2.0) \ 		$(pkg-config --cflags gio-2.0) \ 		$(pkg-config --cflags cairo) \ 		$(pkg-config --cflags glib-2.0) \@@ -259,7 +304,6 @@ def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, library, n 		-Lbuild/bin/ -lbirdfont \ 		-lm \ 		$(pkg-config --libs """ + config.GEE + """) \-		$(pkg-config --libs libxml-2.0) \ 		$(pkg-config --libs gio-2.0) \ 		$(pkg-config --libs cairo) \ 		$(pkg-config --libs glib-2.0) \@@ -267,7 +311,7 @@ def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, library, n 		-o ./build/bin/birdfont-autotrace""")  -def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True):+def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 	# birdfont 	run("mkdir -p build/birdfont") @@ -282,7 +326,6 @@ def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull 		--enable-experimental \ 		--vapidir=./ \ 		--pkg """ + config.GEE + """ \-		--pkg libxml-2.0 \ 		--pkg gio-2.0  \ 		--pkg cairo \ 		--pkg libsoup-2.4 \@@ -296,7 +339,6 @@ def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull 		-c ./build/libbirdfont/birdfont.h build/birdfont/*.c \ 		-D 'GETTEXT_PACKAGE="birdfont"' \ 		$(pkg-config --cflags """ + config.GEE + """) \-		$(pkg-config --cflags libxml-2.0) \ 		$(pkg-config --cflags gio-2.0) \ 		$(pkg-config --cflags cairo) \ 		$(pkg-config --cflags glib-2.0) \@@ -310,7 +352,6 @@ def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull 		build/birdfont/*.o \ 		-Lbuild/bin/ -lbirdfont \ 		$(pkg-config --libs """ + config.GEE + """) \-		$(pkg-config --libs libxml-2.0) \ 		$(pkg-config --libs gio-2.0) \ 		$(pkg-config --libs cairo) \ 		$(pkg-config --libs glib-2.0) \diff --git a/scripts/linux_build.py b/scripts/linux_build.pyindex 2126af1..3c510f9 100755--- a/scripts/linux_build.py+++ b/scripts/linux_build.py@@ -48,15 +48,18 @@ cc = options.cc cflags = options.cflags ldflags = options.ldflags library_cflags = options.cflags-library_ldflags= options.ldflags + " -Wl,-soname," + "libbirdfont.so." + version.SO_VERSION-library = "libbirdfont.so." + version.SO_VERSION+library_ldflags= options.ldflags + " -Wl,-soname," + "libbirdfont.so." + version.LIBBIRDXML_SO_VERSION++xmllibrary_cflags = options.cflags+xmllibrary_ldflags= options.ldflags + " -Wl,-soname," + "libbirdxml.so." + version.SO_VERSION  configfile.write_config (prefix) compile_translations()-build.libbirdfont(prefix, cc, cflags, library_ldflags, valac, valaflags, library, False)-build.birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, library, False)-build.birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, library, False)-build.birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, library, False)-build.birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, library, False)+build.libbirdxml(prefix, cc, xmllibrary_cflags, xmllibrary_ldflags, valac, valaflags, "libbirdxml.so." + version.LIBBIRDXML_SO_VERSION, False)+build.libbirdfont(prefix, cc, library_cflags, library_ldflags, valac, valaflags, "libbirdfont.so." + version.SO_VERSION, False)+build.birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, False)+build.birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, False)+build.birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, False)+build.birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, False)  print ("Done")diff --git a/scripts/mac_build.py b/scripts/mac_build.pyindex f1db873..6a4d30b 100644--- a/scripts/mac_build.py+++ b/scripts/mac_build.py@@ -1,6 +1,6 @@ #!/usr/bin/python """-Copyright (C) 2013 Johan Mattsson+Copyright (C) 2013 2014 Johan Mattsson  This library is free software; you can redistribute it and/or modify  it under the terms of the GNU Lesser General Public License as @@ -48,14 +48,17 @@ valaflags = "" cc = options.cc cflags = options.cflags ldflags = options.ldflags-library_cflags = options.cflags-library_ldflags = options.ldflags + " " + """-dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,""" + prefix + """/lib/libbirdfont.dylib""" -library = "libbirdfont." + version.SO_VERSION + ".dylib"+ library_cflags = "-fno-common -fPIC " + cflags +library_ldflags = options.ldflags + " " + """-dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,""" + prefix + """/lib/libbirdfont.dylib""" ++xml_library_cflags = "-fno-common -fPIC " + cflags +xml_library_ldflags = options.ldflags + " " + """-dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,""" + prefix + """/lib/libbirdxml.dylib"""   configfile.write_config (prefix) compile_translations()-build.libbirdfont(prefix, cc, library_cflags, library_ldflags, valac, valaflags, library, False)+build.libbirdxml(prefix, cc, xml_library_cflags, xml_library_ldflags, valac, valaflags, "libbirdxml." + version.LIBBIRDXML_SO_VERSION + ".dylib", False)+build.libbirdfont(prefix, cc, library_cflags, library_ldflags, valac, valaflags, "libbirdfont." + version.SO_VERSION + ".dylib", False) build.birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, library, False) build.birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, library, False) build.birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, library, False)diff --git a/scripts/version.py b/scripts/version.pyindex 6ce3233..b7793c1 100644--- a/scripts/version.py+++ b/scripts/version.py@@ -2,21 +2,22 @@ """ Copyright (C) 2013, 2014 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 library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser 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/>.+This library 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 +Lesser General Public License for more details. """  VERSION = '1.4' SO_VERSION_MAJOR = '26' SO_VERSION_MINOR = '0' SO_VERSION = SO_VERSION_MAJOR + '.' + SO_VERSION_MINOR++LIBBIRDXML_SO_VERSION_MAJOR = '0'+LIBBIRDXML_SO_VERSION_MINOR = '0'+LIBBIRDXML_SO_VERSION = LIBBIRDXML_SO_VERSION_MAJOR + '.' + LIBBIRDXML_SO_VERSION_MINOR;diff --git a/scripts/windows_build.py b/scripts/windows_build.pyindex 5968c6e..4b7fc8a 100644--- a/scripts/windows_build.py+++ b/scripts/windows_build.py@@ -20,7 +20,6 @@ cflags = "-g ./build/icon.res -Wl,-subsystem,windows " ldflags = "" library_cflags = "-Wl,-subsystem,windows " library_ldflags= "";-library = "libbirdfont.dll"  import configfile configfile.write_config (prefix)@@ -33,7 +32,8 @@ from run import run  compile_translations() run("windres ./resources/win32/icon.rc -O coff -o ./build/icon.res")-build.libbirdfont(prefix, cc, cflags, library_ldflags, valac, valaflags, library)+build.libbirdxml(prefix, cc, cflags, library_ldflags, valac, valaflags, "libbirdxml.dll")+build.libbirdfont(prefix, cc, cflags, library_ldflags, valac, valaflags, "libbirdfont.dll") build.birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, library)  print ("Done")

Contact

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