The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

Alternate.vala in libbirdfont/OpenFontFormat

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Add *nix as OS tag heads/master
1 /* 2 Copyright (C) 2015 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 namespace BirdFont { 16 17 public class Alternate : GLib.Object { 18 19 public string glyph_name; 20 public Gee.ArrayList<string> alternates; 21 public string tag; 22 23 public Alternate (string glyph_name, string tag) { 24 this.glyph_name = glyph_name; 25 this.alternates = new Gee.ArrayList<string> (); 26 this.tag = tag; 27 } 28 29 public bool is_empty () { 30 return alternates.size == 0; 31 } 32 33 public void add (string alternate_name) { 34 alternates.add (alternate_name); 35 } 36 37 public void remove_alternate (string alt) { 38 int i = 0; 39 foreach (string a in alternates) { 40 if (a == alt) { 41 break; 42 } 43 i++; 44 } 45 46 if (i < alternates.size) { 47 alternates.remove_at (i); 48 } 49 } 50 51 public void remove (GlyphCollection g) { 52 remove_alternate (g.get_name ()); 53 } 54 55 public Alternate copy () { 56 Alternate n = new Alternate (glyph_name, tag); 57 58 foreach (string s in alternates) { 59 n.add (s); 60 } 61 62 return n; 63 } 64 } 65 66 } 67