Clone in a terminal:
Commit 879d6bb
Johan Mattsson - 2016-06-13T10:47:33+00:00
879d6bb7d63088937999474b1662964fb308582fjohan.mattsson.m@gmail.com

Assign spacing class data by name

Changed files (5)

Diff

diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 485b2cf..486b788 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -1,5 +1,5 @@ /*-	Copyright (C) 2013 2014 2015 Johan Mattsson+	Copyright (C) 2013 2014 2015 2016 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 @@ -24,7 +24,7 @@ class BirdFontFile : GLib.Object { 	Font font; 	 	public static const int FORMAT_MAJOR = 2;-	public static const int FORMAT_MINOR = 1;+	public static const int FORMAT_MINOR = 2; 	 	public static const int MIN_FORMAT_MAJOR = 0; 	public static const int MIN_FORMAT_MINOR = 0;@@ -275,11 +275,25 @@ class BirdFontFile : GLib.Object { 		foreach (SpacingClass sc in s.classes) { 				os.put_string ("<spacing "); 				os.put_string ("first=\"");-				os.put_string (Font.to_hex (sc.first.get_char ()));+				+				if (sc.first.char_count () == 1) {+					os.put_string (Font.to_hex (sc.first.get_char ()));+				} else {+					os.put_string ("name:");+					os.put_string (XmlParser.encode (sc.first));+				}+				 				os.put_string ("\" "); 				 				os.put_string ("next=\"");-				os.put_string (Font.to_hex (sc.next.get_char ()));+				+				if (sc.next.char_count () == 1) {+					os.put_string (Font.to_hex (sc.next.get_char ()));+				} else {+					os.put_string ("name:");+					os.put_string (XmlParser.encode (sc.next));+				}+				 				os.put_string ("\" "); 				 				os.put_string ("/>\n");@@ -1054,6 +1068,7 @@ class BirdFontFile : GLib.Object { 	 	private void parse_spacing_class (Tag tag) { 		string first, next;+		string name; 		SpacingData spacing = font.get_spacing (); 		 		first = "";@@ -1061,11 +1076,21 @@ class BirdFontFile : GLib.Object { 		 		foreach (Attribute attr in tag.get_attributes ()) { 			if (attr.get_name () == "first") {-				first = (!) Font.to_unichar (attr.get_content ()).to_string ();+				if (attr.get_content ().has_prefix ("U+")) {+					first = (!) Font.to_unichar (attr.get_content ()).to_string ();+				} else if (attr.get_content ().has_prefix ("name:")) {+					name = attr.get_content ().substring ("name:".length);+					first = XmlParser.decode (name);+				} 			}  			if (attr.get_name () == "next") {-				next = (!) Font.to_unichar (attr.get_content ()).to_string ();+				if (attr.get_content ().has_prefix ("U+")) {+					next = (!) Font.to_unichar (attr.get_content ()).to_string ();+				} else if (attr.get_content ().has_prefix ("name:")) {+					name = attr.get_content ().substring ("name:".length);+					next = XmlParser.decode (name);+				} 			}		 		} 		@@ -1083,6 +1108,7 @@ class BirdFontFile : GLib.Object { 			 			foreach (Attribute attr in tag.get_attributes ()) { 				if (attr.get_name () == "left") {+ 					range_left.parse_ranges (unserialize (attr.get_content ())); 				} diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 6927233..f070ff1 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1,5 +1,5 @@ /*-	Copyright (C) 2012 2013 2014 2015 Johan Mattsson+	Copyright (C) 2012 - 2016 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@@ -2331,7 +2331,7 @@ public class Glyph : FontDisplay { 		SpacingData sd;  		sd = font.get_spacing ();-		s = sd.get_all_connections ((!) unichar_code.to_string ());+		s = sd.get_all_connections (get_name ());  		foreach (string l in s) { 			if (l != (!) unichar_code.to_string ()) {diff --git a/libbirdfont/GlyphSelection.vala b/libbirdfont/GlyphSelection.valaindex 4194969..a0f584d 100644--- a/libbirdfont/GlyphSelection.vala+++ b/libbirdfont/GlyphSelection.vala@@ -27,8 +27,6 @@ public class GlyphSelection : OverView { 		FontDisplay.dirty_scrollbar = true;	 		 		open_glyph_signal.connect ((gc) => {-			print(@"name $(gc.get_name ())\n");-			print(@"g name $(gc.get_current ().get_name ())\n"); 			selected_glyph (gc);			 			Toolbox.redraw_tool_box (); 		});diff --git a/libbirdfont/SpacingClassTools.vala b/libbirdfont/SpacingClassTools.valaindex bc7763d..fc41fda 100644--- a/libbirdfont/SpacingClassTools.vala+++ b/libbirdfont/SpacingClassTools.vala@@ -35,7 +35,6 @@ public class SpacingClassTools : ToolCollection  { 			GlyphSelection glyph_selection = new GlyphSelection (); 			 			glyph_selection.selected_glyph.connect ((glyph_collection) => {-				print (@"glyph_collection.get_name (): $(glyph_collection.get_name ())\n"); 				SpacingClassTab.set_class (glyph_collection.get_name ()); 				MainWindow.get_tab_bar ().select_tab_name ("SpacingClasses"); 			});@@ -48,6 +47,7 @@ public class SpacingClassTools : ToolCollection  { 		spacing_class_tools.add_tool (insert); 		 		expanders.add (font_name);+		 		expanders.add (spacing_class_tools); 	} 	diff --git a/libbirdfont/SpacingData.vala b/libbirdfont/SpacingData.valaindex 5d1b4c9..39cff23 100644--- a/libbirdfont/SpacingData.vala+++ b/libbirdfont/SpacingData.vala@@ -69,7 +69,7 @@ public class SpacingData : GLib.Object { 					add_connections (s.next); 				} 			}-+			 			if (s.next == glyph) { 				if (!has_connection (s.first)) { 					add_connections (s.first);

Contact

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