michael@0: /* michael@0: * Copyright © 2011,2012,2013 Google, Inc. michael@0: * michael@0: * This is part of HarfBuzz, a text shaping library. michael@0: * michael@0: * Permission is hereby granted, without written agreement and without michael@0: * license or royalty fees, to use, copy, modify, and distribute this michael@0: * software and its documentation for any purpose, provided that the michael@0: * above copyright notice and the following two paragraphs appear in michael@0: * all copies of this software. michael@0: * michael@0: * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR michael@0: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES michael@0: * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN michael@0: * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH michael@0: * DAMAGE. michael@0: * michael@0: * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, michael@0: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND michael@0: * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS michael@0: * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO michael@0: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. michael@0: * michael@0: * Google Author(s): Behdad Esfahbod michael@0: */ michael@0: michael@0: #ifndef HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH michael@0: #define HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH michael@0: michael@0: #include "hb-private.hh" michael@0: michael@0: %%{ michael@0: machine sea_syllable_machine; michael@0: alphtype unsigned char; michael@0: write data; michael@0: }%% michael@0: michael@0: %%{ michael@0: michael@0: # Same order as enum sea_category_t. Not sure how to avoid duplication. michael@0: C = 1; michael@0: GB = 12; # Generic Base michael@0: H = 4; # Halant michael@0: IV = 2; # Independent Vowel michael@0: MR = 22; # Medial Ra michael@0: CM = 17; # Consonant Medial michael@0: VAbv = 26; michael@0: VBlw = 27; michael@0: VPre = 28; michael@0: VPst = 29; michael@0: T = 3; # Tone Marks michael@0: A = 10; # Anusvara michael@0: michael@0: syllable_tail = (VPre|VAbv|VBlw|VPst|H.C|CM|MR|T|A)*; michael@0: michael@0: consonant_syllable = (C|IV|GB) syllable_tail; michael@0: broken_cluster = syllable_tail; michael@0: other = any; michael@0: michael@0: main := |* michael@0: consonant_syllable => { found_syllable (consonant_syllable); }; michael@0: broken_cluster => { found_syllable (broken_cluster); }; michael@0: other => { found_syllable (non_sea_cluster); }; michael@0: *|; michael@0: michael@0: michael@0: }%% michael@0: michael@0: #define found_syllable(syllable_type) \ michael@0: HB_STMT_START { \ michael@0: if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \ michael@0: for (unsigned int i = last; i < p+1; i++) \ michael@0: info[i].syllable() = (syllable_serial << 4) | syllable_type; \ michael@0: last = p+1; \ michael@0: syllable_serial++; \ michael@0: if (unlikely (syllable_serial == 16)) syllable_serial = 1; \ michael@0: } HB_STMT_END michael@0: michael@0: static void michael@0: find_syllables (hb_buffer_t *buffer) michael@0: { michael@0: unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED; michael@0: int cs; michael@0: hb_glyph_info_t *info = buffer->info; michael@0: %%{ michael@0: write init; michael@0: getkey info[p].sea_category(); michael@0: }%% michael@0: michael@0: p = 0; michael@0: pe = eof = buffer->len; michael@0: michael@0: unsigned int last = 0; michael@0: unsigned int syllable_serial = 1; michael@0: %%{ michael@0: write exec; michael@0: }%% michael@0: } michael@0: michael@0: #undef found_syllable michael@0: michael@0: #endif /* HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH */