2 * Copyright © 2015 Mozilla Foundation.
3 * Copyright © 2015 Google, Inc.
5 * This is part of HarfBuzz, a text shaping library.
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 * Mozilla Author(s): Jonathan Kew
26 * Google Author(s): Behdad Esfahbod
29 #ifndef HB_OT_SHAPE_COMPLEX_USE_MACHINE_HH
30 #define HB_OT_SHAPE_COMPLEX_USE_MACHINE_HH
35 machine use_syllable_machine;
36 alphtype unsigned char;
42 # Same order as enum use_category_t. Not sure how to avoid duplication.
52 FM = 8; # CONS_FINAL_MOD
59 ZWNJ = 14; # Zero width non-joiner
60 ZWJ = 15; # Zero width joiner
61 WJ = 16; # Word joiner
62 Rsv = 17; # Reserved characters
66 VS = 21; # VARIATION_SELECTOR
70 FAbv = 24; # CONS_FINAL_ABOVE
71 FBlw = 25; # CONS_FINAL_BELOW
72 FPst = 26; # CONS_FINAL_POST
73 MAbv = 27; # CONS_MED_ABOVE
74 MBlw = 28; # CONS_MED_BELOW
75 MPst = 29; # CONS_MED_POST
76 MPre = 30; # CONS_MED_PRE
77 CMAbv = 31; # CONS_MOD_ABOVE
78 CMBlw = 32; # CONS_MOD_BELOW
79 VAbv = 33; # VOWEL_ABOVE / VOWEL_ABOVE_BELOW / VOWEL_ABOVE_BELOW_POST / VOWEL_ABOVE_POST
80 VBlw = 34; # VOWEL_BELOW / VOWEL_BELOW_POST
81 VPst = 35; # VOWEL_POST UIPC = Right
82 VPre = 22; # VOWEL_PRE / VOWEL_PRE_ABOVE / VOWEL_PRE_ABOVE_POST / VOWEL_PRE_POST
83 VMAbv = 37; # VOWEL_MOD_ABOVE
84 VMBlw = 38; # VOWEL_MOD_BELOW
85 VMPst = 39; # VOWEL_MOD_POST
86 VMPre = 23; # VOWEL_MOD_PRE
87 SMAbv = 41; # SYM_MOD_ABOVE
88 SMBlw = 42; # SYM_MOD_BELOW
89 CS = 43; # CONS_WITH_STACKER
91 HVM = 44; # HALANT_OR_VOWEL_MODIFIER
93 h = H | HVM; # https://github.com/harfbuzz/harfbuzz/issues/1102
95 # Override: Adhoc ZWJ placement. https://github.com/harfbuzz/harfbuzz/issues/542#issuecomment-353169729
96 consonant_modifiers = CMAbv* CMBlw* ((ZWJ?.h.ZWJ? B | SUB) VS? CMAbv? CMBlw*)*;
97 # Override: Allow two MBlw. https://github.com/harfbuzz/harfbuzz/issues/376
98 medial_consonants = MPre? MAbv? MBlw?.MBlw? MPst?;
99 dependent_vowels = VPre* VAbv* VBlw* VPst*;
100 vowel_modifiers = HVM? VMPre* VMAbv* VMBlw* VMPst*;
101 final_consonants = FAbv* FBlw* FPst* FM?;
103 complex_syllable_tail =
111 virama_terminated_cluster =
118 complex_syllable_tail
122 complex_syllable_tail
125 number_joiner_terminated_cluster = N VS? (HN N VS?)* HN;
126 numeral_cluster = N VS? (HN N VS?)*;
127 symbol_cluster = S VS? SMAbv* SMBlw*;
128 independent_cluster = (IND | O | Rsv | WJ) VS?;
132 independent_cluster => { found_syllable (independent_cluster); };
133 virama_terminated_cluster => { found_syllable (virama_terminated_cluster); };
134 standard_cluster => { found_syllable (standard_cluster); };
135 number_joiner_terminated_cluster => { found_syllable (number_joiner_terminated_cluster); };
136 numeral_cluster => { found_syllable (numeral_cluster); };
137 symbol_cluster => { found_syllable (symbol_cluster); };
138 broken_cluster => { found_syllable (broken_cluster); };
139 other => { found_syllable (non_cluster); };
145 #define found_syllable(syllable_type) \
147 if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
148 for (unsigned int i = ts; i < te; i++) \
149 info[i].syllable() = (syllable_serial << 4) | syllable_type; \
151 if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
155 find_syllables (hb_buffer_t *buffer)
157 unsigned int p, pe, eof, ts, te, act;
159 hb_glyph_info_t *info = buffer->info;
162 getkey info[p].use_category();
166 pe = eof = buffer->len;
168 unsigned int syllable_serial = 1;
174 #undef found_syllable
176 #endif /* HB_OT_SHAPE_COMPLEX_USE_MACHINE_HH */