2 * Copyright © 2012 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_PRIVATE_HH
28 #define HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH
30 #include "hb-private.hh"
33 #include "hb-ot-shape-complex-private.hh"
36 /* buffer var allocations */
37 #define indic_category() complex_var_persistent_u8_0() /* indic_category_t */
38 #define indic_position() complex_var_persistent_u8_1() /* indic_matra_category_t */
40 #define INDIC_TABLE_ELEMENT_TYPE uint8_t
42 /* Cateories used in the OpenType spec:
43 * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx
45 /* Note: This enum is duplicated in the -machine.rl source file.
46 * Not sure how to avoid duplication. */
47 enum indic_category_t {
50 OT_Ra, /* Not explicitly listed in the OT spec, but used in the grammar. */
61 OT_DOTTEDCIRCLE /* Not in the spec, but special in Uniscribe. /Very very/ special! */
64 /* Visual positions in a syllable from left to right. */
65 enum indic_position_t {
66 POS_RA_TO_BECOME_REPH,
79 /* Categories used in IndicSyllabicCategory.txt from UCD. */
80 enum indic_syllabic_category_t {
81 INDIC_SYLLABIC_CATEGORY_OTHER = OT_X,
83 INDIC_SYLLABIC_CATEGORY_AVAGRAHA = OT_X,
84 INDIC_SYLLABIC_CATEGORY_BINDU = OT_SM,
85 INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C,
86 INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C,
87 INDIC_SYLLABIC_CATEGORY_CONSONANT_FINAL = OT_C,
88 INDIC_SYLLABIC_CATEGORY_CONSONANT_HEAD_LETTER = OT_C,
89 INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL = OT_C,
90 INDIC_SYLLABIC_CATEGORY_CONSONANT_PLACEHOLDER = OT_NBSP,
91 INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED = OT_C,
92 INDIC_SYLLABIC_CATEGORY_CONSONANT_REPHA = OT_C,
93 INDIC_SYLLABIC_CATEGORY_MODIFYING_LETTER = OT_X,
94 INDIC_SYLLABIC_CATEGORY_NUKTA = OT_N,
95 INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER = OT_X,
96 INDIC_SYLLABIC_CATEGORY_TONE_LETTER = OT_X,
97 INDIC_SYLLABIC_CATEGORY_TONE_MARK = OT_X,
98 INDIC_SYLLABIC_CATEGORY_VIRAMA = OT_H,
99 INDIC_SYLLABIC_CATEGORY_VISARGA = OT_SM,
100 INDIC_SYLLABIC_CATEGORY_VOWEL = OT_V,
101 INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT = OT_M,
102 INDIC_SYLLABIC_CATEGORY_VOWEL_INDEPENDENT = OT_V
105 /* Categories used in IndicSMatraCategory.txt from UCD */
106 enum indic_matra_category_t {
107 INDIC_MATRA_CATEGORY_NOT_APPLICABLE = POS_BASE_C,
109 INDIC_MATRA_CATEGORY_LEFT = POS_PRE_M,
110 INDIC_MATRA_CATEGORY_TOP = POS_ABOVE_M,
111 INDIC_MATRA_CATEGORY_BOTTOM = POS_BELOW_M,
112 INDIC_MATRA_CATEGORY_RIGHT = POS_POST_M,
114 /* We don't really care much about these since we decompose them
115 * in the generic pre-shaping layer. They will only be used if
116 * the font does not cover the decomposition. In which case, we
117 * define these as aliases to the place we want the split-matra
118 * glyph to show up. Quite arbitrary.
120 * TODO: There are some split matras without Unicode decompositions.
121 * We have to figure out what to do with them.
123 INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT = POS_POST_M,
124 INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT = POS_PRE_M,
125 INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM = POS_BELOW_M,
126 INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT = POS_POST_M,
127 INDIC_MATRA_CATEGORY_TOP_AND_LEFT = POS_PRE_M,
128 INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT = POS_PRE_M,
129 INDIC_MATRA_CATEGORY_TOP_AND_RIGHT = POS_POST_M,
131 INDIC_MATRA_CATEGORY_INVISIBLE = INDIC_MATRA_CATEGORY_NOT_APPLICABLE,
132 INDIC_MATRA_CATEGORY_OVERSTRUCK = INDIC_MATRA_CATEGORY_NOT_APPLICABLE,
133 INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT = INDIC_MATRA_CATEGORY_NOT_APPLICABLE
136 /* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and the comma operation
137 * because gcc fails to optimize the latter and fills the table in at runtime. */
138 #define INDIC_COMBINE_CATEGORIES(S,M) \
139 (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == INDIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)) + \
140 ASSERT_STATIC_EXPR_ZERO (S < 16 && M < 16) + \
144 #include "hb-ot-shape-complex-indic-table.hh"
147 * This is a hack for now. We should:
148 * 1. Move this data into the main Indic table,
150 * 2. Probe font lookups to determine consonant positions.
152 static const struct consonant_position_t {
154 indic_position_t position;
155 } consonant_positions[] = {
156 {0x0930, POS_BELOW_C},
157 {0x09AC, POS_BELOW_C},
158 {0x09AF, POS_POST_C},
159 {0x09B0, POS_BELOW_C},
160 {0x09F0, POS_BELOW_C},
161 {0x0A2F, POS_POST_C},
162 {0x0A30, POS_BELOW_C},
163 {0x0A35, POS_BELOW_C},
164 {0x0A39, POS_BELOW_C},
165 {0x0AB0, POS_BELOW_C},
166 {0x0B24, POS_BELOW_C},
167 {0x0B28, POS_BELOW_C},
168 {0x0B2C, POS_BELOW_C},
169 {0x0B2D, POS_BELOW_C},
170 {0x0B2E, POS_BELOW_C},
171 {0x0B2F, POS_POST_C},
172 {0x0B30, POS_BELOW_C},
173 {0x0B32, POS_BELOW_C},
174 {0x0B33, POS_BELOW_C},
175 {0x0B5F, POS_POST_C},
176 {0x0B71, POS_BELOW_C},
177 {0x0C15, POS_BELOW_C},
178 {0x0C16, POS_BELOW_C},
179 {0x0C17, POS_BELOW_C},
180 {0x0C18, POS_BELOW_C},
181 {0x0C19, POS_BELOW_C},
182 {0x0C1A, POS_BELOW_C},
183 {0x0C1B, POS_BELOW_C},
184 {0x0C1C, POS_BELOW_C},
185 {0x0C1D, POS_BELOW_C},
186 {0x0C1E, POS_BELOW_C},
187 {0x0C1F, POS_BELOW_C},
188 {0x0C20, POS_BELOW_C},
189 {0x0C21, POS_BELOW_C},
190 {0x0C22, POS_BELOW_C},
191 {0x0C23, POS_BELOW_C},
192 {0x0C24, POS_BELOW_C},
193 {0x0C25, POS_BELOW_C},
194 {0x0C26, POS_BELOW_C},
195 {0x0C27, POS_BELOW_C},
196 {0x0C28, POS_BELOW_C},
197 {0x0C2A, POS_BELOW_C},
198 {0x0C2B, POS_BELOW_C},
199 {0x0C2C, POS_BELOW_C},
200 {0x0C2D, POS_BELOW_C},
201 {0x0C2E, POS_BELOW_C},
202 {0x0C2F, POS_BELOW_C},
203 {0x0C30, POS_BELOW_C},
204 {0x0C32, POS_BELOW_C},
205 {0x0C33, POS_BELOW_C},
206 {0x0C35, POS_BELOW_C},
207 {0x0C36, POS_BELOW_C},
208 {0x0C37, POS_BELOW_C},
209 {0x0C38, POS_BELOW_C},
210 {0x0C39, POS_BELOW_C},
211 {0x0C95, POS_BELOW_C},
212 {0x0C96, POS_BELOW_C},
213 {0x0C97, POS_BELOW_C},
214 {0x0C98, POS_BELOW_C},
215 {0x0C99, POS_BELOW_C},
216 {0x0C9A, POS_BELOW_C},
217 {0x0C9B, POS_BELOW_C},
218 {0x0C9C, POS_BELOW_C},
219 {0x0C9D, POS_BELOW_C},
220 {0x0C9E, POS_BELOW_C},
221 {0x0C9F, POS_BELOW_C},
222 {0x0CA0, POS_BELOW_C},
223 {0x0CA1, POS_BELOW_C},
224 {0x0CA2, POS_BELOW_C},
225 {0x0CA3, POS_BELOW_C},
226 {0x0CA4, POS_BELOW_C},
227 {0x0CA5, POS_BELOW_C},
228 {0x0CA6, POS_BELOW_C},
229 {0x0CA7, POS_BELOW_C},
230 {0x0CA8, POS_BELOW_C},
231 {0x0CAA, POS_BELOW_C},
232 {0x0CAB, POS_BELOW_C},
233 {0x0CAC, POS_BELOW_C},
234 {0x0CAD, POS_BELOW_C},
235 {0x0CAE, POS_BELOW_C},
236 {0x0CAF, POS_BELOW_C},
237 {0x0CB0, POS_BELOW_C},
238 {0x0CB2, POS_BELOW_C},
239 {0x0CB3, POS_BELOW_C},
240 {0x0CB5, POS_BELOW_C},
241 {0x0CB6, POS_BELOW_C},
242 {0x0CB7, POS_BELOW_C},
243 {0x0CB8, POS_BELOW_C},
244 {0x0CB9, POS_BELOW_C},
245 {0x0CDE, POS_BELOW_C},
246 {0x0D2F, POS_POST_C},
247 {0x0D30, POS_POST_C},
248 {0x0D32, POS_BELOW_C},
249 {0x0D35, POS_POST_C},
253 * This is a hack for now. We should move this data into the main Indic table.
254 * Or completely remove it and just check in the tables.
256 static const hb_codepoint_t ra_chars[] = {
257 0x0930, /* Devanagari */
258 0x09B0, /* Bengali */
259 0x09F0, /* Bengali */
260 0x0A30, /* Gurmukhi */ /* No Reph */
261 0x0AB0, /* Gujarati */
263 0x0BB0, /* Tamil */ /* No Reph */
264 0x0C30, /* Telugu */ /* No Reph */
265 0x0CB0, /* Kannada */
266 0x0D30, /* Malayalam */ /* No Reph */
270 #endif /* HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH */