OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright © 2011 Google, Inc. |
| 3 * |
| 4 * This is part of HarfBuzz, a text shaping library. |
| 5 * |
| 6 * Permission is hereby granted, without written agreement and without |
| 7 * license or royalty fees, to use, copy, modify, and distribute this |
| 8 * software and its documentation for any purpose, provided that the |
| 9 * above copyright notice and the following two paragraphs appear in |
| 10 * all copies of this software. |
| 11 * |
| 12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 16 * DAMAGE. |
| 17 * |
| 18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 23 * |
| 24 * Google Author(s): Behdad Esfahbod |
| 25 */ |
| 26 |
| 27 #ifndef HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH |
| 28 #define HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH |
| 29 |
| 30 #include "hb-private.hh" |
| 31 |
| 32 HB_BEGIN_DECLS |
| 33 |
| 34 %%{ |
| 35 machine indic_syllable_machine; |
| 36 alphtype unsigned char; |
| 37 write data; |
| 38 }%% |
| 39 |
| 40 %%{ |
| 41 |
| 42 # Same order as enum indic_category_t. Not sure how to avoid duplication. |
| 43 X = 0; |
| 44 C = 1; |
| 45 Ra = 2; |
| 46 V = 3; |
| 47 N = 4; |
| 48 H = 5; |
| 49 ZWNJ = 6; |
| 50 ZWJ = 7; |
| 51 M = 8; |
| 52 SM = 9; |
| 53 VD = 10; |
| 54 A = 11; |
| 55 NBSP = 12; |
| 56 |
| 57 c = C | Ra; |
| 58 z = ZWJ|ZWNJ; |
| 59 matra_group = M N? H?; |
| 60 syllable_tail = SM? (VD VD?)?; |
| 61 |
| 62 action found_consonant_syllable { found_consonant_syllable (map, buffer, mask_ar
ray, last, p); } |
| 63 action found_vowel_syllable { found_vowel_syllable (map, buffer, mask_array, las
t, p); } |
| 64 action found_standalone_cluster { found_standalone_cluster (map, buffer, mask_ar
ray, last, p); } |
| 65 action found_non_indic { found_non_indic (map, buffer, mask_array, last, p); } |
| 66 |
| 67 action next_syllable { set_cluster (buffer, p, last); last = p; } |
| 68 |
| 69 consonant_syllable = (c.N? (z.H|H.z?))* c.N? A? (H.z? | matra_group*)? syllab
le_tail %(found_consonant_syllable); |
| 70 vowel_syllable = (Ra H)? V N? (z.H.c | ZWJ.c)? matra_group* syllable_tail
%(found_vowel_syllable); |
| 71 standalone_cluster = (Ra H)? NBSP N? (z? H c)? matra_group* syllable_tail %(f
ound_standalone_cluster); |
| 72 non_indic = X %(found_non_indic); |
| 73 |
| 74 syllable = |
| 75 consonant_syllable |
| 76 | vowel_syllable |
| 77 | standalone_cluster |
| 78 | non_indic |
| 79 ; |
| 80 |
| 81 main := (syllable %(next_syllable))**; |
| 82 |
| 83 }%% |
| 84 |
| 85 |
| 86 static void |
| 87 set_cluster (hb_buffer_t *buffer, |
| 88 unsigned int start, unsigned int end) |
| 89 { |
| 90 unsigned int cluster = buffer->info[start].cluster; |
| 91 |
| 92 for (unsigned int i = start + 1; i < end; i++) |
| 93 cluster = MIN (cluster, buffer->info[i].cluster); |
| 94 for (unsigned int i = start; i < end; i++) |
| 95 buffer->info[i].cluster = cluster; |
| 96 } |
| 97 |
| 98 static void |
| 99 find_syllables (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_arr
ay) |
| 100 { |
| 101 unsigned int p, pe, eof; |
| 102 int cs; |
| 103 %%{ |
| 104 write init; |
| 105 getkey buffer->info[p].indic_category(); |
| 106 }%% |
| 107 |
| 108 p = 0; |
| 109 pe = eof = buffer->len; |
| 110 |
| 111 unsigned int last = 0; |
| 112 %%{ |
| 113 write exec; |
| 114 }%% |
| 115 } |
| 116 |
| 117 HB_END_DECLS |
| 118 |
| 119 #endif /* HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH */ |
OLD | NEW |