1 | use ttf_parser::Tag; |
2 | |
3 | use crate::aat::feature_selector::*; |
4 | use crate::aat::FeatureType; |
5 | |
6 | pub struct FeatureMapping { |
7 | pub ot_feature_tag: Tag, |
8 | pub aat_feature_type: FeatureType, |
9 | pub selector_to_enable: u8, |
10 | pub selector_to_disable: u8, |
11 | } |
12 | |
13 | impl FeatureMapping { |
14 | const fn new( |
15 | ot_feature_tag: &[u8; 4], |
16 | aat_feature_type: FeatureType, |
17 | selector_to_enable: u8, |
18 | selector_to_disable: u8, |
19 | ) -> Self { |
20 | FeatureMapping { |
21 | ot_feature_tag: Tag::from_bytes(ot_feature_tag), |
22 | aat_feature_type, |
23 | selector_to_enable, |
24 | selector_to_disable, |
25 | } |
26 | } |
27 | } |
28 | |
29 | /// Mapping from OpenType feature tags to AAT feature names and selectors. |
30 | /// |
31 | /// Table data courtesy of Apple. |
32 | /// Converted from mnemonics to integers when moving to this file. |
33 | #[rustfmt::skip] |
34 | pub const FEATURE_MAPPINGS: &[FeatureMapping] = &[ |
35 | FeatureMapping::new(ot_feature_tag:b"afrc" , aat_feature_type:FeatureType::Fractions, VERTICAL_FRACTIONS, NO_FRACTIONS), |
36 | FeatureMapping::new(ot_feature_tag:b"c2pc" , aat_feature_type:FeatureType::UpperCase, UPPER_CASE_PETITE_CAPS, DEFAULT_UPPER_CASE), |
37 | FeatureMapping::new(ot_feature_tag:b"c2sc" , aat_feature_type:FeatureType::UpperCase, UPPER_CASE_SMALL_CAPS, DEFAULT_UPPER_CASE), |
38 | FeatureMapping::new(ot_feature_tag:b"calt" , aat_feature_type:FeatureType::ContextualAlternatives, CONTEXTUAL_ALTERNATES_ON, CONTEXTUAL_ALTERNATES_OFF), |
39 | FeatureMapping::new(ot_feature_tag:b"case" , aat_feature_type:FeatureType::CaseSensitiveLayout, CASE_SENSITIVE_LAYOUT_ON, CASE_SENSITIVE_LAYOUT_OFF), |
40 | FeatureMapping::new(ot_feature_tag:b"clig" , aat_feature_type:FeatureType::Ligatures, CONTEXTUAL_LIGATURES_ON, CONTEXTUAL_LIGATURES_OFF), |
41 | FeatureMapping::new(ot_feature_tag:b"cpsp" , aat_feature_type:FeatureType::CaseSensitiveLayout, CASE_SENSITIVE_SPACING_ON, CASE_SENSITIVE_SPACING_OFF), |
42 | FeatureMapping::new(ot_feature_tag:b"cswh" , aat_feature_type:FeatureType::ContextualAlternatives, CONTEXTUAL_SWASH_ALTERNATES_ON, CONTEXTUAL_SWASH_ALTERNATES_OFF), |
43 | FeatureMapping::new(ot_feature_tag:b"dlig" , aat_feature_type:FeatureType::Ligatures, RARE_LIGATURES_ON, RARE_LIGATURES_OFF), |
44 | FeatureMapping::new(ot_feature_tag:b"expt" , aat_feature_type:FeatureType::CharacterShape, EXPERT_CHARACTERS, selector_to_disable:16), |
45 | FeatureMapping::new(ot_feature_tag:b"frac" , aat_feature_type:FeatureType::Fractions, DIAGONAL_FRACTIONS, NO_FRACTIONS), |
46 | FeatureMapping::new(ot_feature_tag:b"fwid" , aat_feature_type:FeatureType::TextSpacing, MONOSPACED_TEXT, selector_to_disable:7), |
47 | FeatureMapping::new(ot_feature_tag:b"halt" , aat_feature_type:FeatureType::TextSpacing, ALT_HALF_WIDTH_TEXT, selector_to_disable:7), |
48 | FeatureMapping::new(ot_feature_tag:b"hist" , aat_feature_type:FeatureType::Dummy, selector_to_enable:0, selector_to_disable:1), |
49 | FeatureMapping::new(ot_feature_tag:b"hkna" , aat_feature_type:FeatureType::AlternateKana, ALTERNATE_HORIZ_KANA_ON, ALTERNATE_HORIZ_KANA_OFF), |
50 | FeatureMapping::new(ot_feature_tag:b"hlig" , aat_feature_type:FeatureType::Ligatures, HISTORICAL_LIGATURES_ON, HISTORICAL_LIGATURES_OFF), |
51 | FeatureMapping::new(ot_feature_tag:b"hngl" , aat_feature_type:FeatureType::Transliteration, HANJA_TO_HANGUL, NO_TRANSLITERATION), |
52 | FeatureMapping::new(ot_feature_tag:b"hojo" , aat_feature_type:FeatureType::CharacterShape, HOJO_CHARACTERS, selector_to_disable:16), |
53 | FeatureMapping::new(ot_feature_tag:b"hwid" , aat_feature_type:FeatureType::TextSpacing, HALF_WIDTH_TEXT, selector_to_disable:7), |
54 | FeatureMapping::new(ot_feature_tag:b"ital" , aat_feature_type:FeatureType::ItalicCjkRoman, CJK_ITALIC_ROMAN_ON, CJK_ITALIC_ROMAN_OFF), |
55 | FeatureMapping::new(ot_feature_tag:b"jp04" , aat_feature_type:FeatureType::CharacterShape, JIS2004_CHARACTERS, selector_to_disable:16), |
56 | FeatureMapping::new(ot_feature_tag:b"jp78" , aat_feature_type:FeatureType::CharacterShape, JIS1978_CHARACTERS, selector_to_disable:16), |
57 | FeatureMapping::new(ot_feature_tag:b"jp83" , aat_feature_type:FeatureType::CharacterShape, JIS1983_CHARACTERS, selector_to_disable:16), |
58 | FeatureMapping::new(ot_feature_tag:b"jp90" , aat_feature_type:FeatureType::CharacterShape, JIS1990_CHARACTERS, selector_to_disable:16), |
59 | FeatureMapping::new(ot_feature_tag:b"liga" , aat_feature_type:FeatureType::Ligatures, COMMON_LIGATURES_ON, COMMON_LIGATURES_OFF), |
60 | FeatureMapping::new(ot_feature_tag:b"lnum" , aat_feature_type:FeatureType::NumberCase, UPPER_CASE_NUMBERS, selector_to_disable:2), |
61 | FeatureMapping::new(ot_feature_tag:b"mgrk" , aat_feature_type:FeatureType::MathematicalExtras, MATHEMATICAL_GREEK_ON, MATHEMATICAL_GREEK_OFF), |
62 | FeatureMapping::new(ot_feature_tag:b"nlck" , aat_feature_type:FeatureType::CharacterShape, NLCCHARACTERS, selector_to_disable:16), |
63 | FeatureMapping::new(ot_feature_tag:b"onum" , aat_feature_type:FeatureType::NumberCase, LOWER_CASE_NUMBERS, selector_to_disable:2), |
64 | FeatureMapping::new(ot_feature_tag:b"ordn" , aat_feature_type:FeatureType::VerticalPosition, ORDINALS, NORMAL_POSITION), |
65 | FeatureMapping::new(ot_feature_tag:b"palt" , aat_feature_type:FeatureType::TextSpacing, ALT_PROPORTIONAL_TEXT, selector_to_disable:7), |
66 | FeatureMapping::new(ot_feature_tag:b"pcap" , aat_feature_type:FeatureType::LowerCase, LOWER_CASE_PETITE_CAPS, DEFAULT_LOWER_CASE), |
67 | FeatureMapping::new(ot_feature_tag:b"pkna" , aat_feature_type:FeatureType::TextSpacing, PROPORTIONAL_TEXT, selector_to_disable:7), |
68 | FeatureMapping::new(ot_feature_tag:b"pnum" , aat_feature_type:FeatureType::NumberSpacing, PROPORTIONAL_NUMBERS, selector_to_disable:4), |
69 | FeatureMapping::new(ot_feature_tag:b"pwid" , aat_feature_type:FeatureType::TextSpacing, PROPORTIONAL_TEXT, selector_to_disable:7), |
70 | FeatureMapping::new(ot_feature_tag:b"qwid" , aat_feature_type:FeatureType::TextSpacing, QUARTER_WIDTH_TEXT, selector_to_disable:7), |
71 | FeatureMapping::new(ot_feature_tag:b"ruby" , aat_feature_type:FeatureType::RubyKana, RUBY_KANA_ON, RUBY_KANA_OFF), |
72 | FeatureMapping::new(ot_feature_tag:b"sinf" , aat_feature_type:FeatureType::VerticalPosition, SCIENTIFIC_INFERIORS, NORMAL_POSITION), |
73 | FeatureMapping::new(ot_feature_tag:b"smcp" , aat_feature_type:FeatureType::LowerCase, LOWER_CASE_SMALL_CAPS, DEFAULT_LOWER_CASE), |
74 | FeatureMapping::new(ot_feature_tag:b"smpl" , aat_feature_type:FeatureType::CharacterShape, SIMPLIFIED_CHARACTERS, selector_to_disable:16), |
75 | FeatureMapping::new(ot_feature_tag:b"ss01" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_ONE_ON, STYLISTIC_ALT_ONE_OFF), |
76 | FeatureMapping::new(ot_feature_tag:b"ss02" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_TWO_ON, STYLISTIC_ALT_TWO_OFF), |
77 | FeatureMapping::new(ot_feature_tag:b"ss03" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_THREE_ON, STYLISTIC_ALT_THREE_OFF), |
78 | FeatureMapping::new(ot_feature_tag:b"ss04" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_FOUR_ON, STYLISTIC_ALT_FOUR_OFF), |
79 | FeatureMapping::new(ot_feature_tag:b"ss05" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_FIVE_ON, STYLISTIC_ALT_FIVE_OFF), |
80 | FeatureMapping::new(ot_feature_tag:b"ss06" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_SIX_ON, STYLISTIC_ALT_SIX_OFF), |
81 | FeatureMapping::new(ot_feature_tag:b"ss07" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_SEVEN_ON, STYLISTIC_ALT_SEVEN_OFF), |
82 | FeatureMapping::new(ot_feature_tag:b"ss08" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_EIGHT_ON, STYLISTIC_ALT_EIGHT_OFF), |
83 | FeatureMapping::new(ot_feature_tag:b"ss09" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_NINE_ON, STYLISTIC_ALT_NINE_OFF), |
84 | FeatureMapping::new(ot_feature_tag:b"ss10" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_TEN_ON, STYLISTIC_ALT_TEN_OFF), |
85 | FeatureMapping::new(ot_feature_tag:b"ss11" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_ELEVEN_ON, STYLISTIC_ALT_ELEVEN_OFF), |
86 | FeatureMapping::new(ot_feature_tag:b"ss12" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_TWELVE_ON, STYLISTIC_ALT_TWELVE_OFF), |
87 | FeatureMapping::new(ot_feature_tag:b"ss13" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_THIRTEEN_ON, STYLISTIC_ALT_THIRTEEN_OFF), |
88 | FeatureMapping::new(ot_feature_tag:b"ss14" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_FOURTEEN_ON, STYLISTIC_ALT_FOURTEEN_OFF), |
89 | FeatureMapping::new(ot_feature_tag:b"ss15" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_FIFTEEN_ON, STYLISTIC_ALT_FIFTEEN_OFF), |
90 | FeatureMapping::new(ot_feature_tag:b"ss16" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_SIXTEEN_ON, STYLISTIC_ALT_SIXTEEN_OFF), |
91 | FeatureMapping::new(ot_feature_tag:b"ss17" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_SEVENTEEN_ON, STYLISTIC_ALT_SEVENTEEN_OFF), |
92 | FeatureMapping::new(ot_feature_tag:b"ss18" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_EIGHTEEN_ON, STYLISTIC_ALT_EIGHTEEN_OFF), |
93 | FeatureMapping::new(ot_feature_tag:b"ss19" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_NINETEEN_ON, STYLISTIC_ALT_NINETEEN_OFF), |
94 | FeatureMapping::new(ot_feature_tag:b"ss20" , aat_feature_type:FeatureType::StylisticAlternatives, STYLISTIC_ALT_TWENTY_ON, STYLISTIC_ALT_TWENTY_OFF), |
95 | FeatureMapping::new(ot_feature_tag:b"subs" , aat_feature_type:FeatureType::VerticalPosition, INFERIORS, NORMAL_POSITION), |
96 | FeatureMapping::new(ot_feature_tag:b"sups" , aat_feature_type:FeatureType::VerticalPosition, SUPERIORS, NORMAL_POSITION), |
97 | FeatureMapping::new(ot_feature_tag:b"swsh" , aat_feature_type:FeatureType::ContextualAlternatives, SWASH_ALTERNATES_ON, SWASH_ALTERNATES_OFF), |
98 | FeatureMapping::new(ot_feature_tag:b"titl" , aat_feature_type:FeatureType::StyleOptions, TITLING_CAPS, NO_STYLE_OPTIONS), |
99 | FeatureMapping::new(ot_feature_tag:b"tnam" , aat_feature_type:FeatureType::CharacterShape, TRADITIONAL_NAMES_CHARACTERS, selector_to_disable:16), |
100 | FeatureMapping::new(ot_feature_tag:b"tnum" , aat_feature_type:FeatureType::NumberSpacing, MONOSPACED_NUMBERS, selector_to_disable:4), |
101 | FeatureMapping::new(ot_feature_tag:b"trad" , aat_feature_type:FeatureType::CharacterShape, TRADITIONAL_CHARACTERS, selector_to_disable:16), |
102 | FeatureMapping::new(ot_feature_tag:b"twid" , aat_feature_type:FeatureType::TextSpacing, THIRD_WIDTH_TEXT, selector_to_disable:7), |
103 | FeatureMapping::new(ot_feature_tag:b"unic" , aat_feature_type:FeatureType::LetterCase, selector_to_enable:14, selector_to_disable:15), |
104 | FeatureMapping::new(ot_feature_tag:b"valt" , aat_feature_type:FeatureType::TextSpacing, ALT_PROPORTIONAL_TEXT, selector_to_disable:7), |
105 | FeatureMapping::new(ot_feature_tag:b"vert" , aat_feature_type:FeatureType::VerticalSubstitution, SUBSTITUTE_VERTICAL_FORMS_ON, SUBSTITUTE_VERTICAL_FORMS_OFF), |
106 | FeatureMapping::new(ot_feature_tag:b"vhal" , aat_feature_type:FeatureType::TextSpacing, ALT_HALF_WIDTH_TEXT, selector_to_disable:7), |
107 | FeatureMapping::new(ot_feature_tag:b"vkna" , aat_feature_type:FeatureType::AlternateKana, ALTERNATE_VERT_KANA_ON, ALTERNATE_VERT_KANA_OFF), |
108 | FeatureMapping::new(ot_feature_tag:b"vpal" , aat_feature_type:FeatureType::TextSpacing, ALT_PROPORTIONAL_TEXT, selector_to_disable:7), |
109 | FeatureMapping::new(ot_feature_tag:b"vrt2" , aat_feature_type:FeatureType::VerticalSubstitution, SUBSTITUTE_VERTICAL_FORMS_ON, SUBSTITUTE_VERTICAL_FORMS_OFF), |
110 | FeatureMapping::new(ot_feature_tag:b"vrtr" , aat_feature_type:FeatureType::VerticalSubstitution, selector_to_enable:2, selector_to_disable:3), |
111 | FeatureMapping::new(ot_feature_tag:b"zero" , aat_feature_type:FeatureType::TypographicExtras, SLASHED_ZERO_ON, SLASHED_ZERO_OFF), |
112 | ]; |
113 | |