The Birdfont Source Code


All Repositories / birdfont.git / blobdiff – RSS feed

Save stylistic alternatives to bf fonts and make gsub features optional

Changes made to libbirdfont/Font.vala

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
--- libbirdfont/Font.vala +++ libbirdfont/Font.vala @@ -186,9 +186,9 @@ font_deleted (); } - public Alternate? get_alternate (GlyphCollection gc) { + public Alternate? get_alternate (unichar character) { foreach (Alternate a in alternates) { - if (a.glyph == gc) { + if (a.character == character) { return a; } } @@ -198,19 +198,33 @@ public void add_new_alternate (GlyphCollection glyph, GlyphCollection alternate) { - Alternate a; - Alternate? alt = get_alternate (alternate); + Alternate? alt = get_alternate (glyph.get_unicode_character ()); if (alt == null) { - a = new Alternate (glyph); + a = new Alternate (glyph.get_unicode_character ()); alternates.add (a); } else { a = (!) alt; } - a.add (alternate); + a.add (alternate.get_name ()); glyph_name.insert (alternate.get_name (), alternate); + glyph_cache.insert (alternate.get_name (), alternate); + } + + public void add_alternate (unichar character, string alternate) { + Alternate a; + Alternate? alt = get_alternate (character); + + if (alt == null) { + a = new Alternate (character); + alternates.add (a); + } else { + a = (!) alt; + } + + a.add (alternate); } public bool has_compatible_format () {