OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2010,2011 Google, Inc. | 2 * Copyright © 2010,2011,2012 Google, Inc. |
3 * | 3 * |
4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
5 * | 5 * |
6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
10 * all copies of this software. | 10 * all copies of this software. |
11 * | 11 * |
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
(...skipping 10 matching lines...) Expand all Loading... |
23 * | 23 * |
24 * Google Author(s): Behdad Esfahbod | 24 * Google Author(s): Behdad Esfahbod |
25 */ | 25 */ |
26 | 26 |
27 #ifndef HB_OT_SHAPE_COMPLEX_PRIVATE_HH | 27 #ifndef HB_OT_SHAPE_COMPLEX_PRIVATE_HH |
28 #define HB_OT_SHAPE_COMPLEX_PRIVATE_HH | 28 #define HB_OT_SHAPE_COMPLEX_PRIVATE_HH |
29 | 29 |
30 #include "hb-private.hh" | 30 #include "hb-private.hh" |
31 | 31 |
32 #include "hb-ot-map-private.hh" | 32 #include "hb-ot-map-private.hh" |
| 33 #include "hb-ot-shape-normalize-private.hh" |
33 | 34 |
34 | 35 |
35 | 36 |
36 /* buffer var allocations, used during the entire shaping process */ | 37 /* buffer var allocations, used during the entire shaping process */ |
37 #define general_category() var1.u8[0] /* unicode general_category (hb_unicode_ge
neral_category_t) */ | 38 #define unicode_props0()» var1.u8[0] |
38 #define combining_class() var1.u8[1] /* unicode combining_class (uint8_t) */ | 39 #define unicode_props1()» var1.u8[1] |
| 40 |
| 41 /* buffer var allocations, used during the GSUB/GPOS processing */ |
| 42 #define props_cache()» » var1.u16[1] /* GSUB/GPOS glyph_props cache */ |
| 43 #define syllable()» » var2.u8[0] /* GSUB/GPOS shaping boundaries */ |
| 44 #define lig_props()» » var2.u8[1] /* GSUB/GPOS ligature tracking */ |
39 | 45 |
40 /* buffer var allocations, used by complex shapers */ | 46 /* buffer var allocations, used by complex shapers */ |
41 #define complex_var_persistent_u8_0()» var2.u8[0] | 47 #define complex_var_persistent_u8_0()» var2.u8[2] |
42 #define complex_var_persistent_u8_1()» var2.u8[1] | 48 #define complex_var_persistent_u8_1()» var2.u8[3] |
43 #define complex_var_persistent_u16()» var2.u16[0] | 49 #define complex_var_temporary_u8()» var2.u8[0] |
44 #define complex_var_temporary_u8_0()» var2.u8[2] | |
45 #define complex_var_temporary_u8_1()» var2.u8[3] | |
46 #define complex_var_temporary_u16()» var2.u16[1] | |
47 | 50 |
48 | 51 |
49 #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \ | 52 #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \ |
50 HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \ | 53 HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \ |
51 HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \ | 54 HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \ |
| 55 HB_COMPLEX_SHAPER_IMPLEMENT (hangul) \ |
52 HB_COMPLEX_SHAPER_IMPLEMENT (indic) \ | 56 HB_COMPLEX_SHAPER_IMPLEMENT (indic) \ |
| 57 HB_COMPLEX_SHAPER_IMPLEMENT (thai) \ |
53 /* ^--- Add new shapers here */ | 58 /* ^--- Add new shapers here */ |
54 | 59 |
55 enum hb_ot_complex_shaper_t { | 60 enum hb_ot_complex_shaper_t { |
56 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) hb_ot_complex_shaper_##name, | 61 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) hb_ot_complex_shaper_##name, |
57 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS | 62 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS |
58 /* Just here to avoid enum trailing comma: */ | 63 /* Just here to avoid enum trailing comma: */ |
59 hb_ot_complex_shaper_generic = hb_ot_complex_shaper_default | 64 hb_ot_complex_shaper_generic = hb_ot_complex_shaper_default |
60 #undef HB_COMPLEX_SHAPER_IMPLEMENT | 65 #undef HB_COMPLEX_SHAPER_IMPLEMENT |
61 }; | 66 }; |
62 | 67 |
63 static inline hb_ot_complex_shaper_t | 68 static inline hb_ot_complex_shaper_t |
64 hb_ot_shape_complex_categorize (const hb_segment_properties_t *props) | 69 hb_ot_shape_complex_categorize (const hb_segment_properties_t *props) |
65 { | 70 { |
66 switch ((int) props->script) | 71 switch ((hb_tag_t) props->script) |
67 { | 72 { |
68 default: | 73 default: |
69 return hb_ot_complex_shaper_default; | 74 return hb_ot_complex_shaper_default; |
70 | 75 |
| 76 |
| 77 /* Unicode-1.1 additions */ |
71 case HB_SCRIPT_ARABIC: | 78 case HB_SCRIPT_ARABIC: |
| 79 case HB_SCRIPT_MONGOLIAN: |
| 80 case HB_SCRIPT_SYRIAC: |
| 81 |
| 82 /* Unicode-5.0 additions */ |
| 83 case HB_SCRIPT_NKO: |
| 84 |
| 85 /* Unicode-6.0 additions */ |
72 case HB_SCRIPT_MANDAIC: | 86 case HB_SCRIPT_MANDAIC: |
73 case HB_SCRIPT_MONGOLIAN: | 87 |
74 case HB_SCRIPT_NKO: | |
75 case HB_SCRIPT_SYRIAC: | |
76 return hb_ot_complex_shaper_arabic; | 88 return hb_ot_complex_shaper_arabic; |
77 | 89 |
| 90 |
| 91 /* Unicode-1.1 additions */ |
| 92 case HB_SCRIPT_HANGUL: |
| 93 |
| 94 return hb_ot_complex_shaper_hangul; |
| 95 |
| 96 |
| 97 /* Unicode-1.1 additions */ |
| 98 case HB_SCRIPT_THAI: |
| 99 case HB_SCRIPT_LAO: |
| 100 |
| 101 return hb_ot_complex_shaper_thai; |
| 102 |
| 103 |
| 104 |
| 105 /* ^--- Add new shapers here */ |
| 106 |
| 107 |
78 #if 0 | 108 #if 0 |
79 /* Note: | 109 /* Note: |
80 * | 110 * |
81 * These disabled scripts are listed in ucd/IndicSyllabicCategory.txt, but a
ccording | 111 * These disabled scripts are listed in ucd/IndicSyllabicCategory.txt, but a
ccording |
82 * to Martin Hosken do not require complex shaping. | 112 * to Martin Hosken and Jonathan Kew do not require complex shaping. |
| 113 * |
| 114 * TODO We should automate figuring out which scripts do not need complex sh
aping |
83 * | 115 * |
84 * TODO We currently keep data for these scripts in our indic table. Need t
o fix the | 116 * TODO We currently keep data for these scripts in our indic table. Need t
o fix the |
85 * generator to not do that. | 117 * generator to not do that. |
86 */ | 118 */ |
87 | 119 |
| 120 |
88 /* Simple? */ | 121 /* Simple? */ |
| 122 |
| 123 /* Unicode-3.2 additions */ |
| 124 case HB_SCRIPT_BUHID: |
| 125 case HB_SCRIPT_HANUNOO: |
| 126 |
| 127 /* Unicode-5.1 additions */ |
| 128 case HB_SCRIPT_SAURASHTRA: |
| 129 |
| 130 /* Unicode-5.2 additions */ |
| 131 case HB_SCRIPT_MEETEI_MAYEK: |
| 132 |
| 133 /* Unicode-6.0 additions */ |
89 case HB_SCRIPT_BATAK: | 134 case HB_SCRIPT_BATAK: |
90 case HB_SCRIPT_BRAHMI: | 135 case HB_SCRIPT_BRAHMI: |
91 case HB_SCRIPT_HANUNOO: | 136 |
92 case HB_SCRIPT_MEETEI_MAYEK: | |
93 case HB_SCRIPT_SAURASHTRA: | |
94 | 137 |
95 /* Simple */ | 138 /* Simple */ |
96 case HB_SCRIPT_KAYAH_LI: | 139 |
| 140 /* Unicode-1.1 additions */ |
| 141 /* These have their own shaper now. */ |
97 case HB_SCRIPT_LAO: | 142 case HB_SCRIPT_LAO: |
98 case HB_SCRIPT_LIMBU: | 143 case HB_SCRIPT_THAI: |
99 case HB_SCRIPT_PHAGS_PA: | 144 |
100 case HB_SCRIPT_SYLOTI_NAGRI: | 145 /* Unicode-2.0 additions */ |
| 146 case HB_SCRIPT_TIBETAN: |
| 147 |
| 148 /* Unicode-3.2 additions */ |
101 case HB_SCRIPT_TAGALOG: | 149 case HB_SCRIPT_TAGALOG: |
102 case HB_SCRIPT_TAGBANWA: | 150 case HB_SCRIPT_TAGBANWA: |
| 151 |
| 152 /* Unicode-4.0 additions */ |
| 153 case HB_SCRIPT_LIMBU: |
103 case HB_SCRIPT_TAI_LE: | 154 case HB_SCRIPT_TAI_LE: |
| 155 |
| 156 /* Unicode-4.1 additions */ |
| 157 case HB_SCRIPT_SYLOTI_NAGRI: |
| 158 |
| 159 /* Unicode-5.0 additions */ |
| 160 case HB_SCRIPT_PHAGS_PA: |
| 161 |
| 162 /* Unicode-5.1 additions */ |
| 163 case HB_SCRIPT_KAYAH_LI: |
| 164 |
| 165 /* Unicode-5.2 additions */ |
104 case HB_SCRIPT_TAI_VIET: | 166 case HB_SCRIPT_TAI_VIET: |
105 case HB_SCRIPT_THAI: | 167 |
106 case HB_SCRIPT_TIBETAN: | |
107 | 168 |
108 /* May need Indic treatment in the future? */ | 169 /* May need Indic treatment in the future? */ |
| 170 |
| 171 /* Unicode-3.0 additions */ |
109 case HB_SCRIPT_MYANMAR: | 172 case HB_SCRIPT_MYANMAR: |
| 173 |
| 174 |
110 #endif | 175 #endif |
111 | 176 |
112 case HB_SCRIPT_BALINESE: | 177 /* Unicode-1.1 additions */ |
113 case HB_SCRIPT_BENGALI: | 178 case HB_SCRIPT_BENGALI: |
114 case HB_SCRIPT_BUGINESE: | |
115 case HB_SCRIPT_BUHID: | |
116 case HB_SCRIPT_CHAM: | |
117 case HB_SCRIPT_DEVANAGARI: | 179 case HB_SCRIPT_DEVANAGARI: |
118 case HB_SCRIPT_GUJARATI: | 180 case HB_SCRIPT_GUJARATI: |
119 case HB_SCRIPT_GURMUKHI: | 181 case HB_SCRIPT_GURMUKHI: |
| 182 case HB_SCRIPT_KANNADA: |
| 183 case HB_SCRIPT_MALAYALAM: |
| 184 case HB_SCRIPT_ORIYA: |
| 185 case HB_SCRIPT_TAMIL: |
| 186 case HB_SCRIPT_TELUGU: |
| 187 |
| 188 /* Unicode-3.0 additions */ |
| 189 case HB_SCRIPT_KHMER: |
| 190 case HB_SCRIPT_SINHALA: |
| 191 |
| 192 /* Unicode-4.1 additions */ |
| 193 case HB_SCRIPT_BUGINESE: |
| 194 case HB_SCRIPT_KHAROSHTHI: |
| 195 case HB_SCRIPT_NEW_TAI_LUE: |
| 196 |
| 197 /* Unicode-5.0 additions */ |
| 198 case HB_SCRIPT_BALINESE: |
| 199 |
| 200 /* Unicode-5.1 additions */ |
| 201 case HB_SCRIPT_CHAM: |
| 202 case HB_SCRIPT_LEPCHA: |
| 203 case HB_SCRIPT_REJANG: |
| 204 case HB_SCRIPT_SUNDANESE: |
| 205 |
| 206 /* Unicode-5.2 additions */ |
120 case HB_SCRIPT_JAVANESE: | 207 case HB_SCRIPT_JAVANESE: |
121 case HB_SCRIPT_KAITHI: | 208 case HB_SCRIPT_KAITHI: |
122 case HB_SCRIPT_KANNADA: | |
123 case HB_SCRIPT_KHAROSHTHI: | |
124 case HB_SCRIPT_KHMER: | |
125 case HB_SCRIPT_LEPCHA: | |
126 case HB_SCRIPT_MALAYALAM: | |
127 case HB_SCRIPT_NEW_TAI_LUE: | |
128 case HB_SCRIPT_ORIYA: | |
129 case HB_SCRIPT_REJANG: | |
130 case HB_SCRIPT_SINHALA: | |
131 case HB_SCRIPT_SUNDANESE: | |
132 case HB_SCRIPT_TAI_THAM: | 209 case HB_SCRIPT_TAI_THAM: |
133 case HB_SCRIPT_TAMIL: | 210 |
134 case HB_SCRIPT_TELUGU: | 211 /* Unicode-6.1 additions */ |
| 212 case HB_SCRIPT_CHAKMA: |
| 213 case HB_SCRIPT_SHARADA: |
| 214 case HB_SCRIPT_TAKRI: |
| 215 |
135 return hb_ot_complex_shaper_indic; | 216 return hb_ot_complex_shaper_indic; |
136 | |
137 /* ^--- Add new shapers here */ | |
138 } | 217 } |
139 } | 218 } |
140 | 219 |
141 | 220 |
142 | 221 |
143 /* | 222 /* |
144 * collect_features() | 223 * collect_features() |
145 * | 224 * |
146 * Called during shape_plan(). | 225 * Called during shape_plan(). |
147 * | 226 * |
(...skipping 15 matching lines...) Expand all Loading... |
163 default: | 242 default: |
164 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ | 243 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ |
165 case hb_ot_complex_shaper_##name: _hb_ot_shape_complex_collect_features_##
name (map, props); return; | 244 case hb_ot_complex_shaper_##name: _hb_ot_shape_complex_collect_features_##
name (map, props); return; |
166 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS | 245 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS |
167 #undef HB_COMPLEX_SHAPER_IMPLEMENT | 246 #undef HB_COMPLEX_SHAPER_IMPLEMENT |
168 } | 247 } |
169 } | 248 } |
170 | 249 |
171 | 250 |
172 /* | 251 /* |
173 * prefer_decomposed() | 252 * normalization_preference() |
174 * | 253 * |
175 * Called during shape_execute(). | 254 * Called during shape_execute(). |
176 * | 255 * |
177 * Shapers should return TRUE if it prefers decomposed (NFD) input rather than p
recomposed (NFC). | 256 * Shapers should return TRUE if it prefers decomposed (NFD) input rather than p
recomposed (NFC). |
178 */ | 257 */ |
179 | 258 |
180 typedef bool hb_ot_shape_complex_prefer_decomposed_func_t (void); | 259 typedef hb_ot_shape_normalization_mode_t hb_ot_shape_complex_normalization_prefe
rence_func_t (void); |
181 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ | 260 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ |
182 HB_INTERNAL hb_ot_shape_complex_prefer_decomposed_func_t _hb_ot_shape_complex_
prefer_decomposed_##name; | 261 HB_INTERNAL hb_ot_shape_complex_normalization_preference_func_t _hb_ot_shape_c
omplex_normalization_preference_##name; |
183 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS | 262 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS |
184 #undef HB_COMPLEX_SHAPER_IMPLEMENT | 263 #undef HB_COMPLEX_SHAPER_IMPLEMENT |
185 | 264 |
186 static inline bool | 265 static inline hb_ot_shape_normalization_mode_t |
187 hb_ot_shape_complex_prefer_decomposed (hb_ot_complex_shaper_t shaper) | 266 hb_ot_shape_complex_normalization_preference (hb_ot_complex_shaper_t shaper) |
188 { | 267 { |
189 switch (shaper) { | 268 switch (shaper) { |
190 default: | 269 default: |
191 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ | 270 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ |
192 case hb_ot_complex_shaper_##name:» return _hb_ot_shape_complex_prefer_decom
posed_##name (); | 271 case hb_ot_complex_shaper_##name:» return _hb_ot_shape_complex_normalizatio
n_preference_##name (); |
193 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS | 272 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS |
194 #undef HB_COMPLEX_SHAPER_IMPLEMENT | 273 #undef HB_COMPLEX_SHAPER_IMPLEMENT |
195 } | 274 } |
196 } | 275 } |
197 | 276 |
198 | 277 |
199 /* setup_masks() | 278 /* setup_masks() |
200 * | 279 * |
201 * Called during shape_execute(). | 280 * Called during shape_execute(). |
202 * | 281 * |
203 * Shapers should use map to get feature masks and set on buffer. | 282 * Shapers should use map to get feature masks and set on buffer. |
204 */ | 283 */ |
205 | 284 |
206 typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer
_t *buffer); | 285 typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer
_t *buffer, hb_font_t *font); |
207 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ | 286 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ |
208 HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_
masks_##name; | 287 HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_
masks_##name; |
209 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS | 288 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS |
210 #undef HB_COMPLEX_SHAPER_IMPLEMENT | 289 #undef HB_COMPLEX_SHAPER_IMPLEMENT |
211 | 290 |
212 static inline void | 291 static inline void |
213 hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper, | 292 hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper, |
214 hb_ot_map_t *map, | 293 hb_ot_map_t *map, |
215 » » » » hb_buffer_t *buffer) | 294 » » » » hb_buffer_t *buffer, |
| 295 » » » » hb_font_t *font) |
216 { | 296 { |
217 switch (shaper) { | 297 switch (shaper) { |
218 default: | 298 default: |
219 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ | 299 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \ |
220 case hb_ot_complex_shaper_##name:» _hb_ot_shape_complex_setup_masks_##name
(map, buffer); return; | 300 case hb_ot_complex_shaper_##name:» _hb_ot_shape_complex_setup_masks_##name
(map, buffer, font); return; |
221 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS | 301 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS |
222 #undef HB_COMPLEX_SHAPER_IMPLEMENT | 302 #undef HB_COMPLEX_SHAPER_IMPLEMENT |
223 } | 303 } |
224 } | 304 } |
225 | 305 |
226 | 306 |
227 | 307 |
228 #endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */ | 308 #endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */ |
OLD | NEW |