OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2010,2011,2012 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. |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "hb-ot-shape-private.hh" | 32 #include "hb-ot-shape-private.hh" |
33 #include "hb-ot-shape-normalize-private.hh" | 33 #include "hb-ot-shape-normalize-private.hh" |
34 | 34 |
35 | 35 |
36 | 36 |
37 /* buffer var allocations, used by complex shapers */ | 37 /* buffer var allocations, used by complex shapers */ |
38 #define complex_var_u8_0() var2.u8[2] | 38 #define complex_var_u8_0() var2.u8[2] |
39 #define complex_var_u8_1() var2.u8[3] | 39 #define complex_var_u8_1() var2.u8[3] |
40 | 40 |
41 | 41 |
| 42 enum hb_ot_shape_zero_width_marks_type_t { |
| 43 HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, |
| 44 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE, |
| 45 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF |
| 46 }; |
| 47 |
42 | 48 |
43 /* Master OT shaper list */ | 49 /* Master OT shaper list */ |
44 #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \ | 50 #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \ |
45 HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \ | 51 HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \ |
46 HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \ | 52 HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \ |
47 HB_COMPLEX_SHAPER_IMPLEMENT (indic) \ | 53 HB_COMPLEX_SHAPER_IMPLEMENT (indic) \ |
| 54 HB_COMPLEX_SHAPER_IMPLEMENT (myanmar) \ |
| 55 HB_COMPLEX_SHAPER_IMPLEMENT (sea) \ |
48 HB_COMPLEX_SHAPER_IMPLEMENT (thai) \ | 56 HB_COMPLEX_SHAPER_IMPLEMENT (thai) \ |
49 /* ^--- Add new shapers here */ | 57 /* ^--- Add new shapers here */ |
50 | 58 |
51 | 59 |
52 struct hb_ot_complex_shaper_t | 60 struct hb_ot_complex_shaper_t |
53 { | 61 { |
54 char name[8]; | 62 char name[8]; |
55 | 63 |
56 /* collect_features() | 64 /* collect_features() |
57 * Called during shape_plan(). | 65 * Called during shape_plan(). |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 /* setup_masks() | 131 /* setup_masks() |
124 * Called during shape(). | 132 * Called during shape(). |
125 * Shapers should use map to get feature masks and set on buffer. | 133 * Shapers should use map to get feature masks and set on buffer. |
126 * Shapers may NOT modify characters. | 134 * Shapers may NOT modify characters. |
127 * May be NULL. | 135 * May be NULL. |
128 */ | 136 */ |
129 void (*setup_masks) (const hb_ot_shape_plan_t *plan, | 137 void (*setup_masks) (const hb_ot_shape_plan_t *plan, |
130 hb_buffer_t *buffer, | 138 hb_buffer_t *buffer, |
131 hb_font_t *font); | 139 hb_font_t *font); |
132 | 140 |
133 bool zero_width_attached_marks; | 141 hb_ot_shape_zero_width_marks_type_t zero_width_marks; |
| 142 |
134 bool fallback_position; | 143 bool fallback_position; |
135 }; | 144 }; |
136 | 145 |
137 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_complex
_shaper_t _hb_ot_complex_shaper_##name; | 146 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_complex
_shaper_t _hb_ot_complex_shaper_##name; |
138 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS | 147 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS |
139 #undef HB_COMPLEX_SHAPER_IMPLEMENT | 148 #undef HB_COMPLEX_SHAPER_IMPLEMENT |
140 | 149 |
141 | 150 |
142 static inline const hb_ot_complex_shaper_t * | 151 static inline const hb_ot_complex_shaper_t * |
143 hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner) | 152 hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 case HB_SCRIPT_MALAYALAM: | 256 case HB_SCRIPT_MALAYALAM: |
248 case HB_SCRIPT_ORIYA: | 257 case HB_SCRIPT_ORIYA: |
249 case HB_SCRIPT_TAMIL: | 258 case HB_SCRIPT_TAMIL: |
250 case HB_SCRIPT_TELUGU: | 259 case HB_SCRIPT_TELUGU: |
251 | 260 |
252 /* Unicode-3.0 additions */ | 261 /* Unicode-3.0 additions */ |
253 case HB_SCRIPT_SINHALA: | 262 case HB_SCRIPT_SINHALA: |
254 | 263 |
255 /* Unicode-4.1 additions */ | 264 /* Unicode-4.1 additions */ |
256 case HB_SCRIPT_BUGINESE: | 265 case HB_SCRIPT_BUGINESE: |
257 case HB_SCRIPT_NEW_TAI_LUE: | |
258 | 266 |
259 /* Unicode-5.0 additions */ | 267 /* Unicode-5.0 additions */ |
260 case HB_SCRIPT_BALINESE: | 268 case HB_SCRIPT_BALINESE: |
261 | 269 |
262 /* Unicode-5.1 additions */ | 270 /* Unicode-5.1 additions */ |
263 case HB_SCRIPT_CHAM: | |
264 case HB_SCRIPT_LEPCHA: | 271 case HB_SCRIPT_LEPCHA: |
265 case HB_SCRIPT_REJANG: | 272 case HB_SCRIPT_REJANG: |
266 case HB_SCRIPT_SUNDANESE: | 273 case HB_SCRIPT_SUNDANESE: |
267 | 274 |
268 /* Unicode-5.2 additions */ | 275 /* Unicode-5.2 additions */ |
269 case HB_SCRIPT_JAVANESE: | 276 case HB_SCRIPT_JAVANESE: |
270 case HB_SCRIPT_KAITHI: | 277 case HB_SCRIPT_KAITHI: |
271 case HB_SCRIPT_MEETEI_MAYEK: | 278 case HB_SCRIPT_MEETEI_MAYEK: |
272 case HB_SCRIPT_TAI_THAM: | |
273 | 279 |
| 280 /* Unicode-6.0 additions */ |
274 | 281 |
275 /* Unicode-6.1 additions */ | 282 /* Unicode-6.1 additions */ |
276 case HB_SCRIPT_CHAKMA: | 283 case HB_SCRIPT_CHAKMA: |
277 case HB_SCRIPT_SHARADA: | 284 case HB_SCRIPT_SHARADA: |
278 case HB_SCRIPT_TAKRI: | 285 case HB_SCRIPT_TAKRI: |
279 | 286 |
280 /* Only use Indic shaper if the font has Indic tables. */ | 287 /* If the designer designed the font for the 'DFLT' script, |
281 if (planner->map.found_script[0]) | 288 * use the default shaper. Otherwise, use the Indic shaper. |
| 289 * Note that for some simple scripts, there may not be *any* |
| 290 * GSUB/GPOS needed, so there may be no scripts found! */ |
| 291 if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T')) |
| 292 » return &_hb_ot_complex_shaper_default; |
| 293 else |
282 return &_hb_ot_complex_shaper_indic; | 294 return &_hb_ot_complex_shaper_indic; |
283 else | |
284 return &_hb_ot_complex_shaper_default; | |
285 | 295 |
286 case HB_SCRIPT_KHMER: | 296 case HB_SCRIPT_KHMER: |
287 /* A number of Khmer fonts in the wild don't have a 'pref' feature, | 297 /* A number of Khmer fonts in the wild don't have a 'pref' feature, |
288 * and as such won't shape properly via the Indic shaper; | 298 * and as such won't shape properly via the Indic shaper; |
289 * however, they typically have 'liga' / 'clig' features that implement | 299 * however, they typically have 'liga' / 'clig' features that implement |
290 * the necessary "reordering" by means of ligature substitutions. | 300 * the necessary "reordering" by means of ligature substitutions. |
291 * So we send such pref-less fonts through the generic shaper instead. */ | 301 * So we send such pref-less fonts through the generic shaper instead. */ |
292 if (planner->map.found_script[0] && | 302 if (planner->map.found_script[0] && |
293 hb_ot_layout_language_find_feature (planner->face, HB_OT_TAG_GSUB, | 303 hb_ot_layout_language_find_feature (planner->face, HB_OT_TAG_GSUB, |
294 planner->map.script_index[0], | 304 planner->map.script_index[0], |
295 planner->map.language_index[0], | 305 planner->map.language_index[0], |
296 HB_TAG ('p','r','e','f'), | 306 HB_TAG ('p','r','e','f'), |
297 NULL)) | 307 NULL)) |
298 return &_hb_ot_complex_shaper_indic; | 308 return &_hb_ot_complex_shaper_indic; |
299 else | 309 else |
300 return &_hb_ot_complex_shaper_default; | 310 return &_hb_ot_complex_shaper_default; |
301 | 311 |
302 case HB_SCRIPT_MYANMAR: | 312 case HB_SCRIPT_MYANMAR: |
303 /* For Myanmar, we only want to use the Indic shaper if the "new" script | 313 /* For Myanmar, we only want to use the Myanmar shaper if the "new" script |
304 * tag is found. For "old" script tag we want to use the default shaper.
*/ | 314 * tag is found. For "old" script tag we want to use the default shaper.
*/ |
305 if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','2')) | 315 if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','2')) |
306 » return &_hb_ot_complex_shaper_indic; | 316 » return &_hb_ot_complex_shaper_myanmar; |
307 else | 317 else |
308 return &_hb_ot_complex_shaper_default; | 318 return &_hb_ot_complex_shaper_default; |
| 319 |
| 320 /* Unicode-4.1 additions */ |
| 321 case HB_SCRIPT_NEW_TAI_LUE: |
| 322 |
| 323 /* Unicode-5.1 additions */ |
| 324 case HB_SCRIPT_CHAM: |
| 325 |
| 326 /* Unicode-5.2 additions */ |
| 327 case HB_SCRIPT_TAI_THAM: |
| 328 |
| 329 /* If the designer designed the font for the 'DFLT' script, |
| 330 * use the default shaper. Otherwise, use the Indic shaper. |
| 331 * Note that for some simple scripts, there may not be *any* |
| 332 * GSUB/GPOS needed, so there may be no scripts found! */ |
| 333 if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T')) |
| 334 return &_hb_ot_complex_shaper_default; |
| 335 else |
| 336 return &_hb_ot_complex_shaper_sea; |
309 } | 337 } |
310 } | 338 } |
311 | 339 |
312 | 340 |
313 #endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */ | 341 #endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */ |
OLD | NEW |