1 // Copyright 2012 Google Inc. All Rights Reserved. 2 3 package com.google.typography.font.sfntly.table.opentype; 4 5 import com.google.typography.font.sfntly.Tag; 6 7 import java.util.HashMap; 8 import java.util.Map; 9 10 /** 11 * @author dougfelt@google.com (Doug Felt) 12 */ 13 enum FeatureTag { 14 aalt("Access All Alternates"), 15 abvf("Above-base Forms"), 16 abvm("Above-base Mark Positioning"), 17 abvs("Above-base Substitutions"), 18 afrc("Alternative Fractions"), 19 akhn("Akhands"), 20 blwf("Below-base Forms"), 21 blwm("Below-base Mark Positioning"), 22 blws("Below-base Substitutions"), 23 calt("Contextual Alternates"), 24 // Note, 'case' collides with a reserved word in java, 25 // so the enum constant has a trailing underscore 26 case_("case", "Case-Sensitive Forms"), 27 ccmp("Glyph Composition / Decomposition"), 28 cfar("Conjunct Form After Ro"), 29 cjct("Conjunct Forms"), 30 clig("Contextual Ligatures"), 31 cpct("Centered CJK Punctuation"), 32 cpsp("Capital Spacing"), 33 cswh("Contextual Swash"), 34 curs("Cursive Positioning"), 35 cv01("Character Variants 1"), 36 cv02("Character Variants 2"), 37 cv03("Character Variants 3"), 38 cv04("Character Variants 4"), 39 cv05("Character Variants 5"), 40 cv06("Character Variants 6"), 41 cv07("Character Variants 7"), 42 cv08("Character Variants 8"), 43 cv09("Character Variants 9"), 44 cv10("Character Variants 10"), 45 // continues to cv99, omitted here 46 c2pc("Petite Capitals From Capitals"), 47 c2sc("Small Capitals From Capitals"), 48 dist("Distances"), 49 dlig("Discretionary Ligatures"), 50 dnom("Denominators"), 51 expt("Expert Forms"), 52 falt("Final Glyph on Line Alternates"), 53 fin2("Terminal Forms #2"), 54 fin3("Terminal Forms #3"), 55 fina("Terminal Forms"), 56 frac("Fractions"), 57 fwid("Full Widths"), 58 half("Half Forms"), 59 haln("Halant Forms"), 60 halt("Alternate Half Widths"), 61 hist("Historical Forms"), 62 hkna("Horizontal Kana Alternates"), 63 hlig("Historical Ligatures"), 64 hngl("Hangul"), 65 hojo("Hojo Kanji Forms (JIS X 0212-1990 Kanji Forms)"), 66 hwid("Half Widths"), 67 init("Initial Forms"), 68 isol("Isolated Forms"), 69 ital("Italics"), 70 jalt("Justification Alternates"), 71 jp78("JIS78 Forms"), 72 jp83("JIS83 Forms"), 73 jp90("JIS90 Forms"), 74 jp04("JIS2004 Forms"), 75 kern("Kerning"), 76 lfbd("Left Bounds"), 77 liga("Standard Ligatures"), 78 ljmo("Leading Jamo Forms"), 79 lnum("Lining Figures"), 80 locl("Localized Forms"), 81 ltra("Left-to-right alternates"), 82 ltrm("Left-to-right mirrored forms"), 83 mark("Mark Positioning"), 84 med2("Medial Forms #2"), 85 medi("Medial Forms"), 86 mgrk("Mathematical Greek"), 87 mkmk("Mark to Mark Positioning"), 88 mset("Mark Positioning via Substitution"), 89 nalt("Alternate Annotation Forms"), 90 nlck("NLC Kanji Forms"), 91 nukt("Nukta Forms"), 92 numr("Numerators"), 93 onum("Oldstyle Figures"), 94 opbd("Optical Bounds"), 95 ordn("Ordinals"), 96 ornm("Ornaments"), 97 palt("Proportional Alternate Widths"), 98 pcap("Petite Capitals"), 99 pkna("Proportional Kana"), 100 pnum("Proportional Figures"), 101 pref("Pre-Base Forms"), 102 pres("Pre-base Substitutions"), 103 pstf("Post-base Forms"), 104 psts("Post-base Substitutions"), 105 pwid("Proportional Widths"), 106 qwid("Quarter Widths"), 107 rand("Randomize"), 108 rkrf("Rakar Forms"), 109 rlig("Required Ligatures"), 110 rphf("Reph Forms"), 111 rtbd("Right Bounds"), 112 rtla("Right-to-left alternates"), 113 rtlm("Right-to-left mirrored forms"), 114 ruby("Ruby Notation Forms"), 115 salt("Stylistic Alternates"), 116 sinf("Scientific Inferiors"), 117 size("Optical size"), 118 smcp("Small Capitals"), 119 smpl("Simplified Forms"), 120 ss01("Stylistic Set 1"), 121 ss02("Stylistic Set 2"), 122 ss03("Stylistic Set 3"), 123 ss04("Stylistic Set 4"), 124 ss05("Stylistic Set 5"), 125 ss06("Stylistic Set 6"), 126 ss07("Stylistic Set 7"), 127 ss08("Stylistic Set 8"), 128 ss09("Stylistic Set 9"), 129 ss10("Stylistic Set 10"), 130 ss11("Stylistic Set 11"), 131 ss12("Stylistic Set 12"), 132 ss13("Stylistic Set 13"), 133 ss14("Stylistic Set 14"), 134 ss15("Stylistic Set 15"), 135 ss16("Stylistic Set 16"), 136 ss17("Stylistic Set 17"), 137 ss18("Stylistic Set 18"), 138 ss19("Stylistic Set 19"), 139 ss20("Stylistic Set 20"), 140 subs("Subscript"), 141 sups("Superscript"), 142 swsh("Swash"), 143 titl("Titling"), 144 tjmo("Trailing Jamo Forms"), 145 tnam("Traditional Name Forms"), 146 tnum("Tabular Figures"), 147 trad("Traditional Forms"), 148 twid("Third Widths"), 149 unic("Unicase"), 150 valt("Alternate Vertical Metrics"), 151 vatu("Vattu Variants"), 152 vert("Vertical Writing"), 153 vhal("Alternate Vertical Half Metrics"), 154 vjmo("Vowel Jamo Forms"), 155 vkna("Vertical Kana Alternates"), 156 vkrn("Vertical Kerning"), 157 vpal("Proportional Alternate Vertical Metrics"), 158 vrt2("Vertical Alternates and Rotation"), 159 zero("Slashed Zero"); 160 161 private static Map<Integer, FeatureTag> tagMap; 162 FeatureTag(String name)163 private FeatureTag(String name) { 164 this.tag = Tag.intValue(name()); 165 this.name = name; 166 } 167 FeatureTag(String tagName, String name)168 private FeatureTag(String tagName, String name) { 169 this.tag = Tag.intValue(tagName); 170 this.name = name; 171 } 172 forTagValue(int value)173 public static FeatureTag forTagValue(int value) { 174 synchronized (FeatureTag.class) { 175 if (tagMap == null) { 176 Map<Integer, FeatureTag> map = new HashMap<Integer, FeatureTag>(); 177 for (FeatureTag tag : values()) { 178 map.put(tag.tag(), tag); 179 } 180 tagMap = map; 181 } 182 return tagMap.get(value); 183 } 184 } 185 tag()186 private int tag() { 187 return tag; 188 } 189 longName()190 public String longName() { 191 return name; 192 } 193 194 private final int tag; 195 private final String name; 196 } 197