The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Assign spacing class data by name

These changes was commited to the Birdfont repository Mon, 13 Jun 2016 10:47:33 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Mon, 13 Jun 2016 10:47:33 +0000]

Updated Files

libbirdfont/BirdFontFile.vala
libbirdfont/Glyph.vala
libbirdfont/GlyphSelection.vala
libbirdfont/SpacingClassTools.vala
libbirdfont/SpacingData.vala
--- 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 @@ 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 @@ 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 @@ private void parse_spacing_class (Tag tag) { string first, next; + string name; SpacingData spacing = font.get_spacing (); first = ""; @@ -1061,11 +1076,21 @@ 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 @@ foreach (Attribute attr in tag.get_attributes ()) { if (attr.get_name () == "left") { + range_left.parse_ranges (unserialize (attr.get_content ())); }
--- 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 @@ 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 ()) {
--- a/libbirdfont/GlyphSelection.vala +++ b/libbirdfont/GlyphSelection.vala @@ -27,8 +27,6 @@ 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 (); });
--- a/libbirdfont/SpacingClassTools.vala +++ b/libbirdfont/SpacingClassTools.vala @@ -35,7 +35,6 @@ 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 @@ spacing_class_tools.add_tool (insert); expanders.add (font_name); + expanders.add (spacing_class_tools); }
--- a/libbirdfont/SpacingData.vala +++ b/libbirdfont/SpacingData.vala @@ -69,7 +69,7 @@ add_connections (s.next); } } - + if (s.next == glyph) { if (!has_connection (s.first)) { add_connections (s.first);