2 * Copyright © 2011 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
24 * Google Author(s): Behdad Esfahbod
27 #ifndef HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH
28 #define HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH
30 #include "hb-private.hh"
35 machine indic_syllable_machine;
36 alphtype unsigned char;
42 # Same order as enum indic_category_t. Not sure how to avoid duplication.
59 matra_group = M N? H?;
60 syllable_tail = SM? (VD VD?)?;
62 action found_consonant_syllable { found_consonant_syllable (map, buffer, mask_array, last, p); }
63 action found_vowel_syllable { found_vowel_syllable (map, buffer, mask_array, last, p); }
64 action found_standalone_cluster { found_standalone_cluster (map, buffer, mask_array, last, p); }
65 action found_non_indic { found_non_indic (map, buffer, mask_array, last, p); }
67 action next_syllable { set_cluster (buffer, p, last); last = p; }
69 consonant_syllable = (c.N? (z.H|H.z?))* c.N? A? (H.z? | matra_group*)? syllable_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 %(found_standalone_cluster);
72 non_indic = X %(found_non_indic);
81 main := (syllable %(next_syllable))**;
87 set_cluster (hb_buffer_t *buffer,
88 unsigned int start, unsigned int end)
90 unsigned int cluster = buffer->info[start].cluster;
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;
99 find_syllables (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array)
101 unsigned int p, pe, eof;
105 getkey buffer->info[p].indic_category();
109 pe = eof = buffer->len;
111 unsigned int last = 0;
119 #endif /* HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH */