Commit e2e6d1a
Update kerning when kerning classes are updated
Changed files (3)
modifiedlibbirdfont/Font.valamodifiedlibbirdfont/KerningClasses.valamodifiedlibbirdfont/KerningRange.vala
Diff
@@ -87,7 +87,7 @@ public class Font : GLib.Object { /** File format. */ public FontFormat format = FontFormat.BIRDFONT; - SpacingData spacing;+ public SpacingData spacing; bool read_only = false; @@ -52,6 +52,30 @@ public class KerningClasses : GLib.Object { single_kerning = new HashMap<string, double?> (); } + public void update_range (GlyphRange old, GlyphRange new_range) {+ string o = old.get_all_ranges ();+ + foreach (GlyphRange gr in classes_first) {+ try {+ if (gr.get_all_ranges () == o) {+ gr.parse_ranges (new_range.get_all_ranges ());+ }+ } catch (GLib.MarkupError e) {+ warning (e.message);+ }+ }+ + foreach (GlyphRange gr in classes_last) {+ try {+ if (gr.get_all_ranges () == o) {+ gr.parse_ranges (new_range.get_all_ranges ());+ }+ } catch (GLib.MarkupError e) {+ warning (e.message);+ }+ }+ }+ /** Class based gpos kerning. */ public double get_kerning_for_pair (string a, string b, GlyphRange? gr_left, GlyphRange? gr_right) { double k = 0;@@ -90,12 +90,20 @@ public class KerningRange : Tool { } private void set_one_range (string r) throws MarkupError {+ Font f = BirdFont.get_current_font ();+ GlyphRange old = new GlyphRange ();+ + old.parse_ranges (ranges);+ old.set_class (true);+ ranges = r; name = r; glyph_range.empty (); glyph_range.parse_ranges (r); glyph_range.set_class (true);++ f.spacing.kerning_classes.update_range (old, glyph_range); } public void update_kerning_classes () {