1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/harfbuzz/src/hb-ot-shape-complex-sea-machine.rl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,102 @@ 1.4 +/* 1.5 + * Copyright © 2011,2012,2013 Google, Inc. 1.6 + * 1.7 + * This is part of HarfBuzz, a text shaping library. 1.8 + * 1.9 + * Permission is hereby granted, without written agreement and without 1.10 + * license or royalty fees, to use, copy, modify, and distribute this 1.11 + * software and its documentation for any purpose, provided that the 1.12 + * above copyright notice and the following two paragraphs appear in 1.13 + * all copies of this software. 1.14 + * 1.15 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 1.16 + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 1.17 + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 1.18 + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1.19 + * DAMAGE. 1.20 + * 1.21 + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 1.22 + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 1.23 + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 1.24 + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 1.25 + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 1.26 + * 1.27 + * Google Author(s): Behdad Esfahbod 1.28 + */ 1.29 + 1.30 +#ifndef HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH 1.31 +#define HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH 1.32 + 1.33 +#include "hb-private.hh" 1.34 + 1.35 +%%{ 1.36 + machine sea_syllable_machine; 1.37 + alphtype unsigned char; 1.38 + write data; 1.39 +}%% 1.40 + 1.41 +%%{ 1.42 + 1.43 +# Same order as enum sea_category_t. Not sure how to avoid duplication. 1.44 +C = 1; 1.45 +GB = 12; # Generic Base 1.46 +H = 4; # Halant 1.47 +IV = 2; # Independent Vowel 1.48 +MR = 22; # Medial Ra 1.49 +CM = 17; # Consonant Medial 1.50 +VAbv = 26; 1.51 +VBlw = 27; 1.52 +VPre = 28; 1.53 +VPst = 29; 1.54 +T = 3; # Tone Marks 1.55 +A = 10; # Anusvara 1.56 + 1.57 +syllable_tail = (VPre|VAbv|VBlw|VPst|H.C|CM|MR|T|A)*; 1.58 + 1.59 +consonant_syllable = (C|IV|GB) syllable_tail; 1.60 +broken_cluster = syllable_tail; 1.61 +other = any; 1.62 + 1.63 +main := |* 1.64 + consonant_syllable => { found_syllable (consonant_syllable); }; 1.65 + broken_cluster => { found_syllable (broken_cluster); }; 1.66 + other => { found_syllable (non_sea_cluster); }; 1.67 +*|; 1.68 + 1.69 + 1.70 +}%% 1.71 + 1.72 +#define found_syllable(syllable_type) \ 1.73 + HB_STMT_START { \ 1.74 + if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \ 1.75 + for (unsigned int i = last; i < p+1; i++) \ 1.76 + info[i].syllable() = (syllable_serial << 4) | syllable_type; \ 1.77 + last = p+1; \ 1.78 + syllable_serial++; \ 1.79 + if (unlikely (syllable_serial == 16)) syllable_serial = 1; \ 1.80 + } HB_STMT_END 1.81 + 1.82 +static void 1.83 +find_syllables (hb_buffer_t *buffer) 1.84 +{ 1.85 + unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED; 1.86 + int cs; 1.87 + hb_glyph_info_t *info = buffer->info; 1.88 + %%{ 1.89 + write init; 1.90 + getkey info[p].sea_category(); 1.91 + }%% 1.92 + 1.93 + p = 0; 1.94 + pe = eof = buffer->len; 1.95 + 1.96 + unsigned int last = 0; 1.97 + unsigned int syllable_serial = 1; 1.98 + %%{ 1.99 + write exec; 1.100 + }%% 1.101 +} 1.102 + 1.103 +#undef found_syllable 1.104 + 1.105 +#endif /* HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH */