Commit 879d6bb
Assign spacing class data by name
Changed files (5)
modifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/GlyphSelection.valamodifiedlibbirdfont/SpacingClassTools.valamodifiedlibbirdfont/SpacingData.vala
Diff
@@ -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 ())); } @@ -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 ()) {@@ -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 (); });@@ -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); } @@ -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);