| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 #include "hb-ot-shape-complex-myanmar-machine.hh" | 127 #include "hb-ot-shape-complex-myanmar-machine.hh" |
| 128 | 128 |
| 129 | 129 |
| 130 /* Note: This enum is duplicated in the -machine.rl source file. | 130 /* Note: This enum is duplicated in the -machine.rl source file. |
| 131 * Not sure how to avoid duplication. */ | 131 * Not sure how to avoid duplication. */ |
| 132 enum myanmar_category_t { | 132 enum myanmar_category_t { |
| 133 OT_As = 18, /* Asat */ | 133 OT_As = 18, /* Asat */ |
| 134 OT_D = 19, /* Digits except zero */ | 134 OT_D = 19, /* Digits except zero */ |
| 135 OT_D0 = 20, /* Digit zero */ | 135 OT_D0 = 20, /* Digit zero */ |
| 136 OT_DB = OT_N, /* Dot below */ | 136 OT_DB = OT_N, /* Dot below */ |
| 137 OT_GB = OT_DOTTEDCIRCLE, | 137 OT_GB = OT_PLACEHOLDER, |
| 138 OT_MH = 21, /* Various consonant medial types */ | 138 OT_MH = 21, /* Various consonant medial types */ |
| 139 OT_MR = 22, /* Various consonant medial types */ | 139 OT_MR = 22, /* Various consonant medial types */ |
| 140 OT_MW = 23, /* Various consonant medial types */ | 140 OT_MW = 23, /* Various consonant medial types */ |
| 141 OT_MY = 24, /* Various consonant medial types */ | 141 OT_MY = 24, /* Various consonant medial types */ |
| 142 OT_PT = 25, /* Pwo and other tones */ | 142 OT_PT = 25, /* Pwo and other tones */ |
| 143 OT_VAbv = 26, | 143 OT_VAbv = 26, |
| 144 OT_VBlw = 27, | 144 OT_VBlw = 27, |
| 145 OT_VPre = 28, | 145 OT_VPre = 28, |
| 146 OT_VPst = 29, | 146 OT_VPst = 29, |
| 147 OT_VS = 30, /* Variation selectors */ | 147 OT_VS = 30, /* Variation selectors */ |
| 148 OT_P = 31 /* Punctuation */ | 148 OT_P = 31 /* Punctuation */ |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 | 151 |
| 152 static inline bool | 152 static inline bool |
| 153 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) |
| 154 { | 154 { |
| 155 /* If it ligated, all bets are off. */ | 155 /* If it ligated, all bets are off. */ |
| 156 if (_hb_glyph_info_ligated (&info)) return false; | 156 if (_hb_glyph_info_ligated (&info)) return false; |
| 157 return !!(FLAG (info.myanmar_category()) & flags); | 157 return !!(FLAG (info.myanmar_category()) & flags); |
| 158 } | 158 } |
| 159 | 159 |
| 160 /* Note: | |
| 161 * | |
| 162 * We treat Vowels and placeholders as if they were consonants. This is safe be
cause Vowels | |
| 163 * cannot happen in a consonant syllable. The plus side however is, we can call
the | |
| 164 * consonant syllable logic from the vowel syllable function and get it all righ
t! */ | |
| 165 #define CONSONANT_FLAGS (FLAG (OT_C) | FLAG (OT_CM) | FLAG (OT_Ra) | FLAG (OT_V)
| FLAG (OT_NBSP) | FLAG (OT_GB)) | |
| 166 static inline bool | 160 static inline bool |
| 167 is_consonant (const hb_glyph_info_t &info) | 161 is_consonant (const hb_glyph_info_t &info) |
| 168 { | 162 { |
| 169 return is_one_of (info, CONSONANT_FLAGS); | 163 return is_one_of (info, CONSONANT_FLAGS); |
| 170 } | 164 } |
| 171 | 165 |
| 172 | 166 |
| 173 static inline void | 167 static inline void |
| 174 set_myanmar_properties (hb_glyph_info_t &info) | 168 set_myanmar_properties (hb_glyph_info_t &info) |
| 175 { | 169 { |
| 176 hb_codepoint_t u = info.codepoint; | 170 hb_codepoint_t u = info.codepoint; |
| 177 unsigned int type = hb_indic_get_categories (u); | 171 unsigned int type = hb_indic_get_categories (u); |
| 178 indic_category_t cat = (indic_category_t) (type & 0x7F); | 172 indic_category_t cat = (indic_category_t) (type & 0x7Fu); |
| 179 indic_position_t pos = (indic_position_t) (type >> 8); | 173 indic_position_t pos = (indic_position_t) (type >> 8); |
| 180 | 174 |
| 181 /* Myanmar | 175 /* Myanmar |
| 182 * http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm#analyze | 176 * http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm#analyze |
| 183 */ | 177 */ |
| 184 if (unlikely (hb_in_range<hb_codepoint_t> (u, 0xFE00, 0xFE0F))) | 178 if (unlikely (hb_in_range (u, 0xFE00u, 0xFE0Fu))) |
| 185 cat = (indic_category_t) OT_VS; | 179 cat = (indic_category_t) OT_VS; |
| 186 else if (unlikely (u == 0x200C)) cat = (indic_category_t) OT_ZWNJ; | |
| 187 else if (unlikely (u == 0x200D)) cat = (indic_category_t) OT_ZWJ; | |
| 188 | 180 |
| 189 switch (u) | 181 switch (u) |
| 190 { | 182 { |
| 191 case 0x104E: | 183 case 0x104Eu: |
| 192 cat = (indic_category_t) OT_C; /* The spec says C, IndicSyllableCategory d
oesn't have. */ | 184 cat = (indic_category_t) OT_C; /* The spec says C, IndicSyllableCategory d
oesn't have. */ |
| 193 break; | 185 break; |
| 194 | 186 |
| 195 case 0x002D: case 0x00A0: case 0x00D7: case 0x2012: | 187 case 0x002Du: case 0x00A0u: case 0x00D7u: case 0x2012u: |
| 196 case 0x2013: case 0x2014: case 0x2015: case 0x2022: | 188 case 0x2013u: case 0x2014u: case 0x2015u: case 0x2022u: |
| 197 case 0x25CC: case 0x25FB: case 0x25FC: case 0x25FD: | 189 case 0x25CCu: case 0x25FBu: case 0x25FCu: case 0x25FDu: |
| 198 case 0x25FE: | 190 case 0x25FEu: |
| 199 cat = (indic_category_t) OT_GB; | 191 cat = (indic_category_t) OT_GB; |
| 200 break; | 192 break; |
| 201 | 193 |
| 202 case 0x1004: case 0x101B: case 0x105A: | 194 case 0x1004u: case 0x101Bu: case 0x105Au: |
| 203 cat = (indic_category_t) OT_Ra; | 195 cat = (indic_category_t) OT_Ra; |
| 204 break; | 196 break; |
| 205 | 197 |
| 206 case 0x1032: case 0x1036: | 198 case 0x1032u: case 0x1036u: |
| 207 cat = (indic_category_t) OT_A; | 199 cat = (indic_category_t) OT_A; |
| 208 break; | 200 break; |
| 209 | 201 |
| 210 case 0x103A: | 202 case 0x103Au: |
| 211 cat = (indic_category_t) OT_As; | 203 cat = (indic_category_t) OT_As; |
| 212 break; | 204 break; |
| 213 | 205 |
| 214 case 0x1041: case 0x1042: case 0x1043: case 0x1044: | 206 case 0x1041u: case 0x1042u: case 0x1043u: case 0x1044u: |
| 215 case 0x1045: case 0x1046: case 0x1047: case 0x1048: | 207 case 0x1045u: case 0x1046u: case 0x1047u: case 0x1048u: |
| 216 case 0x1049: case 0x1090: case 0x1091: case 0x1092: | 208 case 0x1049u: case 0x1090u: case 0x1091u: case 0x1092u: |
| 217 case 0x1093: case 0x1094: case 0x1095: case 0x1096: | 209 case 0x1093u: case 0x1094u: case 0x1095u: case 0x1096u: |
| 218 case 0x1097: case 0x1098: case 0x1099: | 210 case 0x1097u: case 0x1098u: case 0x1099u: |
| 219 cat = (indic_category_t) OT_D; | 211 cat = (indic_category_t) OT_D; |
| 220 break; | 212 break; |
| 221 | 213 |
| 222 case 0x1040: | 214 case 0x1040u: |
| 223 cat = (indic_category_t) OT_D; /* XXX The spec says D0, but Uniscribe does
n't seem to do. */ | 215 cat = (indic_category_t) OT_D; /* XXX The spec says D0, but Uniscribe does
n't seem to do. */ |
| 224 break; | 216 break; |
| 225 | 217 |
| 226 case 0x103E: case 0x1060: | 218 case 0x103Eu: case 0x1060u: |
| 227 cat = (indic_category_t) OT_MH; | 219 cat = (indic_category_t) OT_MH; |
| 228 break; | 220 break; |
| 229 | 221 |
| 230 case 0x103C: | 222 case 0x103Cu: |
| 231 cat = (indic_category_t) OT_MR; | 223 cat = (indic_category_t) OT_MR; |
| 232 break; | 224 break; |
| 233 | 225 |
| 234 case 0x103D: case 0x1082: | 226 case 0x103Du: case 0x1082u: |
| 235 cat = (indic_category_t) OT_MW; | 227 cat = (indic_category_t) OT_MW; |
| 236 break; | 228 break; |
| 237 | 229 |
| 238 case 0x103B: case 0x105E: case 0x105F: | 230 case 0x103Bu: case 0x105Eu: case 0x105Fu: |
| 239 cat = (indic_category_t) OT_MY; | 231 cat = (indic_category_t) OT_MY; |
| 240 break; | 232 break; |
| 241 | 233 |
| 242 case 0x1063: case 0x1064: case 0x1069: case 0x106A: | 234 case 0x1063u: case 0x1064u: case 0x1069u: case 0x106Au: |
| 243 case 0x106B: case 0x106C: case 0x106D: case 0xAA7B: | 235 case 0x106Bu: case 0x106Cu: case 0x106Du: case 0xAA7Bu: |
| 244 cat = (indic_category_t) OT_PT; | 236 cat = (indic_category_t) OT_PT; |
| 245 break; | 237 break; |
| 246 | 238 |
| 247 case 0x1038: case 0x1087: case 0x1088: case 0x1089: | 239 case 0x1038u: case 0x1087u: case 0x1088u: case 0x1089u: |
| 248 case 0x108A: case 0x108B: case 0x108C: case 0x108D: | 240 case 0x108Au: case 0x108Bu: case 0x108Cu: case 0x108Du: |
| 249 case 0x108F: case 0x109A: case 0x109B: case 0x109C: | 241 case 0x108Fu: case 0x109Au: case 0x109Bu: case 0x109Cu: |
| 250 cat = (indic_category_t) OT_SM; | 242 cat = (indic_category_t) OT_SM; |
| 251 break; | 243 break; |
| 252 | 244 |
| 253 case 0x104A: case 0x104B: | 245 case 0x104Au: case 0x104Bu: |
| 254 cat = (indic_category_t) OT_P; | 246 cat = (indic_category_t) OT_P; |
| 255 break; | 247 break; |
| 256 } | 248 } |
| 257 | 249 |
| 258 if (cat == OT_M) | 250 if (cat == OT_M) |
| 259 { | 251 { |
| 260 switch ((int) pos) | 252 switch ((int) pos) |
| 261 { | 253 { |
| 262 case POS_PRE_C: cat = (indic_category_t) OT_VPre; | 254 case POS_PRE_C: cat = (indic_category_t) OT_VPre; |
| 263 pos = POS_PRE_M; break; | 255 pos = POS_PRE_M; break; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 278 hb_buffer_t *buffer, | 270 hb_buffer_t *buffer, |
| 279 hb_font_t *font HB_UNUSED) | 271 hb_font_t *font HB_UNUSED) |
| 280 { | 272 { |
| 281 HB_BUFFER_ALLOCATE_VAR (buffer, myanmar_category); | 273 HB_BUFFER_ALLOCATE_VAR (buffer, myanmar_category); |
| 282 HB_BUFFER_ALLOCATE_VAR (buffer, myanmar_position); | 274 HB_BUFFER_ALLOCATE_VAR (buffer, myanmar_position); |
| 283 | 275 |
| 284 /* We cannot setup masks here. We save information about characters | 276 /* We cannot setup masks here. We save information about characters |
| 285 * and setup masks later on in a pause-callback. */ | 277 * and setup masks later on in a pause-callback. */ |
| 286 | 278 |
| 287 unsigned int count = buffer->len; | 279 unsigned int count = buffer->len; |
| 280 hb_glyph_info_t *info = buffer->info; |
| 288 for (unsigned int i = 0; i < count; i++) | 281 for (unsigned int i = 0; i < count; i++) |
| 289 set_myanmar_properties (buffer->info[i]); | 282 set_myanmar_properties (info[i]); |
| 290 } | 283 } |
| 291 | 284 |
| 292 static void | 285 static void |
| 293 setup_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED, | 286 setup_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED, |
| 294 hb_font_t *font HB_UNUSED, | 287 hb_font_t *font HB_UNUSED, |
| 295 hb_buffer_t *buffer) | 288 hb_buffer_t *buffer) |
| 296 { | 289 { |
| 297 find_syllables (buffer); | 290 find_syllables (buffer); |
| 298 } | 291 } |
| 299 | 292 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 } | 445 } |
| 453 | 446 |
| 454 static inline void | 447 static inline void |
| 455 insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, | 448 insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, |
| 456 hb_font_t *font, | 449 hb_font_t *font, |
| 457 hb_buffer_t *buffer) | 450 hb_buffer_t *buffer) |
| 458 { | 451 { |
| 459 /* Note: This loop is extra overhead, but should not be measurable. */ | 452 /* Note: This loop is extra overhead, but should not be measurable. */ |
| 460 bool has_broken_syllables = false; | 453 bool has_broken_syllables = false; |
| 461 unsigned int count = buffer->len; | 454 unsigned int count = buffer->len; |
| 455 hb_glyph_info_t *info = buffer->info; |
| 462 for (unsigned int i = 0; i < count; i++) | 456 for (unsigned int i = 0; i < count; i++) |
| 463 if ((buffer->info[i].syllable() & 0x0F) == broken_cluster) { | 457 if ((info[i].syllable() & 0x0F) == broken_cluster) |
| 458 { |
| 464 has_broken_syllables = true; | 459 has_broken_syllables = true; |
| 465 break; | 460 break; |
| 466 } | 461 } |
| 467 if (likely (!has_broken_syllables)) | 462 if (likely (!has_broken_syllables)) |
| 468 return; | 463 return; |
| 469 | 464 |
| 470 | 465 |
| 471 hb_codepoint_t dottedcircle_glyph; | 466 hb_codepoint_t dottedcircle_glyph; |
| 472 if (!font->get_glyph (0x25CC, 0, &dottedcircle_glyph)) | 467 if (!font->get_glyph (0x25CCu, 0, &dottedcircle_glyph)) |
| 473 return; | 468 return; |
| 474 | 469 |
| 475 hb_glyph_info_t dottedcircle = {0}; | 470 hb_glyph_info_t dottedcircle = {0}; |
| 476 dottedcircle.codepoint = 0x25CC; | 471 dottedcircle.codepoint = 0x25CCu; |
| 477 set_myanmar_properties (dottedcircle); | 472 set_myanmar_properties (dottedcircle); |
| 478 dottedcircle.codepoint = dottedcircle_glyph; | 473 dottedcircle.codepoint = dottedcircle_glyph; |
| 479 | 474 |
| 480 buffer->clear_output (); | 475 buffer->clear_output (); |
| 481 | 476 |
| 482 buffer->idx = 0; | 477 buffer->idx = 0; |
| 483 unsigned int last_syllable = 0; | 478 unsigned int last_syllable = 0; |
| 484 while (buffer->idx < buffer->len) | 479 while (buffer->idx < buffer->len) |
| 485 { | 480 { |
| 486 unsigned int syllable = buffer->cur().syllable(); | 481 unsigned int syllable = buffer->cur().syllable(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 NULL, /* data_create */ | 544 NULL, /* data_create */ |
| 550 NULL, /* data_destroy */ | 545 NULL, /* data_destroy */ |
| 551 NULL, /* preprocess_text */ | 546 NULL, /* preprocess_text */ |
| 552 HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, | 547 HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, |
| 553 NULL, /* decompose */ | 548 NULL, /* decompose */ |
| 554 NULL, /* compose */ | 549 NULL, /* compose */ |
| 555 setup_masks_myanmar, | 550 setup_masks_myanmar, |
| 556 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, | 551 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, |
| 557 false, /* fallback_position */ | 552 false, /* fallback_position */ |
| 558 }; | 553 }; |
| OLD | NEW |