OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2011,2012,2013 Google, Inc. | 2 * Copyright © 2011,2012,2013 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 static void | 113 static void |
114 override_features_myanmar (hb_ot_shape_planner_t *plan) | 114 override_features_myanmar (hb_ot_shape_planner_t *plan) |
115 { | 115 { |
116 plan->map.add_feature (HB_TAG('l','i','g','a'), 0, F_GLOBAL); | 116 plan->map.add_feature (HB_TAG('l','i','g','a'), 0, F_GLOBAL); |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 enum syllable_type_t { | 120 enum syllable_type_t { |
121 consonant_syllable, | 121 consonant_syllable, |
| 122 punctuation_cluster, |
122 broken_cluster, | 123 broken_cluster, |
123 non_myanmar_cluster, | 124 non_myanmar_cluster, |
124 }; | 125 }; |
125 | 126 |
126 #include "hb-ot-shape-complex-myanmar-machine.hh" | 127 #include "hb-ot-shape-complex-myanmar-machine.hh" |
127 | 128 |
128 | 129 |
129 /* Note: This enum is duplicated in the -machine.rl source file. | 130 /* Note: This enum is duplicated in the -machine.rl source file. |
130 * Not sure how to avoid duplication. */ | 131 * Not sure how to avoid duplication. */ |
131 enum myanmar_category_t { | 132 enum myanmar_category_t { |
132 OT_As = 18, /* Asat */ | 133 OT_As = 18, /* Asat */ |
133 OT_D = 19, /* Digits except zero */ | 134 OT_D = 19, /* Digits except zero */ |
134 OT_D0 = 20, /* Digit zero */ | 135 OT_D0 = 20, /* Digit zero */ |
135 OT_DB = OT_N, /* Dot below */ | 136 OT_DB = OT_N, /* Dot below */ |
136 OT_GB = OT_DOTTEDCIRCLE, | 137 OT_GB = OT_DOTTEDCIRCLE, |
137 OT_MH = 21, /* Various consonant medial types */ | 138 OT_MH = 21, /* Various consonant medial types */ |
138 OT_MR = 22, /* Various consonant medial types */ | 139 OT_MR = 22, /* Various consonant medial types */ |
139 OT_MW = 23, /* Various consonant medial types */ | 140 OT_MW = 23, /* Various consonant medial types */ |
140 OT_MY = 24, /* Various consonant medial types */ | 141 OT_MY = 24, /* Various consonant medial types */ |
141 OT_PT = 25, /* Pwo and other tones */ | 142 OT_PT = 25, /* Pwo and other tones */ |
142 OT_VAbv = 26, | 143 OT_VAbv = 26, |
143 OT_VBlw = 27, | 144 OT_VBlw = 27, |
144 OT_VPre = 28, | 145 OT_VPre = 28, |
145 OT_VPst = 29, | 146 OT_VPst = 29, |
146 OT_VS = 30 /* Variation selectors */ | 147 OT_VS = 30, /* Variation selectors */ |
| 148 OT_P = 31 /* Punctuation */ |
147 }; | 149 }; |
148 | 150 |
149 | 151 |
150 static inline bool | 152 static inline bool |
151 is_one_of (const hb_glyph_info_t &info, unsigned int flags) | 153 is_one_of (const hb_glyph_info_t &info, unsigned int flags) |
152 { | 154 { |
153 /* If it ligated, all bets are off. */ | 155 /* If it ligated, all bets are off. */ |
154 if (_hb_glyph_info_ligated (&info)) return false; | 156 if (_hb_glyph_info_ligated (&info)) return false; |
155 return !!(FLAG (info.myanmar_category()) & flags); | 157 return !!(FLAG (info.myanmar_category()) & flags); |
156 } | 158 } |
(...skipping 22 matching lines...) Expand all Loading... |
179 /* Myanmar | 181 /* Myanmar |
180 * http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm#analyze | 182 * http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm#analyze |
181 */ | 183 */ |
182 if (unlikely (hb_in_range<hb_codepoint_t> (u, 0xFE00, 0xFE0F))) | 184 if (unlikely (hb_in_range<hb_codepoint_t> (u, 0xFE00, 0xFE0F))) |
183 cat = (indic_category_t) OT_VS; | 185 cat = (indic_category_t) OT_VS; |
184 else if (unlikely (u == 0x200C)) cat = (indic_category_t) OT_ZWNJ; | 186 else if (unlikely (u == 0x200C)) cat = (indic_category_t) OT_ZWNJ; |
185 else if (unlikely (u == 0x200D)) cat = (indic_category_t) OT_ZWJ; | 187 else if (unlikely (u == 0x200D)) cat = (indic_category_t) OT_ZWJ; |
186 | 188 |
187 switch (u) | 189 switch (u) |
188 { | 190 { |
| 191 case 0x104E: |
| 192 cat = (indic_category_t) OT_C; /* The spec says C, IndicSyllableCategory d
oesn't have. */ |
| 193 break; |
| 194 |
189 case 0x002D: case 0x00A0: case 0x00D7: case 0x2012: | 195 case 0x002D: case 0x00A0: case 0x00D7: case 0x2012: |
190 case 0x2013: case 0x2014: case 0x2015: case 0x2022: | 196 case 0x2013: case 0x2014: case 0x2015: case 0x2022: |
191 case 0x25CC: case 0x25FB: case 0x25FC: case 0x25FD: | 197 case 0x25CC: case 0x25FB: case 0x25FC: case 0x25FD: |
192 case 0x25FE: | 198 case 0x25FE: |
193 cat = (indic_category_t) OT_GB; | 199 cat = (indic_category_t) OT_GB; |
194 break; | 200 break; |
195 | 201 |
196 case 0x1004: case 0x101B: case 0x105A: | 202 case 0x1004: case 0x101B: case 0x105A: |
197 cat = (indic_category_t) OT_Ra; | 203 cat = (indic_category_t) OT_Ra; |
198 break; | 204 break; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 case 0x1063: case 0x1064: case 0x1069: case 0x106A: | 242 case 0x1063: case 0x1064: case 0x1069: case 0x106A: |
237 case 0x106B: case 0x106C: case 0x106D: case 0xAA7B: | 243 case 0x106B: case 0x106C: case 0x106D: case 0xAA7B: |
238 cat = (indic_category_t) OT_PT; | 244 cat = (indic_category_t) OT_PT; |
239 break; | 245 break; |
240 | 246 |
241 case 0x1038: case 0x1087: case 0x1088: case 0x1089: | 247 case 0x1038: case 0x1087: case 0x1088: case 0x1089: |
242 case 0x108A: case 0x108B: case 0x108C: case 0x108D: | 248 case 0x108A: case 0x108B: case 0x108C: case 0x108D: |
243 case 0x108F: case 0x109A: case 0x109B: case 0x109C: | 249 case 0x108F: case 0x109A: case 0x109B: case 0x109C: |
244 cat = (indic_category_t) OT_SM; | 250 cat = (indic_category_t) OT_SM; |
245 break; | 251 break; |
| 252 |
| 253 case 0x104A: case 0x104B: |
| 254 cat = (indic_category_t) OT_P; |
| 255 break; |
246 } | 256 } |
247 | 257 |
248 if (cat == OT_M) | 258 if (cat == OT_M) |
249 { | 259 { |
250 switch ((int) pos) | 260 switch ((int) pos) |
251 { | 261 { |
252 case POS_PRE_C: cat = (indic_category_t) OT_VPre; | 262 case POS_PRE_C: cat = (indic_category_t) OT_VPre; |
253 pos = POS_PRE_M; break; | 263 pos = POS_PRE_M; break; |
254 case POS_ABOVE_C: cat = (indic_category_t) OT_VAbv; break; | 264 case POS_ABOVE_C: cat = (indic_category_t) OT_VAbv; break; |
255 case POS_BELOW_C: cat = (indic_category_t) OT_VBlw; break; | 265 case POS_BELOW_C: cat = (indic_category_t) OT_VBlw; break; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 initial_reordering_broken_cluster (const hb_ot_shape_plan_t *plan, | 409 initial_reordering_broken_cluster (const hb_ot_shape_plan_t *plan, |
400 hb_face_t *face, | 410 hb_face_t *face, |
401 hb_buffer_t *buffer, | 411 hb_buffer_t *buffer, |
402 unsigned int start, unsigned int end) | 412 unsigned int start, unsigned int end) |
403 { | 413 { |
404 /* We already inserted dotted-circles, so just call the consonant_syllable. */ | 414 /* We already inserted dotted-circles, so just call the consonant_syllable. */ |
405 initial_reordering_consonant_syllable (plan, face, buffer, start, end); | 415 initial_reordering_consonant_syllable (plan, face, buffer, start, end); |
406 } | 416 } |
407 | 417 |
408 static void | 418 static void |
| 419 initial_reordering_punctuation_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED
, |
| 420 hb_face_t *face HB_UNUSED, |
| 421 hb_buffer_t *buffer HB_UNUSED, |
| 422 unsigned int start HB_UNUSED, unsigned i
nt end HB_UNUSED) |
| 423 { |
| 424 /* Nothing to do right now. If we ever switch to using the output |
| 425 * buffer in the reordering process, we'd need to next_glyph() here. */ |
| 426 } |
| 427 |
| 428 static void |
409 initial_reordering_non_myanmar_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED
, | 429 initial_reordering_non_myanmar_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED
, |
410 hb_face_t *face HB_UNUSED, | 430 hb_face_t *face HB_UNUSED, |
411 hb_buffer_t *buffer HB_UNUSED, | 431 hb_buffer_t *buffer HB_UNUSED, |
412 unsigned int start HB_UNUSED, unsigned i
nt end HB_UNUSED) | 432 unsigned int start HB_UNUSED, unsigned i
nt end HB_UNUSED) |
413 { | 433 { |
414 /* Nothing to do right now. If we ever switch to using the output | 434 /* Nothing to do right now. If we ever switch to using the output |
415 * buffer in the reordering process, we'd need to next_glyph() here. */ | 435 * buffer in the reordering process, we'd need to next_glyph() here. */ |
416 } | 436 } |
417 | 437 |
418 | 438 |
419 static void | 439 static void |
420 initial_reordering_syllable (const hb_ot_shape_plan_t *plan, | 440 initial_reordering_syllable (const hb_ot_shape_plan_t *plan, |
421 hb_face_t *face, | 441 hb_face_t *face, |
422 hb_buffer_t *buffer, | 442 hb_buffer_t *buffer, |
423 unsigned int start, unsigned int end) | 443 unsigned int start, unsigned int end) |
424 { | 444 { |
425 syllable_type_t syllable_type = (syllable_type_t) (buffer->info[start].syllabl
e() & 0x0F); | 445 syllable_type_t syllable_type = (syllable_type_t) (buffer->info[start].syllabl
e() & 0x0F); |
426 switch (syllable_type) { | 446 switch (syllable_type) { |
427 case consonant_syllable: initial_reordering_consonant_syllable (plan, fa
ce, buffer, start, end); return; | 447 case consonant_syllable: initial_reordering_consonant_syllable (plan, fa
ce, buffer, start, end); return; |
| 448 case punctuation_cluster: initial_reordering_punctuation_cluster (plan, fa
ce, buffer, start, end); return; |
428 case broken_cluster: initial_reordering_broken_cluster (plan, fa
ce, buffer, start, end); return; | 449 case broken_cluster: initial_reordering_broken_cluster (plan, fa
ce, buffer, start, end); return; |
429 case non_myanmar_cluster: initial_reordering_non_myanmar_cluster (plan, fa
ce, buffer, start, end); return; | 450 case non_myanmar_cluster: initial_reordering_non_myanmar_cluster (plan, fa
ce, buffer, start, end); return; |
430 } | 451 } |
431 } | 452 } |
432 | 453 |
433 static inline void | 454 static inline void |
434 insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, | 455 insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, |
435 hb_font_t *font, | 456 hb_font_t *font, |
436 hb_buffer_t *buffer) | 457 hb_buffer_t *buffer) |
437 { | 458 { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 534 |
514 /* Zero syllables now... */ | 535 /* Zero syllables now... */ |
515 for (unsigned int i = 0; i < count; i++) | 536 for (unsigned int i = 0; i < count; i++) |
516 info[i].syllable() = 0; | 537 info[i].syllable() = 0; |
517 | 538 |
518 HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category); | 539 HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category); |
519 HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_position); | 540 HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_position); |
520 } | 541 } |
521 | 542 |
522 | 543 |
523 static hb_ot_shape_normalization_mode_t | |
524 normalization_preference_myanmar (const hb_segment_properties_t *props HB_UNUSED
) | |
525 { | |
526 return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT; | |
527 } | |
528 | |
529 | |
530 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar = | 544 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar = |
531 { | 545 { |
532 "myanmar", | 546 "myanmar", |
533 collect_features_myanmar, | 547 collect_features_myanmar, |
534 override_features_myanmar, | 548 override_features_myanmar, |
535 NULL, /* data_create */ | 549 NULL, /* data_create */ |
536 NULL, /* data_destroy */ | 550 NULL, /* data_destroy */ |
537 NULL, /* preprocess_text */ | 551 NULL, /* preprocess_text */ |
538 normalization_preference_myanmar, | 552 HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, |
539 NULL, /* decompose */ | 553 NULL, /* decompose */ |
540 NULL, /* compose */ | 554 NULL, /* compose */ |
541 setup_masks_myanmar, | 555 setup_masks_myanmar, |
542 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, | 556 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, |
543 false, /* fallback_position */ | 557 false, /* fallback_position */ |
544 }; | 558 }; |
OLD | NEW |