.
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 /** Gsub substitutions will be performed kening and spacing tab when
18 * this tool is selected.
19 */
20 public class OtfLabel : LabelTool {
21
22 public bool active_substitution = false;
23 public string tag;
24
25 public signal void otf_feature_activity (bool enable, string tag);
26
27 public OtfLabel (string tag) {
28 string label = get_string(tag);
29 base (label);
30
31 this.tag = tag;
32
33 select_action.connect ((self) => {
34 active_substitution = !active_substitution;
35 set_selected_tag (active_substitution);
36 });
37 }
38
39 public void set_selected_tag (bool enabled) {
40 set_selected (enabled);
41 otf_feature_activity (enabled, tag);
42 }
43
44 /** @return translated string representation of a OTF feature tag. */
45 public static string get_string (string tag) {
46 if (tag == "salt") {
47 return t_("Stylistic Alternate") + " (salt)";
48 } else if (tag == "smcp") {
49 return t_("Small Caps") + " (smcp)";
50 } else if (tag == "c2sc") {
51 return t_("Capitals to Small Caps") + " (c2sc)";
52 } else if (tag == "swsh") {
53 return t_("Swashes") + " (swsh)";
54 }
55
56 warning (@"Unknown tag: $tag");
57 return tag;
58 }
59 }
60
61 }
62