Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright © 2011,2012,2013 Google, Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * This is part of HarfBuzz, a text shaping library. |
michael@0 | 5 | * |
michael@0 | 6 | * Permission is hereby granted, without written agreement and without |
michael@0 | 7 | * license or royalty fees, to use, copy, modify, and distribute this |
michael@0 | 8 | * software and its documentation for any purpose, provided that the |
michael@0 | 9 | * above copyright notice and the following two paragraphs appear in |
michael@0 | 10 | * all copies of this software. |
michael@0 | 11 | * |
michael@0 | 12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
michael@0 | 13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
michael@0 | 14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
michael@0 | 15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
michael@0 | 16 | * DAMAGE. |
michael@0 | 17 | * |
michael@0 | 18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
michael@0 | 19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
michael@0 | 20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
michael@0 | 21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
michael@0 | 22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
michael@0 | 23 | * |
michael@0 | 24 | * Google Author(s): Behdad Esfahbod |
michael@0 | 25 | */ |
michael@0 | 26 | |
michael@0 | 27 | #ifndef HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH |
michael@0 | 28 | #define HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH |
michael@0 | 29 | |
michael@0 | 30 | #include "hb-private.hh" |
michael@0 | 31 | |
michael@0 | 32 | %%{ |
michael@0 | 33 | machine sea_syllable_machine; |
michael@0 | 34 | alphtype unsigned char; |
michael@0 | 35 | write data; |
michael@0 | 36 | }%% |
michael@0 | 37 | |
michael@0 | 38 | %%{ |
michael@0 | 39 | |
michael@0 | 40 | # Same order as enum sea_category_t. Not sure how to avoid duplication. |
michael@0 | 41 | C = 1; |
michael@0 | 42 | GB = 12; # Generic Base |
michael@0 | 43 | H = 4; # Halant |
michael@0 | 44 | IV = 2; # Independent Vowel |
michael@0 | 45 | MR = 22; # Medial Ra |
michael@0 | 46 | CM = 17; # Consonant Medial |
michael@0 | 47 | VAbv = 26; |
michael@0 | 48 | VBlw = 27; |
michael@0 | 49 | VPre = 28; |
michael@0 | 50 | VPst = 29; |
michael@0 | 51 | T = 3; # Tone Marks |
michael@0 | 52 | A = 10; # Anusvara |
michael@0 | 53 | |
michael@0 | 54 | syllable_tail = (VPre|VAbv|VBlw|VPst|H.C|CM|MR|T|A)*; |
michael@0 | 55 | |
michael@0 | 56 | consonant_syllable = (C|IV|GB) syllable_tail; |
michael@0 | 57 | broken_cluster = syllable_tail; |
michael@0 | 58 | other = any; |
michael@0 | 59 | |
michael@0 | 60 | main := |* |
michael@0 | 61 | consonant_syllable => { found_syllable (consonant_syllable); }; |
michael@0 | 62 | broken_cluster => { found_syllable (broken_cluster); }; |
michael@0 | 63 | other => { found_syllable (non_sea_cluster); }; |
michael@0 | 64 | *|; |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | }%% |
michael@0 | 68 | |
michael@0 | 69 | #define found_syllable(syllable_type) \ |
michael@0 | 70 | HB_STMT_START { \ |
michael@0 | 71 | if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \ |
michael@0 | 72 | for (unsigned int i = last; i < p+1; i++) \ |
michael@0 | 73 | info[i].syllable() = (syllable_serial << 4) | syllable_type; \ |
michael@0 | 74 | last = p+1; \ |
michael@0 | 75 | syllable_serial++; \ |
michael@0 | 76 | if (unlikely (syllable_serial == 16)) syllable_serial = 1; \ |
michael@0 | 77 | } HB_STMT_END |
michael@0 | 78 | |
michael@0 | 79 | static void |
michael@0 | 80 | find_syllables (hb_buffer_t *buffer) |
michael@0 | 81 | { |
michael@0 | 82 | unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED; |
michael@0 | 83 | int cs; |
michael@0 | 84 | hb_glyph_info_t *info = buffer->info; |
michael@0 | 85 | %%{ |
michael@0 | 86 | write init; |
michael@0 | 87 | getkey info[p].sea_category(); |
michael@0 | 88 | }%% |
michael@0 | 89 | |
michael@0 | 90 | p = 0; |
michael@0 | 91 | pe = eof = buffer->len; |
michael@0 | 92 | |
michael@0 | 93 | unsigned int last = 0; |
michael@0 | 94 | unsigned int syllable_serial = 1; |
michael@0 | 95 | %%{ |
michael@0 | 96 | write exec; |
michael@0 | 97 | }%% |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | #undef found_syllable |
michael@0 | 101 | |
michael@0 | 102 | #endif /* HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH */ |