1 2 #line 1 "hb-ot-shape-complex-use-machine.rl" 3 /* 4 * Copyright 2015 Mozilla Foundation. 5 * Copyright 2015 Google, Inc. 6 * 7 * This is part of HarfBuzz, a text shaping library. 8 * 9 * Permission is hereby granted, without written agreement and without 10 * license or royalty fees, to use, copy, modify, and distribute this 11 * software and its documentation for any purpose, provided that the 12 * above copyright notice and the following two paragraphs appear in 13 * all copies of this software. 14 * 15 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 16 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 17 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 18 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 19 * DAMAGE. 20 * 21 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 22 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 23 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 24 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 25 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 26 * 27 * Mozilla Author(s): Jonathan Kew 28 * Google Author(s): Behdad Esfahbod 29 */ 30 31 #ifndef HB_OT_SHAPE_COMPLEX_USE_MACHINE_HH 32 #define HB_OT_SHAPE_COMPLEX_USE_MACHINE_HH 33 34 #include "hb-private.hh" 35 36 37 #line 38 "hb-ot-shape-complex-use-machine.hh" 38 static const unsigned char _use_syllable_machine_trans_keys[] = { 39 1u, 1u, 0u, 39u, 21u, 21u, 8u, 39u, 8u, 39u, 1u, 1u, 8u, 39u, 8u, 39u, 40 8u, 39u, 8u, 26u, 8u, 26u, 8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 41 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 13u, 21u, 42 4u, 4u, 13u, 13u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 26u, 8u, 26u, 43 8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 44 8u, 39u, 8u, 39u, 8u, 39u, 1u, 1u, 1u, 39u, 8u, 39u, 21u, 42u, 41u, 42u, 45 42u, 42u, 0 46 }; 47 48 static const char _use_syllable_machine_key_spans[] = { 49 1, 40, 1, 32, 32, 1, 32, 32, 50 32, 19, 19, 19, 32, 32, 32, 32, 51 32, 32, 32, 32, 32, 32, 32, 9, 52 1, 1, 32, 32, 32, 32, 19, 19, 53 19, 32, 32, 32, 32, 32, 32, 32, 54 32, 32, 32, 1, 39, 32, 22, 2, 55 1 56 }; 57 58 static const short _use_syllable_machine_index_offsets[] = { 59 0, 2, 43, 45, 78, 111, 113, 146, 60 179, 212, 232, 252, 272, 305, 338, 371, 61 404, 437, 470, 503, 536, 569, 602, 635, 62 645, 647, 649, 682, 715, 748, 781, 801, 63 821, 841, 874, 907, 940, 973, 1006, 1039, 64 1072, 1105, 1138, 1171, 1173, 1213, 1246, 1269, 65 1272 66 }; 67 68 static const char _use_syllable_machine_indicies[] = { 69 1, 0, 2, 3, 4, 2, 5, 3, 70 4, 4, 6, 4, 4, 1, 7, 4, 71 4, 4, 2, 2, 8, 9, 4, 4, 72 10, 11, 12, 13, 14, 15, 16, 10, 73 17, 18, 19, 20, 21, 22, 4, 23, 74 24, 25, 4, 27, 26, 29, 28, 28, 75 30, 31, 28, 28, 28, 28, 28, 28, 76 28, 28, 32, 33, 34, 35, 36, 37, 77 38, 39, 33, 40, 32, 41, 42, 43, 78 44, 28, 45, 46, 47, 28, 29, 28, 79 28, 30, 31, 28, 28, 28, 28, 28, 80 28, 28, 28, 48, 33, 34, 35, 36, 81 37, 38, 39, 33, 40, 41, 41, 42, 82 43, 44, 28, 45, 46, 47, 28, 30, 83 49, 29, 28, 28, 30, 31, 28, 28, 84 28, 28, 28, 28, 28, 28, 28, 33, 85 34, 35, 36, 37, 38, 39, 33, 40, 86 41, 41, 42, 43, 44, 28, 45, 46, 87 47, 28, 29, 28, 28, 28, 28, 28, 88 28, 28, 28, 28, 28, 28, 28, 28, 89 33, 34, 35, 36, 37, 28, 28, 28, 90 28, 28, 28, 42, 43, 44, 28, 45, 91 46, 47, 28, 29, 28, 28, 28, 28, 92 28, 28, 28, 28, 28, 28, 28, 28, 93 28, 28, 34, 35, 36, 37, 28, 28, 94 28, 28, 28, 28, 28, 28, 28, 28, 95 45, 46, 47, 28, 29, 28, 28, 28, 96 28, 28, 28, 28, 28, 28, 28, 28, 97 28, 28, 28, 28, 35, 36, 37, 28, 98 29, 28, 28, 28, 28, 28, 28, 28, 99 28, 28, 28, 28, 28, 28, 28, 28, 100 28, 36, 37, 28, 29, 28, 28, 28, 101 28, 28, 28, 28, 28, 28, 28, 28, 102 28, 28, 28, 28, 28, 28, 37, 28, 103 29, 28, 28, 28, 28, 28, 28, 28, 104 28, 28, 28, 28, 28, 28, 28, 28, 105 35, 36, 37, 28, 28, 28, 28, 28, 106 28, 28, 28, 28, 28, 45, 46, 47, 107 28, 29, 28, 28, 28, 28, 28, 28, 108 28, 28, 28, 28, 28, 28, 28, 28, 109 28, 35, 36, 37, 28, 28, 28, 28, 110 28, 28, 28, 28, 28, 28, 28, 46, 111 47, 28, 29, 28, 28, 28, 28, 28, 112 28, 28, 28, 28, 28, 28, 28, 28, 113 28, 28, 35, 36, 37, 28, 28, 28, 114 28, 28, 28, 28, 28, 28, 28, 28, 115 28, 47, 28, 29, 28, 28, 28, 28, 116 28, 28, 28, 28, 28, 28, 28, 28, 117 28, 28, 34, 35, 36, 37, 28, 28, 118 28, 28, 28, 28, 42, 43, 44, 28, 119 45, 46, 47, 28, 29, 28, 28, 28, 120 28, 28, 28, 28, 28, 28, 28, 28, 121 28, 28, 28, 34, 35, 36, 37, 28, 122 28, 28, 28, 28, 28, 28, 43, 44, 123 28, 45, 46, 47, 28, 29, 28, 28, 124 28, 28, 28, 28, 28, 28, 28, 28, 125 28, 28, 28, 28, 34, 35, 36, 37, 126 28, 28, 28, 28, 28, 28, 28, 28, 127 44, 28, 45, 46, 47, 28, 29, 28, 128 28, 28, 28, 28, 28, 28, 28, 28, 129 28, 28, 28, 28, 33, 34, 35, 36, 130 37, 28, 39, 33, 28, 28, 28, 42, 131 43, 44, 28, 45, 46, 47, 28, 29, 132 28, 28, 28, 28, 28, 28, 28, 28, 133 28, 28, 28, 28, 28, 33, 34, 35, 134 36, 37, 28, 28, 33, 28, 28, 28, 135 42, 43, 44, 28, 45, 46, 47, 28, 136 29, 28, 28, 28, 28, 28, 28, 28, 137 28, 28, 28, 28, 28, 28, 33, 34, 138 35, 36, 37, 38, 39, 33, 28, 28, 139 28, 42, 43, 44, 28, 45, 46, 47, 140 28, 29, 28, 28, 30, 31, 28, 28, 141 28, 28, 28, 28, 28, 28, 28, 33, 142 34, 35, 36, 37, 38, 39, 33, 40, 143 28, 41, 42, 43, 44, 28, 45, 46, 144 47, 28, 29, 28, 28, 30, 31, 28, 145 28, 28, 28, 28, 28, 28, 28, 28, 146 33, 34, 35, 36, 37, 38, 39, 33, 147 40, 32, 41, 42, 43, 44, 28, 45, 148 46, 47, 28, 51, 50, 50, 50, 50, 149 50, 50, 50, 52, 50, 5, 53, 51, 150 50, 6, 54, 54, 1, 55, 54, 54, 151 54, 54, 54, 54, 54, 54, 56, 10, 152 11, 12, 13, 14, 15, 16, 10, 17, 153 19, 19, 20, 21, 22, 54, 23, 24, 154 25, 54, 6, 54, 54, 1, 55, 54, 155 54, 54, 54, 54, 54, 54, 54, 54, 156 10, 11, 12, 13, 14, 15, 16, 10, 157 17, 19, 19, 20, 21, 22, 54, 23, 158 24, 25, 54, 6, 54, 54, 54, 54, 159 54, 54, 54, 54, 54, 54, 54, 54, 160 54, 10, 11, 12, 13, 14, 54, 54, 161 54, 54, 54, 54, 20, 21, 22, 54, 162 23, 24, 25, 54, 6, 54, 54, 54, 163 54, 54, 54, 54, 54, 54, 54, 54, 164 54, 54, 54, 11, 12, 13, 14, 54, 165 54, 54, 54, 54, 54, 54, 54, 54, 166 54, 23, 24, 25, 54, 6, 54, 54, 167 54, 54, 54, 54, 54, 54, 54, 54, 168 54, 54, 54, 54, 54, 12, 13, 14, 169 54, 6, 54, 54, 54, 54, 54, 54, 170 54, 54, 54, 54, 54, 54, 54, 54, 171 54, 54, 13, 14, 54, 6, 54, 54, 172 54, 54, 54, 54, 54, 54, 54, 54, 173 54, 54, 54, 54, 54, 54, 54, 14, 174 54, 6, 54, 54, 54, 54, 54, 54, 175 54, 54, 54, 54, 54, 54, 54, 54, 176 54, 12, 13, 14, 54, 54, 54, 54, 177 54, 54, 54, 54, 54, 54, 23, 24, 178 25, 54, 6, 54, 54, 54, 54, 54, 179 54, 54, 54, 54, 54, 54, 54, 54, 180 54, 54, 12, 13, 14, 54, 54, 54, 181 54, 54, 54, 54, 54, 54, 54, 54, 182 24, 25, 54, 6, 54, 54, 54, 54, 183 54, 54, 54, 54, 54, 54, 54, 54, 184 54, 54, 54, 12, 13, 14, 54, 54, 185 54, 54, 54, 54, 54, 54, 54, 54, 186 54, 54, 25, 54, 6, 54, 54, 54, 187 54, 54, 54, 54, 54, 54, 54, 54, 188 54, 54, 54, 11, 12, 13, 14, 54, 189 54, 54, 54, 54, 54, 20, 21, 22, 190 54, 23, 24, 25, 54, 6, 54, 54, 191 54, 54, 54, 54, 54, 54, 54, 54, 192 54, 54, 54, 54, 11, 12, 13, 14, 193 54, 54, 54, 54, 54, 54, 54, 21, 194 22, 54, 23, 24, 25, 54, 6, 54, 195 54, 54, 54, 54, 54, 54, 54, 54, 196 54, 54, 54, 54, 54, 11, 12, 13, 197 14, 54, 54, 54, 54, 54, 54, 54, 198 54, 22, 54, 23, 24, 25, 54, 6, 199 54, 54, 54, 54, 54, 54, 54, 54, 200 54, 54, 54, 54, 54, 10, 11, 12, 201 13, 14, 54, 16, 10, 54, 54, 54, 202 20, 21, 22, 54, 23, 24, 25, 54, 203 6, 54, 54, 54, 54, 54, 54, 54, 204 54, 54, 54, 54, 54, 54, 10, 11, 205 12, 13, 14, 54, 54, 10, 54, 54, 206 54, 20, 21, 22, 54, 23, 24, 25, 207 54, 6, 54, 54, 54, 54, 54, 54, 208 54, 54, 54, 54, 54, 54, 54, 10, 209 11, 12, 13, 14, 15, 16, 10, 54, 210 54, 54, 20, 21, 22, 54, 23, 24, 211 25, 54, 6, 54, 54, 1, 55, 54, 212 54, 54, 54, 54, 54, 54, 54, 54, 213 10, 11, 12, 13, 14, 15, 16, 10, 214 17, 54, 19, 20, 21, 22, 54, 23, 215 24, 25, 54, 1, 57, 3, 54, 54, 216 54, 3, 54, 54, 6, 54, 54, 1, 217 55, 54, 54, 54, 54, 54, 54, 54, 218 54, 54, 10, 11, 12, 13, 14, 15, 219 16, 10, 17, 18, 19, 20, 21, 22, 220 54, 23, 24, 25, 54, 6, 54, 54, 221 1, 55, 54, 54, 54, 54, 54, 54, 222 54, 54, 54, 10, 11, 12, 13, 14, 223 15, 16, 10, 17, 18, 19, 20, 21, 224 22, 54, 23, 24, 25, 54, 59, 58, 225 58, 58, 58, 58, 58, 58, 58, 58, 226 58, 58, 58, 58, 58, 58, 58, 58, 227 58, 58, 59, 60, 58, 59, 60, 58, 228 60, 58, 0 229 }; 230 231 static const char _use_syllable_machine_trans_targs[] = { 232 1, 26, 2, 3, 1, 23, 1, 43, 233 44, 46, 28, 29, 30, 31, 32, 39, 234 40, 41, 45, 42, 36, 37, 38, 33, 235 34, 35, 1, 1, 1, 1, 4, 5, 236 22, 7, 8, 9, 10, 11, 18, 19, 237 20, 21, 15, 16, 17, 12, 13, 14, 238 6, 1, 1, 24, 25, 1, 1, 0, 239 27, 1, 1, 47, 48 240 }; 241 242 static const char _use_syllable_machine_trans_actions[] = { 243 1, 2, 0, 0, 5, 0, 6, 0, 244 2, 0, 0, 0, 0, 0, 0, 0, 245 0, 0, 2, 2, 0, 0, 0, 0, 246 0, 0, 7, 8, 9, 10, 0, 0, 247 0, 0, 0, 0, 0, 0, 0, 0, 248 0, 0, 0, 0, 0, 0, 0, 0, 249 0, 11, 12, 0, 0, 13, 14, 0, 250 2, 15, 16, 0, 0 251 }; 252 253 static const char _use_syllable_machine_to_state_actions[] = { 254 0, 3, 0, 0, 0, 0, 0, 0, 255 0, 0, 0, 0, 0, 0, 0, 0, 256 0, 0, 0, 0, 0, 0, 0, 0, 257 0, 0, 0, 0, 0, 0, 0, 0, 258 0, 0, 0, 0, 0, 0, 0, 0, 259 0, 0, 0, 0, 0, 0, 0, 0, 260 0 261 }; 262 263 static const char _use_syllable_machine_from_state_actions[] = { 264 0, 4, 0, 0, 0, 0, 0, 0, 265 0, 0, 0, 0, 0, 0, 0, 0, 266 0, 0, 0, 0, 0, 0, 0, 0, 267 0, 0, 0, 0, 0, 0, 0, 0, 268 0, 0, 0, 0, 0, 0, 0, 0, 269 0, 0, 0, 0, 0, 0, 0, 0, 270 0 271 }; 272 273 static const short _use_syllable_machine_eof_trans[] = { 274 1, 0, 27, 29, 29, 50, 29, 29, 275 29, 29, 29, 29, 29, 29, 29, 29, 276 29, 29, 29, 29, 29, 29, 29, 51, 277 54, 51, 55, 55, 55, 55, 55, 55, 278 55, 55, 55, 55, 55, 55, 55, 55, 279 55, 55, 55, 58, 55, 55, 59, 59, 280 59 281 }; 282 283 static const int use_syllable_machine_start = 1; 284 static const int use_syllable_machine_first_final = 1; 285 static const int use_syllable_machine_error = -1; 286 287 static const int use_syllable_machine_en_main = 1; 288 289 290 #line 38 "hb-ot-shape-complex-use-machine.rl" 291 292 293 294 #line 138 "hb-ot-shape-complex-use-machine.rl" 295 296 297 #define found_syllable(syllable_type) \ 298 HB_STMT_START { \ 299 if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \ 300 for (unsigned int i = last; i < p+1; i++) \ 301 info[i].syllable() = (syllable_serial << 4) | syllable_type; \ 302 last = p+1; \ 303 syllable_serial++; \ 304 if (unlikely (syllable_serial == 16)) syllable_serial = 1; \ 305 } HB_STMT_END 306 307 static void 308 find_syllables (hb_buffer_t *buffer) 309 { 310 unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED; 311 int cs; 312 hb_glyph_info_t *info = buffer->info; 313 314 #line 315 "hb-ot-shape-complex-use-machine.hh" 315 { 316 cs = use_syllable_machine_start; 317 ts = 0; 318 te = 0; 319 act = 0; 320 } 321 322 #line 159 "hb-ot-shape-complex-use-machine.rl" 323 324 325 p = 0; 326 pe = eof = buffer->len; 327 328 unsigned int last = 0; 329 unsigned int syllable_serial = 1; 330 331 #line 332 "hb-ot-shape-complex-use-machine.hh" 332 { 333 int _slen; 334 int _trans; 335 const unsigned char *_keys; 336 const char *_inds; 337 if ( p == pe ) 338 goto _test_eof; 339 _resume: 340 switch ( _use_syllable_machine_from_state_actions[cs] ) { 341 case 4: 342 #line 1 "NONE" 343 {ts = p;} 344 break; 345 #line 346 "hb-ot-shape-complex-use-machine.hh" 346 } 347 348 _keys = _use_syllable_machine_trans_keys + (cs<<1); 349 _inds = _use_syllable_machine_indicies + _use_syllable_machine_index_offsets[cs]; 350 351 _slen = _use_syllable_machine_key_spans[cs]; 352 _trans = _inds[ _slen > 0 && _keys[0] <=( info[p].use_category()) && 353 ( info[p].use_category()) <= _keys[1] ? 354 ( info[p].use_category()) - _keys[0] : _slen ]; 355 356 _eof_trans: 357 cs = _use_syllable_machine_trans_targs[_trans]; 358 359 if ( _use_syllable_machine_trans_actions[_trans] == 0 ) 360 goto _again; 361 362 switch ( _use_syllable_machine_trans_actions[_trans] ) { 363 case 2: 364 #line 1 "NONE" 365 {te = p+1;} 366 break; 367 case 8: 368 #line 127 "hb-ot-shape-complex-use-machine.rl" 369 {te = p+1;{ found_syllable (independent_cluster); }} 370 break; 371 case 10: 372 #line 129 "hb-ot-shape-complex-use-machine.rl" 373 {te = p+1;{ found_syllable (standard_cluster); }} 374 break; 375 case 6: 376 #line 133 "hb-ot-shape-complex-use-machine.rl" 377 {te = p+1;{ found_syllable (broken_cluster); }} 378 break; 379 case 5: 380 #line 134 "hb-ot-shape-complex-use-machine.rl" 381 {te = p+1;{ found_syllable (non_cluster); }} 382 break; 383 case 7: 384 #line 127 "hb-ot-shape-complex-use-machine.rl" 385 {te = p;p--;{ found_syllable (independent_cluster); }} 386 break; 387 case 11: 388 #line 128 "hb-ot-shape-complex-use-machine.rl" 389 {te = p;p--;{ found_syllable (virama_terminated_cluster); }} 390 break; 391 case 9: 392 #line 129 "hb-ot-shape-complex-use-machine.rl" 393 {te = p;p--;{ found_syllable (standard_cluster); }} 394 break; 395 case 13: 396 #line 130 "hb-ot-shape-complex-use-machine.rl" 397 {te = p;p--;{ found_syllable (number_joiner_terminated_cluster); }} 398 break; 399 case 12: 400 #line 131 "hb-ot-shape-complex-use-machine.rl" 401 {te = p;p--;{ found_syllable (numeral_cluster); }} 402 break; 403 case 16: 404 #line 132 "hb-ot-shape-complex-use-machine.rl" 405 {te = p;p--;{ found_syllable (symbol_cluster); }} 406 break; 407 case 14: 408 #line 133 "hb-ot-shape-complex-use-machine.rl" 409 {te = p;p--;{ found_syllable (broken_cluster); }} 410 break; 411 case 15: 412 #line 134 "hb-ot-shape-complex-use-machine.rl" 413 {te = p;p--;{ found_syllable (non_cluster); }} 414 break; 415 case 1: 416 #line 133 "hb-ot-shape-complex-use-machine.rl" 417 {{p = ((te))-1;}{ found_syllable (broken_cluster); }} 418 break; 419 #line 420 "hb-ot-shape-complex-use-machine.hh" 420 } 421 422 _again: 423 switch ( _use_syllable_machine_to_state_actions[cs] ) { 424 case 3: 425 #line 1 "NONE" 426 {ts = 0;} 427 break; 428 #line 429 "hb-ot-shape-complex-use-machine.hh" 429 } 430 431 if ( ++p != pe ) 432 goto _resume; 433 _test_eof: {} 434 if ( p == eof ) 435 { 436 if ( _use_syllable_machine_eof_trans[cs] > 0 ) { 437 _trans = _use_syllable_machine_eof_trans[cs] - 1; 438 goto _eof_trans; 439 } 440 } 441 442 } 443 444 #line 168 "hb-ot-shape-complex-use-machine.rl" 445 446 } 447 448 #undef found_syllable 449 450 #endif /* HB_OT_SHAPE_COMPLEX_USE_MACHINE_HH */ 451