Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-ot-shape-complex-indic.cc

Issue 396393005: Roll HarfBuzz to 0.9.32 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright © 2011,2012 Google, Inc. 2 * Copyright © 2011,2012 Google, Inc.
3 * 3 *
4 * This is part of HarfBuzz, a text shaping library. 4 * This is part of HarfBuzz, a text shaping library.
5 * 5 *
6 * Permission is hereby granted, without written agreement and without 6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this 7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the 8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in 9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software. 10 * all copies of this software.
(...skipping 19 matching lines...) Expand all
30 /* buffer var allocations */ 30 /* buffer var allocations */
31 #define indic_category() complex_var_u8_0() /* indic_category_t */ 31 #define indic_category() complex_var_u8_0() /* indic_category_t */
32 #define indic_position() complex_var_u8_1() /* indic_position_t */ 32 #define indic_position() complex_var_u8_1() /* indic_position_t */
33 33
34 34
35 /* 35 /*
36 * Indic shaper. 36 * Indic shaper.
37 */ 37 */
38 38
39 39
40 #define IN_HALF_BLOCK(u, Base) (((u) & ~0x7F) == (Base)) 40 #define IN_HALF_BLOCK(u, Base) (((u) & ~0x7Fu) == (Base))
41 41
42 #define IS_DEVA(u) (IN_HALF_BLOCK (u, 0x0900)) 42 #define IS_DEVA(u) (IN_HALF_BLOCK (u, 0x0900u))
43 #define IS_BENG(u) (IN_HALF_BLOCK (u, 0x0980)) 43 #define IS_BENG(u) (IN_HALF_BLOCK (u, 0x0980u))
44 #define IS_GURU(u) (IN_HALF_BLOCK (u, 0x0A00)) 44 #define IS_GURU(u) (IN_HALF_BLOCK (u, 0x0A00u))
45 #define IS_GUJR(u) (IN_HALF_BLOCK (u, 0x0A80)) 45 #define IS_GUJR(u) (IN_HALF_BLOCK (u, 0x0A80u))
46 #define IS_ORYA(u) (IN_HALF_BLOCK (u, 0x0B00)) 46 #define IS_ORYA(u) (IN_HALF_BLOCK (u, 0x0B00u))
47 #define IS_TAML(u) (IN_HALF_BLOCK (u, 0x0B80)) 47 #define IS_TAML(u) (IN_HALF_BLOCK (u, 0x0B80u))
48 #define IS_TELU(u) (IN_HALF_BLOCK (u, 0x0C00)) 48 #define IS_TELU(u) (IN_HALF_BLOCK (u, 0x0C00u))
49 #define IS_KNDA(u) (IN_HALF_BLOCK (u, 0x0C80)) 49 #define IS_KNDA(u) (IN_HALF_BLOCK (u, 0x0C80u))
50 #define IS_MLYM(u) (IN_HALF_BLOCK (u, 0x0D00)) 50 #define IS_MLYM(u) (IN_HALF_BLOCK (u, 0x0D00u))
51 #define IS_SINH(u) (IN_HALF_BLOCK (u, 0x0D80)) 51 #define IS_SINH(u) (IN_HALF_BLOCK (u, 0x0D80u))
52 #define IS_KHMR(u) (IN_HALF_BLOCK (u, 0x1780)) 52 #define IS_KHMR(u) (IN_HALF_BLOCK (u, 0x1780u))
53 53
54 54
55 #define MATRA_POS_LEFT(u) POS_PRE_M 55 #define MATRA_POS_LEFT(u) POS_PRE_M
56 #define MATRA_POS_RIGHT(u) ( \ 56 #define MATRA_POS_RIGHT(u) ( \
57 IS_DEVA(u) ? POS_AFTER_SUB : \ 57 IS_DEVA(u) ? POS_AFTER_SUB : \
58 IS_BENG(u) ? POS_AFTER_POST : \ 58 IS_BENG(u) ? POS_AFTER_POST : \
59 IS_GURU(u) ? POS_AFTER_POST : \ 59 IS_GURU(u) ? POS_AFTER_POST : \
60 IS_GUJR(u) ? POS_AFTER_POST : \ 60 IS_GUJR(u) ? POS_AFTER_POST : \
61 IS_ORYA(u) ? POS_AFTER_POST : \ 61 IS_ORYA(u) ? POS_AFTER_POST : \
62 IS_TAML(u) ? POS_AFTER_POST : \ 62 IS_TAML(u) ? POS_AFTER_POST : \
63 » » » » IS_TELU(u) ? (u <= 0x0C42 ? POS_BEFORE_SUB : P OS_AFTER_SUB) : \ 63 » » » » IS_TELU(u) ? (u <= 0x0C42u ? POS_BEFORE_SUB : POS_AFTER_SUB) : \
64 » » » » IS_KNDA(u) ? (u < 0x0CC3 || u > 0xCD6 ? POS_BE FORE_SUB : POS_AFTER_SUB) : \ 64 » » » » IS_KNDA(u) ? (u < 0x0CC3u || u > 0xCD6u ? POS_ BEFORE_SUB : POS_AFTER_SUB) : \
65 IS_MLYM(u) ? POS_AFTER_POST : \ 65 IS_MLYM(u) ? POS_AFTER_POST : \
66 IS_SINH(u) ? POS_AFTER_SUB : \ 66 IS_SINH(u) ? POS_AFTER_SUB : \
67 IS_KHMR(u) ? POS_AFTER_POST : \ 67 IS_KHMR(u) ? POS_AFTER_POST : \
68 /*default*/ POS_AFTER_SUB \ 68 /*default*/ POS_AFTER_SUB \
69 ) 69 )
70 #define MATRA_POS_TOP(u) ( /* BENG and MLYM don't have top matras. */ \ 70 #define MATRA_POS_TOP(u) ( /* BENG and MLYM don't have top matras. */ \
71 IS_DEVA(u) ? POS_AFTER_SUB : \ 71 IS_DEVA(u) ? POS_AFTER_SUB : \
72 IS_GURU(u) ? POS_AFTER_POST : /* Deviate from spec */ \ 72 IS_GURU(u) ? POS_AFTER_POST : /* Deviate from spec */ \
73 IS_GUJR(u) ? POS_AFTER_SUB : \ 73 IS_GUJR(u) ? POS_AFTER_SUB : \
74 IS_ORYA(u) ? POS_AFTER_MAIN : \ 74 IS_ORYA(u) ? POS_AFTER_MAIN : \
(...skipping 30 matching lines...) Expand all
105 case POS_BELOW_C: return MATRA_POS_BOTTOM (u); 105 case POS_BELOW_C: return MATRA_POS_BOTTOM (u);
106 }; 106 };
107 return side; 107 return side;
108 } 108 }
109 109
110 /* XXX 110 /* XXX
111 * This is a hack for now. We should move this data into the main Indic table. 111 * This is a hack for now. We should move this data into the main Indic table.
112 * Or completely remove it and just check in the tables. 112 * Or completely remove it and just check in the tables.
113 */ 113 */
114 static const hb_codepoint_t ra_chars[] = { 114 static const hb_codepoint_t ra_chars[] = {
115 0x0930, /* Devanagari */ 115 0x0930u, /* Devanagari */
116 0x09B0, /* Bengali */ 116 0x09B0u, /* Bengali */
117 0x09F0, /* Bengali */ 117 0x09F0u, /* Bengali */
118 0x0A30, /* Gurmukhi */» /* No Reph */ 118 0x0A30u, /* Gurmukhi */» /* No Reph */
119 0x0AB0, /* Gujarati */ 119 0x0AB0u, /* Gujarati */
120 0x0B30, /* Oriya */ 120 0x0B30u, /* Oriya */
121 0x0BB0, /* Tamil */» » /* No Reph */ 121 0x0BB0u, /* Tamil */» » /* No Reph */
122 0x0C30, /* Telugu */» » /* Reph formed only with ZWJ */ 122 0x0C30u, /* Telugu */»» /* Reph formed only with ZWJ */
123 0x0CB0, /* Kannada */ 123 0x0CB0u, /* Kannada */
124 0x0D30, /* Malayalam */» /* No Reph, Logical Repha */ 124 0x0D30u, /* Malayalam */» /* No Reph, Logical Repha */
125 125
126 0x0DBB, /* Sinhala */»» /* Reph formed only with ZWJ */ 126 0x0DBBu, /* Sinhala */» » /* Reph formed only with ZWJ */
127 127
128 0x179A, /* Khmer */» » /* No Reph, Visual Repha */ 128 0x179Au, /* Khmer */» » /* No Reph, Visual Repha */
129 }; 129 };
130 130
131 static inline bool 131 static inline bool
132 is_ra (hb_codepoint_t u) 132 is_ra (hb_codepoint_t u)
133 { 133 {
134 for (unsigned int i = 0; i < ARRAY_LENGTH (ra_chars); i++) 134 for (unsigned int i = 0; i < ARRAY_LENGTH (ra_chars); i++)
135 if (u == ra_chars[i]) 135 if (u == ra_chars[i])
136 return true; 136 return true;
137 return false; 137 return false;
138 } 138 }
139 139
140 static inline bool 140 static inline bool
141 is_one_of (const hb_glyph_info_t &info, unsigned int flags) 141 is_one_of (const hb_glyph_info_t &info, unsigned int flags)
142 { 142 {
143 /* If it ligated, all bets are off. */ 143 /* If it ligated, all bets are off. */
144 if (_hb_glyph_info_ligated (&info)) return false; 144 if (_hb_glyph_info_ligated (&info)) return false;
145 return !!(FLAG (info.indic_category()) & flags); 145 return !!(FLAG (info.indic_category()) & flags);
146 } 146 }
147 147
148 #define JOINER_FLAGS (FLAG (OT_ZWJ) | FLAG (OT_ZWNJ))
149 static inline bool 148 static inline bool
150 is_joiner (const hb_glyph_info_t &info) 149 is_joiner (const hb_glyph_info_t &info)
151 { 150 {
152 return is_one_of (info, JOINER_FLAGS); 151 return is_one_of (info, JOINER_FLAGS);
153 } 152 }
154 153
155 #define MEDIAL_FLAGS (FLAG (OT_CM) | FLAG (OT_CM2))
156
157 /* Note:
158 *
159 * We treat Vowels and placeholders as if they were consonants. This is safe be cause Vowels
160 * cannot happen in a consonant syllable. The plus side however is, we can call the
161 * consonant syllable logic from the vowel syllable function and get it all righ t! */
162 #define CONSONANT_FLAGS (FLAG (OT_C) | FLAG (OT_Ra) | MEDIAL_FLAGS | FLAG (OT_V) | FLAG (OT_NBSP) | FLAG (OT_DOTTEDCIRCLE))
163 static inline bool 154 static inline bool
164 is_consonant (const hb_glyph_info_t &info) 155 is_consonant (const hb_glyph_info_t &info)
165 { 156 {
166 return is_one_of (info, CONSONANT_FLAGS); 157 return is_one_of (info, CONSONANT_FLAGS);
167 } 158 }
168 159
169 #define HALANT_OR_COENG_FLAGS (FLAG (OT_H) | FLAG (OT_Coeng))
170 static inline bool 160 static inline bool
171 is_halant_or_coeng (const hb_glyph_info_t &info) 161 is_halant_or_coeng (const hb_glyph_info_t &info)
172 { 162 {
173 return is_one_of (info, HALANT_OR_COENG_FLAGS); 163 return is_one_of (info, HALANT_OR_COENG_FLAGS);
174 } 164 }
175 165
176 static inline void 166 static inline void
177 set_indic_properties (hb_glyph_info_t &info) 167 set_indic_properties (hb_glyph_info_t &info)
178 { 168 {
179 hb_codepoint_t u = info.codepoint; 169 hb_codepoint_t u = info.codepoint;
180 unsigned int type = hb_indic_get_categories (u); 170 unsigned int type = hb_indic_get_categories (u);
181 indic_category_t cat = (indic_category_t) (type & 0x7F); 171 indic_category_t cat = (indic_category_t) (type & 0x7Fu);
182 indic_position_t pos = (indic_position_t) (type >> 8); 172 indic_position_t pos = (indic_position_t) (type >> 8);
183 173
184 174
185 /* 175 /*
186 * Re-assign category 176 * Re-assign category
187 */ 177 */
188 178
189 179
190 /* The spec says U+0952 is OT_A. However, testing shows that Uniscribe 180 /* The spec says U+0952 is OT_A. However, testing shows that Uniscribe
191 * treats U+0951..U+0954 all behave similarly. 181 * treats a whole bunch of characters similarly.
192 * TESTS: 182 * TESTS: For example, for U+0951:
193 * U+092E,U+0947,U+0952 183 * U+092E,U+0947,U+0952
194 * U+092E,U+0952,U+0947 184 * U+092E,U+0952,U+0947
195 * U+092E,U+0947,U+0951 185 * U+092E,U+0947,U+0951
196 * U+092E,U+0951,U+0947 186 * U+092E,U+0951,U+0947
187 * U+092E,U+0951,U+0952
188 * U+092E,U+0952,U+0951
197 */ 189 */
198 if (unlikely (hb_in_range<hb_codepoint_t> (u, 0x0951, 0x0954))) 190 if (unlikely (hb_in_ranges (u, 0x0951u, 0x0952u,
191 » » » » 0x1CD0u, 0x1CD2u,
192 » » » » 0x1CD4u, 0x1CE1u) ||
193 » » » u == 0x1CF4u))
199 cat = OT_A; 194 cat = OT_A;
200 195 /* The following act more like the Bindus. */
201 if (unlikely (u == 0x17D1)) 196 else if (unlikely (hb_in_range (u, 0x0953u, 0x0954u)))
202 cat = OT_X; 197 cat = OT_SM;
203 if (cat == OT_X && 198 /* The following act like consonants. */
204 unlikely (hb_in_range<hb_codepoint_t> (u, 0x17CB, 0x17D3))) /* Khmer Vario us signs */ 199 else if (unlikely (hb_in_ranges (u, 0x0A72u, 0x0A73u,
200 » » » » 0x1CF5u, 0x1CF6u)))
201 cat = OT_C;
202 /* TODO: The following should only be allowed after a Visarga.
203 * For now, just treat them like regular tone marks. */
204 else if (unlikely (hb_in_range (u, 0x1CE2u, 0x1CE8u)))
205 cat = OT_A;
206 /* TODO: The following should only be allowed after some of
207 * the nasalization marks, maybe only for U+1CE9..U+1CF1.
208 * For now, just treat them like tone marks. */
209 else if (unlikely (u == 0x1CEDu))
210 cat = OT_A;
211 /* The following take marks in standalone clusters, similar to Avagraha. */
212 else if (unlikely (hb_in_ranges (u, 0xA8F2u, 0xA8F7u,
213 » » » » 0x1CE9u, 0x1CECu,
214 » » » » 0x1CEEu, 0x1CF1u)))
215 {
216 cat = OT_Symbol;
217 ASSERT_STATIC ((int) INDIC_SYLLABIC_CATEGORY_AVAGRAHA == OT_Symbol);
218 }
219 else if (unlikely (hb_in_range (u, 0x17CDu, 0x17D1u) ||
220 » » u == 0x17CBu || u == 0x17D3u || u == 0x17DDu)) /* Khmer Var ious signs */
205 { 221 {
206 /* These are like Top Matras. */ 222 /* These are like Top Matras. */
207 cat = OT_M; 223 cat = OT_M;
208 pos = POS_ABOVE_C; 224 pos = POS_ABOVE_C;
209 } 225 }
210 if (u == 0x17C6) /* Khmer Bindu doesn't like to be repositioned. */ 226 else if (unlikely (u == 0x17C6u)) cat = OT_N; /* Khmer Bindu doesn't like to b e repositioned. */
211 cat = OT_N; 227 else if (unlikely (u == 0x17D2u)) cat = OT_Coeng; /* Khmer coeng */
212 228 else if (unlikely (hb_in_range (u, 0x2010u, 0x2011u)))
213 if (unlikely (u == 0x17D2)) cat = OT_Coeng; /* Khmer coeng */ 229 » » » » cat = OT_PLACEHOLDER;
214 else if (unlikely (u == 0x200C)) cat = OT_ZWNJ; 230 else if (unlikely (u == 0x25CCu)) cat = OT_DOTTEDCIRCLE;
215 else if (unlikely (u == 0x200D)) cat = OT_ZWJ; 231 else if (unlikely (u == 0xA982u)) cat = OT_SM; /* Javanese repha. */
216 else if (unlikely (u == 0x25CC)) cat = OT_DOTTEDCIRCLE; 232 else if (unlikely (u == 0xA9BEu)) cat = OT_CM2; /* Javanese medial ya. */
217 else if (unlikely (u == 0x0A71)) cat = OT_SM; /* GURMUKHI ADDAK. Move it to t he end. */ 233 else if (unlikely (u == 0xA9BDu)) { cat = OT_M; pos = POS_POST_C; } /* Javanes e vocalic r. */
218 else if (unlikely (u == 0xA982)) cat = OT_SM; /* Javanese repha. */
219 else if (unlikely (u == 0xA9BE)) cat = OT_CM2; /* Javanese medial ya. */
220 else if (unlikely (u == 0xA9BD)) { cat = OT_M; pos = POS_POST_C; } /* Javanese vocalic r. */
221
222 if (cat == OT_Repha) {
223 /* There are two kinds of characters marked as Repha:
224 * - The ones that are GenCat=Mn are already positioned visually, ie. after base. (eg. Khmer)
225 * - The ones that are GenCat=Lo is encoded logically, ie. beginning of syll able. (eg. Malayalam)
226 *
227 * We recategorize the first kind to look like a Nukta and attached to the b ase directly.
228 */
229 if (_hb_glyph_info_get_general_category (&info) == HB_UNICODE_GENERAL_CATEGO RY_NON_SPACING_MARK)
230 cat = OT_N;
231 }
232
233 234
234 235
235 /* 236 /*
236 * Re-assign position. 237 * Re-assign position.
237 */ 238 */
238 239
239 if ((FLAG (cat) & CONSONANT_FLAGS)) 240 if ((FLAG (cat) & CONSONANT_FLAGS))
240 { 241 {
241 pos = POS_BASE_C; 242 pos = POS_BASE_C;
242 if (is_ra (u)) 243 if (is_ra (u))
243 cat = OT_Ra; 244 cat = OT_Ra;
244 } 245 }
245 else if (cat == OT_M) 246 else if (cat == OT_M)
246 { 247 {
247 pos = matra_position (u, pos); 248 pos = matra_position (u, pos);
248 } 249 }
249 else if ((FLAG (cat) & (FLAG (OT_SM) | FLAG (OT_VD) | FLAG (OT_A) | FLAG (OT_A vag)))) 250 else if ((FLAG (cat) & (FLAG (OT_SM) | FLAG (OT_VD) | FLAG (OT_A) | FLAG (OT_S ymbol))))
250 { 251 {
251 pos = POS_SMVD; 252 pos = POS_SMVD;
252 } 253 }
253 254
254 if (unlikely (u == 0x0B01)) pos = POS_BEFORE_SUB; /* Oriya Bindu is BeforeSub in the spec. */ 255 if (unlikely (u == 0x0B01u)) pos = POS_BEFORE_SUB; /* Oriya Bindu is BeforeSub in the spec. */
255 256
256 257
257 258
258 info.indic_category() = cat; 259 info.indic_category() = cat;
259 info.indic_position() = pos; 260 info.indic_position() = pos;
260 } 261 }
261 262
262 /* 263 /*
263 * Things above this line should ideally be moved to the Indic table itself. 264 * Things above this line should ideally be moved to the Indic table itself.
264 */ 265 */
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 base_position_t base_pos; 309 base_position_t base_pos;
309 reph_position_t reph_pos; 310 reph_position_t reph_pos;
310 reph_mode_t reph_mode; 311 reph_mode_t reph_mode;
311 blwf_mode_t blwf_mode; 312 blwf_mode_t blwf_mode;
312 pref_len_t pref_len; 313 pref_len_t pref_len;
313 }; 314 };
314 315
315 static const indic_config_t indic_configs[] = 316 static const indic_config_t indic_configs[] =
316 { 317 {
317 /* Default. Should be first. */ 318 /* Default. Should be first. */
318 {HB_SCRIPT_INVALID,» false, 0,BASE_POS_LAST, REPH_POS_BEFORE_POST,REPH_MO DE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_1}, 319 {HB_SCRIPT_INVALID,» false, 0,BASE_POS_LAST, REPH_POS_BEFORE_POST,REPH_M ODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_1},
319 {HB_SCRIPT_DEVANAGARI,true, 0x094D,BASE_POS_LAST, REPH_POS_BEFORE_POST,REPH_MO DE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE}, 320 {HB_SCRIPT_DEVANAGARI,true, 0x094Du,BASE_POS_LAST, REPH_POS_BEFORE_POST,REPH_M ODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
320 {HB_SCRIPT_BENGALI,» true, 0x09CD,BASE_POS_LAST, REPH_POS_AFTER_SUB, REPH_MO DE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE}, 321 {HB_SCRIPT_BENGALI,» true, 0x09CDu,BASE_POS_LAST, REPH_POS_AFTER_SUB, REPH_M ODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
321 {HB_SCRIPT_GURMUKHI,» true, 0x0A4D,BASE_POS_LAST, REPH_POS_BEFORE_SUB, REPH_MO DE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE}, 322 {HB_SCRIPT_GURMUKHI,» true, 0x0A4Du,BASE_POS_LAST, REPH_POS_BEFORE_SUB, REPH_M ODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
322 {HB_SCRIPT_GUJARATI,» true, 0x0ACD,BASE_POS_LAST, REPH_POS_BEFORE_POST,REPH_MO DE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE}, 323 {HB_SCRIPT_GUJARATI,» true, 0x0ACDu,BASE_POS_LAST, REPH_POS_BEFORE_POST,REPH_M ODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
323 {HB_SCRIPT_ORIYA,» true, 0x0B4D,BASE_POS_LAST, REPH_POS_AFTER_MAIN, REPH_MO DE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE}, 324 {HB_SCRIPT_ORIYA,» true, 0x0B4Du,BASE_POS_LAST, REPH_POS_AFTER_MAIN, REPH_M ODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
324 {HB_SCRIPT_TAMIL,» true, 0x0BCD,BASE_POS_LAST, REPH_POS_AFTER_POST, REPH_MO DE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_2}, 325 {HB_SCRIPT_TAMIL,» true, 0x0BCDu,BASE_POS_LAST, REPH_POS_AFTER_POST, REPH_M ODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_2},
325 {HB_SCRIPT_TELUGU,» true, 0x0C4D,BASE_POS_LAST, REPH_POS_AFTER_POST, REPH_MO DE_EXPLICIT, BLWF_MODE_POST_ONLY, PREF_LEN_2}, 326 {HB_SCRIPT_TELUGU,» true, 0x0C4Du,BASE_POS_LAST, REPH_POS_AFTER_POST, REPH_M ODE_EXPLICIT, BLWF_MODE_POST_ONLY, PREF_LEN_2},
326 {HB_SCRIPT_KANNADA,» true, 0x0CCD,BASE_POS_LAST, REPH_POS_AFTER_POST, REPH_MO DE_IMPLICIT, BLWF_MODE_POST_ONLY, PREF_LEN_2}, 327 {HB_SCRIPT_KANNADA,» true, 0x0CCDu,BASE_POS_LAST, REPH_POS_AFTER_POST, REPH_M ODE_IMPLICIT, BLWF_MODE_POST_ONLY, PREF_LEN_2},
327 {HB_SCRIPT_MALAYALAM,»true, 0x0D4D,BASE_POS_LAST, REPH_POS_AFTER_MAIN, REPH_MO DE_LOG_REPHA,BLWF_MODE_PRE_AND_POST, PREF_LEN_2}, 328 {HB_SCRIPT_MALAYALAM,»true, 0x0D4Du,BASE_POS_LAST, REPH_POS_AFTER_MAIN, REPH_M ODE_LOG_REPHA,BLWF_MODE_PRE_AND_POST, PREF_LEN_2},
328 {HB_SCRIPT_SINHALA,» false,0x0DCA,BASE_POS_LAST_SINHALA, 329 {HB_SCRIPT_SINHALA,» false,0x0DCAu,BASE_POS_LAST_SINHALA,
329 » » » » » » REPH_POS_AFTER_MAIN, REPH_MO DE_EXPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE}, 330 » » » » » » REPH_POS_AFTER_MAIN, REPH_M ODE_EXPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
330 {HB_SCRIPT_KHMER,» false,0x17D2,BASE_POS_FIRST,REPH_POS_DONT_CARE, REPH_MO DE_VIS_REPHA,BLWF_MODE_PRE_AND_POST, PREF_LEN_2}, 331 {HB_SCRIPT_KHMER,» false,0x17D2u,BASE_POS_FIRST,REPH_POS_DONT_CARE, REPH_M ODE_VIS_REPHA,BLWF_MODE_PRE_AND_POST, PREF_LEN_2},
331 {HB_SCRIPT_JAVANESE,» false,0xA9C0,BASE_POS_FIRST,REPH_POS_DONT_CARE, REPH_MO DE_VIS_REPHA,BLWF_MODE_PRE_AND_POST, PREF_LEN_1}, 332 {HB_SCRIPT_JAVANESE,» false,0xA9C0u,BASE_POS_FIRST,REPH_POS_DONT_CARE, REPH_M ODE_VIS_REPHA,BLWF_MODE_PRE_AND_POST, PREF_LEN_1},
332 }; 333 };
333 334
334 335
335 336
336 /* 337 /*
337 * Indic shaper. 338 * Indic shaper.
338 */ 339 */
339 340
340 struct feature_list_t { 341 struct feature_list_t {
341 hb_tag_t tag; 342 hb_tag_t tag;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (unlikely (!indic_plan)) 546 if (unlikely (!indic_plan))
546 return NULL; 547 return NULL;
547 548
548 indic_plan->config = &indic_configs[0]; 549 indic_plan->config = &indic_configs[0];
549 for (unsigned int i = 1; i < ARRAY_LENGTH (indic_configs); i++) 550 for (unsigned int i = 1; i < ARRAY_LENGTH (indic_configs); i++)
550 if (plan->props.script == indic_configs[i].script) { 551 if (plan->props.script == indic_configs[i].script) {
551 indic_plan->config = &indic_configs[i]; 552 indic_plan->config = &indic_configs[i];
552 break; 553 break;
553 } 554 }
554 555
555 indic_plan->is_old_spec = indic_plan->config->has_old_spec && ((plan->map.chos en_script[0] & 0x000000FF) != '2'); 556 indic_plan->is_old_spec = indic_plan->config->has_old_spec && ((plan->map.chos en_script[0] & 0x000000FFu) != '2');
556 indic_plan->virama_glyph = (hb_codepoint_t) -1; 557 indic_plan->virama_glyph = (hb_codepoint_t) -1;
557 558
558 /* Use zero-context would_substitute() matching for new-spec of the main 559 /* Use zero-context would_substitute() matching for new-spec of the main
559 * Indic scripts, but not for old-spec or scripts with one spec only. */ 560 * Indic scripts, and scripts with one spec only, but not for old-specs. */
560 bool zero_context = indic_plan->config->has_old_spec || !indic_plan->is_old_sp ec; 561 bool zero_context = !indic_plan->is_old_spec;
561 indic_plan->rphf.init (&plan->map, HB_TAG('r','p','h','f'), zero_context); 562 indic_plan->rphf.init (&plan->map, HB_TAG('r','p','h','f'), zero_context);
562 indic_plan->pref.init (&plan->map, HB_TAG('p','r','e','f'), zero_context); 563 indic_plan->pref.init (&plan->map, HB_TAG('p','r','e','f'), zero_context);
563 indic_plan->blwf.init (&plan->map, HB_TAG('b','l','w','f'), zero_context); 564 indic_plan->blwf.init (&plan->map, HB_TAG('b','l','w','f'), zero_context);
564 indic_plan->pstf.init (&plan->map, HB_TAG('p','s','t','f'), zero_context); 565 indic_plan->pstf.init (&plan->map, HB_TAG('p','s','t','f'), zero_context);
565 566
566 for (unsigned int i = 0; i < ARRAY_LENGTH (indic_plan->mask_array); i++) 567 for (unsigned int i = 0; i < ARRAY_LENGTH (indic_plan->mask_array); i++)
567 indic_plan->mask_array[i] = (indic_features[i].flags & F_GLOBAL) ? 568 indic_plan->mask_array[i] = (indic_features[i].flags & F_GLOBAL) ?
568 0 : plan->map.get_1_mask (indic_features[i].tag ); 569 0 : plan->map.get_1_mask (indic_features[i].tag );
569 570
570 return indic_plan; 571 return indic_plan;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 indic_plan->pref.would_substitute (glyphs+1, 1, face))) 608 indic_plan->pref.would_substitute (glyphs+1, 1, face)))
608 return POS_POST_C; 609 return POS_POST_C;
609 return POS_BASE_C; 610 return POS_BASE_C;
610 } 611 }
611 612
612 613
613 enum syllable_type_t { 614 enum syllable_type_t {
614 consonant_syllable, 615 consonant_syllable,
615 vowel_syllable, 616 vowel_syllable,
616 standalone_cluster, 617 standalone_cluster,
617 avagraha_cluster, 618 symbol_cluster,
618 broken_cluster, 619 broken_cluster,
619 non_indic_cluster, 620 non_indic_cluster,
620 }; 621 };
621 622
622 #include "hb-ot-shape-complex-indic-machine.hh" 623 #include "hb-ot-shape-complex-indic-machine.hh"
623 624
624 625
625 static void 626 static void
626 setup_masks_indic (const hb_ot_shape_plan_t *plan HB_UNUSED, 627 setup_masks_indic (const hb_ot_shape_plan_t *plan HB_UNUSED,
627 hb_buffer_t *buffer, 628 hb_buffer_t *buffer,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 unsigned int limit = start; 719 unsigned int limit = start;
719 if (indic_plan->config->reph_pos != REPH_POS_DONT_CARE && 720 if (indic_plan->config->reph_pos != REPH_POS_DONT_CARE &&
720 indic_plan->mask_array[RPHF] && 721 indic_plan->mask_array[RPHF] &&
721 start + 3 <= end && 722 start + 3 <= end &&
722 ( 723 (
723 (indic_plan->config->reph_mode == REPH_MODE_IMPLICIT && !is_joiner (inf o[start + 2])) || 724 (indic_plan->config->reph_mode == REPH_MODE_IMPLICIT && !is_joiner (inf o[start + 2])) ||
724 (indic_plan->config->reph_mode == REPH_MODE_EXPLICIT && info[start + 2] .indic_category() == OT_ZWJ) 725 (indic_plan->config->reph_mode == REPH_MODE_EXPLICIT && info[start + 2] .indic_category() == OT_ZWJ)
725 )) 726 ))
726 { 727 {
727 /* See if it matches the 'rphf' feature. */ 728 /* See if it matches the 'rphf' feature. */
728 hb_codepoint_t glyphs[2] = {info[start].codepoint, info[start + 1].codepoi nt}; 729 hb_codepoint_t glyphs[3] = {info[start].codepoint,
729 if (indic_plan->rphf.would_substitute (glyphs, ARRAY_LENGTH (glyphs), face )) 730 » » » » info[start + 1].codepoint,
731 » » » » indic_plan->config->reph_mode == REPH_MODE_EXP LICIT ?
732 » » » » info[start + 2].codepoint : 0};
733 if (indic_plan->rphf.would_substitute (glyphs, 2, face) ||
734 » (indic_plan->config->reph_mode == REPH_MODE_EXPLICIT &&
735 » indic_plan->rphf.would_substitute (glyphs, 3, face)))
730 { 736 {
731 limit += 2; 737 limit += 2;
732 while (limit < end && is_joiner (info[limit])) 738 while (limit < end && is_joiner (info[limit]))
733 limit++; 739 limit++;
734 base = start; 740 base = start;
735 has_reph = true; 741 has_reph = true;
736 } 742 }
737 } else if (indic_plan->config->reph_mode == REPH_MODE_LOG_REPHA && info[star t].indic_category() == OT_Repha) 743 } else if (indic_plan->config->reph_mode == REPH_MODE_LOG_REPHA && info[star t].indic_category() == OT_Repha)
738 { 744 {
739 limit += 1; 745 limit += 1;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 info[i - 1].indic_category() == OT_H) 800 info[i - 1].indic_category() == OT_H)
795 break; 801 break;
796 } 802 }
797 } while (i > limit); 803 } while (i > limit);
798 } 804 }
799 break; 805 break;
800 806
801 case BASE_POS_LAST_SINHALA: 807 case BASE_POS_LAST_SINHALA:
802 { 808 {
803 /* Sinhala base positioning is slightly different from main Indic, in th at: 809 /* Sinhala base positioning is slightly different from main Indic, in th at:
804 » * 1. It's ZWJ behavior is different, 810 » * 1. Its ZWJ behavior is different,
805 * 2. We don't need to look into the font for consonant positions. 811 * 2. We don't need to look into the font for consonant positions.
806 */ 812 */
807 813
808 if (!has_reph) 814 if (!has_reph)
809 base = limit; 815 base = limit;
810 816
811 /* Find the last base consonant that is not blocked by ZWJ. If there is 817 /* Find the last base consonant that is not blocked by ZWJ. If there is
812 * a ZWJ right before a base consonant, that would request a subjoined f orm. */ 818 * a ZWJ right before a base consonant, that would request a subjoined f orm. */
813 for (unsigned int i = limit; i < end; i++) 819 for (unsigned int i = limit; i < end; i++)
814 if (is_consonant (info[i])) 820 if (is_consonant (info[i]))
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 /* We made the vowels look like consonants. So let's call the consonant logic ! */ 1150 /* We made the vowels look like consonants. So let's call the consonant logic ! */
1145 initial_reordering_consonant_syllable (plan, face, buffer, start, end); 1151 initial_reordering_consonant_syllable (plan, face, buffer, start, end);
1146 } 1152 }
1147 1153
1148 static void 1154 static void
1149 initial_reordering_standalone_cluster (const hb_ot_shape_plan_t *plan, 1155 initial_reordering_standalone_cluster (const hb_ot_shape_plan_t *plan,
1150 hb_face_t *face, 1156 hb_face_t *face,
1151 hb_buffer_t *buffer, 1157 hb_buffer_t *buffer,
1152 unsigned int start, unsigned int end) 1158 unsigned int start, unsigned int end)
1153 { 1159 {
1154 /* We treat NBSP/dotted-circle as if they are consonants, so we should just ch ain. 1160 /* We treat placeholder/dotted-circle as if they are consonants, so we
1155 * Only if not in compatibility mode that is... */ 1161 * should just chain. Only if not in compatibility mode that is... */
1156 1162
1157 if (hb_options ().uniscribe_bug_compatible) 1163 if (hb_options ().uniscribe_bug_compatible)
1158 { 1164 {
1159 /* For dotted-circle, this is what Uniscribe does: 1165 /* For dotted-circle, this is what Uniscribe does:
1160 * If dotted-circle is the last glyph, it just does nothing. 1166 * If dotted-circle is the last glyph, it just does nothing.
1161 * Ie. It doesn't form Reph. */ 1167 * Ie. It doesn't form Reph. */
1162 if (buffer->info[end - 1].indic_category() == OT_DOTTEDCIRCLE) 1168 if (buffer->info[end - 1].indic_category() == OT_DOTTEDCIRCLE)
1163 return; 1169 return;
1164 } 1170 }
1165 1171
1166 initial_reordering_consonant_syllable (plan, face, buffer, start, end); 1172 initial_reordering_consonant_syllable (plan, face, buffer, start, end);
1167 } 1173 }
1168 1174
1169 static void 1175 static void
1170 initial_reordering_broken_cluster (const hb_ot_shape_plan_t *plan, 1176 initial_reordering_broken_cluster (const hb_ot_shape_plan_t *plan,
1171 hb_face_t *face, 1177 hb_face_t *face,
1172 hb_buffer_t *buffer, 1178 hb_buffer_t *buffer,
1173 unsigned int start, unsigned int end) 1179 unsigned int start, unsigned int end)
1174 { 1180 {
1175 /* We already inserted dotted-circles, so just call the standalone_cluster. */ 1181 /* We already inserted dotted-circles, so just call the standalone_cluster. */
1176 initial_reordering_standalone_cluster (plan, face, buffer, start, end); 1182 initial_reordering_standalone_cluster (plan, face, buffer, start, end);
1177 } 1183 }
1178 1184
1179 static void 1185 static void
1180 initial_reordering_avagraha_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED, 1186 initial_reordering_symbol_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED,
1181 » » » » hb_face_t *face HB_UNUSED, 1187 » » » » hb_face_t *face HB_UNUSED,
1182 » » » » hb_buffer_t *buffer HB_UNUSED, 1188 » » » » hb_buffer_t *buffer HB_UNUSED,
1183 » » » » unsigned int start HB_UNUSED, unsigned int end HB_UNUSED) 1189 » » » » unsigned int start HB_UNUSED, unsigned int en d HB_UNUSED)
1184 { 1190 {
1185 /* Nothing to do right now. If we ever switch to using the output 1191 /* Nothing to do right now. If we ever switch to using the output
1186 * buffer in the reordering process, we'd need to next_glyph() here. */ 1192 * buffer in the reordering process, we'd need to next_glyph() here. */
1187 } 1193 }
1188 1194
1189 static void 1195 static void
1190 initial_reordering_non_indic_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED, 1196 initial_reordering_non_indic_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED,
1191 hb_face_t *face HB_UNUSED, 1197 hb_face_t *face HB_UNUSED,
1192 hb_buffer_t *buffer HB_UNUSED, 1198 hb_buffer_t *buffer HB_UNUSED,
1193 unsigned int start HB_UNUSED, unsigned int end HB_UNUSED) 1199 unsigned int start HB_UNUSED, unsigned int end HB_UNUSED)
1194 { 1200 {
1195 /* Nothing to do right now. If we ever switch to using the output 1201 /* Nothing to do right now. If we ever switch to using the output
1196 * buffer in the reordering process, we'd need to next_glyph() here. */ 1202 * buffer in the reordering process, we'd need to next_glyph() here. */
1197 } 1203 }
1198 1204
1199 1205
1200 static void 1206 static void
1201 initial_reordering_syllable (const hb_ot_shape_plan_t *plan, 1207 initial_reordering_syllable (const hb_ot_shape_plan_t *plan,
1202 hb_face_t *face, 1208 hb_face_t *face,
1203 hb_buffer_t *buffer, 1209 hb_buffer_t *buffer,
1204 unsigned int start, unsigned int end) 1210 unsigned int start, unsigned int end)
1205 { 1211 {
1206 syllable_type_t syllable_type = (syllable_type_t) (buffer->info[start].syllabl e() & 0x0F); 1212 syllable_type_t syllable_type = (syllable_type_t) (buffer->info[start].syllabl e() & 0x0F);
1207 switch (syllable_type) { 1213 switch (syllable_type) {
1208 case consonant_syllable: initial_reordering_consonant_syllable (plan, fac e, buffer, start, end); return; 1214 case consonant_syllable: initial_reordering_consonant_syllable (plan, fac e, buffer, start, end); return;
1209 case vowel_syllable: initial_reordering_vowel_syllable (plan, fac e, buffer, start, end); return; 1215 case vowel_syllable: initial_reordering_vowel_syllable (plan, fac e, buffer, start, end); return;
1210 case standalone_cluster: initial_reordering_standalone_cluster (plan, fac e, buffer, start, end); return; 1216 case standalone_cluster: initial_reordering_standalone_cluster (plan, fac e, buffer, start, end); return;
1211 case avagraha_cluster:» initial_reordering_avagraha_cluster (plan, fac e, buffer, start, end); return; 1217 case symbol_cluster:» » initial_reordering_symbol_cluster (plan, fac e, buffer, start, end); return;
1212 case broken_cluster: initial_reordering_broken_cluster (plan, fac e, buffer, start, end); return; 1218 case broken_cluster: initial_reordering_broken_cluster (plan, fac e, buffer, start, end); return;
1213 case non_indic_cluster: initial_reordering_non_indic_cluster (plan, fac e, buffer, start, end); return; 1219 case non_indic_cluster: initial_reordering_non_indic_cluster (plan, fac e, buffer, start, end); return;
1214 } 1220 }
1215 } 1221 }
1216 1222
1217 static inline void 1223 static inline void
1218 insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, 1224 insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
1219 hb_font_t *font, 1225 hb_font_t *font,
1220 hb_buffer_t *buffer) 1226 hb_buffer_t *buffer)
1221 { 1227 {
1222 /* Note: This loop is extra overhead, but should not be measurable. */ 1228 /* Note: This loop is extra overhead, but should not be measurable. */
1223 bool has_broken_syllables = false; 1229 bool has_broken_syllables = false;
1224 unsigned int count = buffer->len; 1230 unsigned int count = buffer->len;
1225 for (unsigned int i = 0; i < count; i++) 1231 for (unsigned int i = 0; i < count; i++)
1226 if ((buffer->info[i].syllable() & 0x0F) == broken_cluster) { 1232 if ((buffer->info[i].syllable() & 0x0F) == broken_cluster) {
1227 has_broken_syllables = true; 1233 has_broken_syllables = true;
1228 break; 1234 break;
1229 } 1235 }
1230 if (likely (!has_broken_syllables)) 1236 if (likely (!has_broken_syllables))
1231 return; 1237 return;
1232 1238
1233 1239
1234 hb_codepoint_t dottedcircle_glyph; 1240 hb_codepoint_t dottedcircle_glyph;
1235 if (!font->get_glyph (0x25CC, 0, &dottedcircle_glyph)) 1241 if (!font->get_glyph (0x25CCu, 0, &dottedcircle_glyph))
1236 return; 1242 return;
1237 1243
1238 hb_glyph_info_t dottedcircle = {0}; 1244 hb_glyph_info_t dottedcircle = {0};
1239 dottedcircle.codepoint = 0x25CC; 1245 dottedcircle.codepoint = 0x25CCu;
1240 set_indic_properties (dottedcircle); 1246 set_indic_properties (dottedcircle);
1241 dottedcircle.codepoint = dottedcircle_glyph; 1247 dottedcircle.codepoint = dottedcircle_glyph;
1242 1248
1243 buffer->clear_output (); 1249 buffer->clear_output ();
1244 1250
1245 buffer->idx = 0; 1251 buffer->idx = 0;
1246 unsigned int last_syllable = 0; 1252 unsigned int last_syllable = 0;
1247 while (buffer->idx < buffer->len) 1253 while (buffer->idx < buffer->len)
1248 { 1254 {
1249 unsigned int syllable = buffer->cur().syllable(); 1255 unsigned int syllable = buffer->cur().syllable();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 } 1301 }
1296 1302
1297 static void 1303 static void
1298 final_reordering_syllable (const hb_ot_shape_plan_t *plan, 1304 final_reordering_syllable (const hb_ot_shape_plan_t *plan,
1299 hb_buffer_t *buffer, 1305 hb_buffer_t *buffer,
1300 unsigned int start, unsigned int end) 1306 unsigned int start, unsigned int end)
1301 { 1307 {
1302 const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) plan->data ; 1308 const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) plan->data ;
1303 hb_glyph_info_t *info = buffer->info; 1309 hb_glyph_info_t *info = buffer->info;
1304 1310
1311
1312 /* This function relies heavily on halant glyphs. Lots of ligation
1313 * and possibly multiplication substitutions happened prior to this
1314 * phase, and that might have messed up our properties. Recover
1315 * from a particular case of that where we're fairly sure that a
1316 * class of OT_H is desired but has been lost. */
1317 if (indic_plan->virama_glyph)
1318 {
1319 unsigned int virama_glyph = indic_plan->virama_glyph;
1320 for (unsigned int i = start; i < end; i++)
1321 if (info[i].codepoint == virama_glyph &&
1322 _hb_glyph_info_ligated (&info[i]) &&
1323 _hb_glyph_info_multiplied (&info[i]))
1324 {
1325 /* This will make sure that this glyph passes is_halant_or_coeng() test. */
1326 info[i].indic_category() = OT_H;
1327 _hb_glyph_info_clear_ligated_and_multiplied (&info[i]);
1328 }
1329 }
1330
1331
1305 /* 4. Final reordering: 1332 /* 4. Final reordering:
1306 * 1333 *
1307 * After the localized forms and basic shaping forms GSUB features have been 1334 * After the localized forms and basic shaping forms GSUB features have been
1308 * applied (see below), the shaping engine performs some final glyph 1335 * applied (see below), the shaping engine performs some final glyph
1309 * reordering before applying all the remaining font features to the entire 1336 * reordering before applying all the remaining font features to the entire
1310 * cluster. 1337 * cluster.
1311 */ 1338 */
1312 1339
1340 bool try_pref = !!indic_plan->mask_array[PREF];
1341
1313 /* Find base again */ 1342 /* Find base again */
1314 unsigned int base; 1343 unsigned int base;
1315 for (base = start; base < end; base++) 1344 for (base = start; base < end; base++)
1316 if (info[base].indic_position() >= POS_BASE_C) { 1345 if (info[base].indic_position() >= POS_BASE_C)
1346 {
1347 if (try_pref && base + 1 < end && indic_plan->config->pref_len == 2)
1348 {
1349 » for (unsigned int i = base + 1; i < end; i++)
1350 » if ((info[i].mask & indic_plan->mask_array[PREF]) != 0)
1351 » {
1352 » if (!(_hb_glyph_info_substituted (&info[i]) &&
1353 » » _hb_glyph_info_ligated_and_didnt_multiply (&info[i])))
1354 » {
1355 » /* Ok, this was a 'pref' candidate but didn't form any.
1356 » * Base is around here... */
1357 » base = i;
1358 » while (base < end && is_halant_or_coeng (info[base]))
1359 » » base++;
1360 » info[base].indic_position() = POS_BASE_C;
1361
1362 » try_pref = false;
1363 » }
1364 » break;
1365 » }
1366 }
1367
1317 if (start < base && info[base].indic_position() > POS_BASE_C) 1368 if (start < base && info[base].indic_position() > POS_BASE_C)
1318 base--; 1369 base--;
1319 break; 1370 break;
1320 } 1371 }
1321 if (base == end && start < base && 1372 if (base == end && start < base &&
1322 info[base - 1].indic_category() != OT_ZWJ) 1373 is_one_of (info[base - 1], FLAG (OT_ZWJ)))
1323 base--; 1374 base--;
1324 while (start < base && 1375 if (base < end)
1325 » (info[base].indic_category() == OT_H || 1376 while (start < base &&
1326 » info[base].indic_category() == OT_N)) 1377 » is_one_of (info[base], (FLAG (OT_N) | HALANT_OR_COENG_FLAGS)))
1327 base--; 1378 base--;
1328 1379
1329 1380
1330 /* o Reorder matras: 1381 /* o Reorder matras:
1331 * 1382 *
1332 * If a pre-base matra character had been reordered before applying basic 1383 * If a pre-base matra character had been reordered before applying basic
1333 * features, the glyph can be moved closer to the main consonant based on 1384 * features, the glyph can be moved closer to the main consonant based on
1334 * whether half-forms had been formed. Actual position for the matra is 1385 * whether half-forms had been formed. Actual position for the matra is
1335 * defined as “after last standalone halant glyph, after initial matra 1386 * defined as “after last standalone halant glyph, after initial matra
1336 * position and before the main consonant”. If ZWJ or ZWNJ follow this 1387 * position and before the main consonant”. If ZWJ or ZWNJ follow this
1337 * halant, position is moved after it. 1388 * halant, position is moved after it.
1338 */ 1389 */
1339 1390
1340 if (start + 1 < end && start < base) /* Otherwise there can't be any pre-base matra characters. */ 1391 if (start + 1 < end && start < base) /* Otherwise there can't be any pre-base matra characters. */
1341 { 1392 {
1342 /* If we lost track of base, alas, position before last thingy. */ 1393 /* If we lost track of base, alas, position before last thingy. */
1343 unsigned int new_pos = base == end ? base - 2 : base - 1; 1394 unsigned int new_pos = base == end ? base - 2 : base - 1;
1344 1395
1345 /* Malayalam / Tamil do not have "half" forms or explicit virama forms. 1396 /* Malayalam / Tamil do not have "half" forms or explicit virama forms.
1346 * The glyphs formed by 'half' are Chillus or ligated explicit viramas. 1397 * The glyphs formed by 'half' are Chillus or ligated explicit viramas.
1347 * We want to position matra after them. 1398 * We want to position matra after them.
1348 */ 1399 */
1349 if (buffer->props.script != HB_SCRIPT_MALAYALAM && buffer->props.script != H B_SCRIPT_TAMIL) 1400 if (buffer->props.script != HB_SCRIPT_MALAYALAM && buffer->props.script != H B_SCRIPT_TAMIL)
1350 { 1401 {
1351 while (new_pos > start && 1402 while (new_pos > start &&
1352 » !(is_one_of (info[new_pos], (FLAG (OT_M) | FLAG (OT_H) | FLAG (OT_C oeng))))) 1403 » !(is_one_of (info[new_pos], (FLAG (OT_M) | HALANT_OR_COENG_FLAGS))) )
1353 new_pos--; 1404 new_pos--;
1354 1405
1355 /* If we found no Halant we are done. 1406 /* If we found no Halant we are done.
1356 * Otherwise only proceed if the Halant does 1407 * Otherwise only proceed if the Halant does
1357 * not belong to the Matra itself! */ 1408 * not belong to the Matra itself! */
1358 if (is_halant_or_coeng (info[new_pos]) && 1409 if (is_halant_or_coeng (info[new_pos]) &&
1359 info[new_pos].indic_position() != POS_PRE_M) 1410 info[new_pos].indic_position() != POS_PRE_M)
1360 { 1411 {
1361 /* -> If ZWJ or ZWNJ follow this halant, position is moved after it. */ 1412 /* -> If ZWJ or ZWNJ follow this halant, position is moved after it. */
1362 if (new_pos + 1 < end && is_joiner (info[new_pos + 1])) 1413 if (new_pos + 1 < end && is_joiner (info[new_pos + 1]))
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 * - If repha is encoded as a sequence of characters (Ra,H or Ra,H,ZWJ), then 1456 * - If repha is encoded as a sequence of characters (Ra,H or Ra,H,ZWJ), then
1406 * we should only move it if the sequence ligated to the repha form. 1457 * we should only move it if the sequence ligated to the repha form.
1407 * 1458 *
1408 * - If repha is encoded separately and in the logical position, we should onl y 1459 * - If repha is encoded separately and in the logical position, we should onl y
1409 * move it if it did NOT ligate. If it ligated, it's probably the font tryi ng 1460 * move it if it did NOT ligate. If it ligated, it's probably the font tryi ng
1410 * to make it work without the reordering. 1461 * to make it work without the reordering.
1411 */ 1462 */
1412 if (start + 1 < end && 1463 if (start + 1 < end &&
1413 info[start].indic_position() == POS_RA_TO_BECOME_REPH && 1464 info[start].indic_position() == POS_RA_TO_BECOME_REPH &&
1414 ((info[start].indic_category() == OT_Repha) ^ 1465 ((info[start].indic_category() == OT_Repha) ^
1415 _hb_glyph_info_ligated (&info[start]))) 1466 _hb_glyph_info_ligated_and_didnt_multiply (&info[start])))
1416 { 1467 {
1417 unsigned int new_reph_pos; 1468 unsigned int new_reph_pos;
1418 reph_position_t reph_pos = indic_plan->config->reph_pos; 1469 reph_position_t reph_pos = indic_plan->config->reph_pos;
1419 1470
1420 assert (reph_pos != REPH_POS_DONT_CARE); 1471 assert (reph_pos != REPH_POS_DONT_CARE);
1421 1472
1422 /* 1. If reph should be positioned after post-base consonant forms, 1473 /* 1. If reph should be positioned after post-base consonant forms,
1423 * proceed to step 5. 1474 * proceed to step 5.
1424 */ 1475 */
1425 if (reph_pos == REPH_POS_AFTER_POST) 1476 if (reph_pos == REPH_POS_AFTER_POST)
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 } 1593 }
1543 } 1594 }
1544 1595
1545 1596
1546 /* o Reorder pre-base reordering consonants: 1597 /* o Reorder pre-base reordering consonants:
1547 * 1598 *
1548 * If a pre-base reordering consonant is found, reorder it according to 1599 * If a pre-base reordering consonant is found, reorder it according to
1549 * the following rules: 1600 * the following rules:
1550 */ 1601 */
1551 1602
1552 if (indic_plan->mask_array[PREF] && base + 1 < end) /* Otherwise there can't b e any pre-base reordering Ra. */ 1603 if (try_pref && base + 1 < end) /* Otherwise there can't be any pre-base reord ering Ra. */
1553 { 1604 {
1554 unsigned int pref_len = indic_plan->config->pref_len; 1605 unsigned int pref_len = indic_plan->config->pref_len;
1555 for (unsigned int i = base + 1; i < end; i++) 1606 for (unsigned int i = base + 1; i < end; i++)
1556 if ((info[i].mask & indic_plan->mask_array[PREF]) != 0) 1607 if ((info[i].mask & indic_plan->mask_array[PREF]) != 0)
1557 { 1608 {
1558 /* 1. Only reorder a glyph produced by substitution during applica tion 1609 /* 1. Only reorder a glyph produced by substitution during applica tion
1559 * of the <pref> feature. (Note that a font may shape a Ra cons onant with 1610 * of the <pref> feature. (Note that a font may shape a Ra cons onant with
1560 * the feature generally but block it in certain contexts.) 1611 * the feature generally but block it in certain contexts.)
1561 */ 1612 */
1562 /* Note: We just check that something got substituted. We don't check t hat 1613 /* Note: We just check that something got substituted. We don't check t hat
1563 * the <pref> feature actually did it... 1614 * the <pref> feature actually did it...
1564 * 1615 *
1565 * If pref len is longer than one, then only reorder if it ligated. If 1616 * If pref len is longer than one, then only reorder if it ligated. If
1566 * pref len is one, only reorder if it didn't ligate with other things. */ 1617 * pref len is one, only reorder if it didn't ligate with other things. */
1567 if (_hb_glyph_info_substituted (&info[i]) && 1618 if (_hb_glyph_info_substituted (&info[i]) &&
1568 » ((pref_len == 1) ^ _hb_glyph_info_ligated (&info[i]))) 1619 » ((pref_len == 1) ^ _hb_glyph_info_ligated_and_didnt_multiply (&info[ i])))
1569 { 1620 {
1570 /* 1621 /*
1571 * 2. Try to find a target position the same way as for pre-base matra. 1622 * 2. Try to find a target position the same way as for pre-base matra.
1572 * If it is found, reorder pre-base consonant glyph. 1623 * If it is found, reorder pre-base consonant glyph.
1573 * 1624 *
1574 * 3. If position is not found, reorder immediately before main 1625 * 3. If position is not found, reorder immediately before main
1575 * consonant. 1626 * consonant.
1576 */ 1627 */
1577 1628
1578 unsigned int new_pos = base; 1629 unsigned int new_pos = base;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 1743
1693 static bool 1744 static bool
1694 decompose_indic (const hb_ot_shape_normalize_context_t *c, 1745 decompose_indic (const hb_ot_shape_normalize_context_t *c,
1695 hb_codepoint_t ab, 1746 hb_codepoint_t ab,
1696 hb_codepoint_t *a, 1747 hb_codepoint_t *a,
1697 hb_codepoint_t *b) 1748 hb_codepoint_t *b)
1698 { 1749 {
1699 switch (ab) 1750 switch (ab)
1700 { 1751 {
1701 /* Don't decompose these. */ 1752 /* Don't decompose these. */
1702 case 0x0931 : return false; 1753 case 0x0931u : return false;
1703 case 0x0B94 : return false; 1754 case 0x0B94u : return false;
1704 1755
1705 1756
1706 /* 1757 /*
1707 * Decompose split matras that don't have Unicode decompositions. 1758 * Decompose split matras that don't have Unicode decompositions.
1708 */ 1759 */
1709 1760
1710 case 0x0F77 : *a = 0x0FB2; *b= 0x0F81; return true; 1761 case 0x0F77u : *a = 0x0FB2u; *b= 0x0F81u; return true;
1711 case 0x0F79 : *a = 0x0FB3; *b= 0x0F81; return true; 1762 case 0x0F79u : *a = 0x0FB3u; *b= 0x0F81u; return true;
1712 case 0x17BE : *a = 0x17C1; *b= 0x17BE; return true; 1763 case 0x17BEu : *a = 0x17C1u; *b= 0x17BEu; return true;
1713 case 0x17BF : *a = 0x17C1; *b= 0x17BF; return true; 1764 case 0x17BFu : *a = 0x17C1u; *b= 0x17BFu; return true;
1714 case 0x17C0 : *a = 0x17C1; *b= 0x17C0; return true; 1765 case 0x17C0u : *a = 0x17C1u; *b= 0x17C0u; return true;
1715 case 0x17C4 : *a = 0x17C1; *b= 0x17C4; return true; 1766 case 0x17C4u : *a = 0x17C1u; *b= 0x17C4u; return true;
1716 case 0x17C5 : *a = 0x17C1; *b= 0x17C5; return true; 1767 case 0x17C5u : *a = 0x17C1u; *b= 0x17C5u; return true;
1717 case 0x1925 : *a = 0x1920; *b= 0x1923; return true; 1768 case 0x1925u : *a = 0x1920u; *b= 0x1923u; return true;
1718 case 0x1926 : *a = 0x1920; *b= 0x1924; return true; 1769 case 0x1926u : *a = 0x1920u; *b= 0x1924u; return true;
1719 case 0x1B3C : *a = 0x1B42; *b= 0x1B3C; return true; 1770 case 0x1B3Cu : *a = 0x1B42u; *b= 0x1B3Cu; return true;
1720 case 0x1112E : *a = 0x11127; *b= 0x11131; return true; 1771 case 0x1112Eu : *a = 0x11127u; *b= 0x11131u; return true;
1721 case 0x1112F : *a = 0x11127; *b= 0x11132; return true; 1772 case 0x1112Fu : *a = 0x11127u; *b= 0x11132u; return true;
1722 #if 0 1773 #if 0
1723 /* This one has no decomposition in Unicode, but needs no decomposition eith er. */ 1774 /* This one has no decomposition in Unicode, but needs no decomposition eith er. */
1724 /* case 0x0AC9 : return false; */ 1775 /* case 0x0AC9u : return false; */
1725 case 0x0B57 : *a = no decomp, -> RIGHT; return true; 1776 case 0x0B57u : *a = no decomp, -> RIGHT; return true;
1726 case 0x1C29 : *a = no decomp, -> LEFT; return true; 1777 case 0x1C29u : *a = no decomp, -> LEFT; return true;
1727 case 0xA9C0 : *a = no decomp, -> RIGHT; return true; 1778 case 0xA9C0u : *a = no decomp, -> RIGHT; return true;
1728 case 0x111BF : *a = no decomp, -> ABOVE; return true; 1779 case 0x111BuF : *a = no decomp, -> ABOVE; return true;
1729 #endif 1780 #endif
1730 } 1781 }
1731 1782
1732 if ((ab == 0x0DDA || hb_in_range<hb_codepoint_t> (ab, 0x0DDC, 0x0DDE))) 1783 if ((ab == 0x0DDAu || hb_in_range (ab, 0x0DDCu, 0x0DDEu)))
1733 { 1784 {
1734 /* 1785 /*
1735 * Sinhala split matras... Let the fun begin. 1786 * Sinhala split matras... Let the fun begin.
1736 * 1787 *
1737 * These four characters have Unicode decompositions. However, Uniscribe 1788 * These four characters have Unicode decompositions. However, Uniscribe
1738 * decomposes them "Khmer-style", that is, it uses the character itself to 1789 * decomposes them "Khmer-style", that is, it uses the character itself to
1739 * get the second half. The first half of all four decompositions is always 1790 * get the second half. The first half of all four decompositions is always
1740 * U+0DD9. 1791 * U+0DD9.
1741 * 1792 *
1742 * Now, there are buggy fonts, namely, the widely used lklug.ttf, that are 1793 * Now, there are buggy fonts, namely, the widely used lklug.ttf, that are
(...skipping 16 matching lines...) Expand all
1759 1810
1760 const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) c->plan- >data; 1811 const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) c->plan- >data;
1761 1812
1762 hb_codepoint_t glyph; 1813 hb_codepoint_t glyph;
1763 1814
1764 if (hb_options ().uniscribe_bug_compatible || 1815 if (hb_options ().uniscribe_bug_compatible ||
1765 (c->font->get_glyph (ab, 0, &glyph) && 1816 (c->font->get_glyph (ab, 0, &glyph) &&
1766 indic_plan->pstf.would_substitute (&glyph, 1, c->font->face))) 1817 indic_plan->pstf.would_substitute (&glyph, 1, c->font->face)))
1767 { 1818 {
1768 /* Ok, safe to use Uniscribe-style decomposition. */ 1819 /* Ok, safe to use Uniscribe-style decomposition. */
1769 *a = 0x0DD9; 1820 *a = 0x0DD9u;
1770 *b = ab; 1821 *b = ab;
1771 return true; 1822 return true;
1772 } 1823 }
1773 } 1824 }
1774 1825
1775 return c->unicode->decompose (ab, a, b); 1826 return c->unicode->decompose (ab, a, b);
1776 } 1827 }
1777 1828
1778 static bool 1829 static bool
1779 compose_indic (const hb_ot_shape_normalize_context_t *c, 1830 compose_indic (const hb_ot_shape_normalize_context_t *c,
1780 hb_codepoint_t a, 1831 hb_codepoint_t a,
1781 hb_codepoint_t b, 1832 hb_codepoint_t b,
1782 hb_codepoint_t *ab) 1833 hb_codepoint_t *ab)
1783 { 1834 {
1784 /* Avoid recomposing split matras. */ 1835 /* Avoid recomposing split matras. */
1785 if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (c->unicode->general_category (a))) 1836 if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (c->unicode->general_category (a)))
1786 return false; 1837 return false;
1787 1838
1788 /* Composition-exclusion exceptions that we want to recompose. */ 1839 /* Composition-exclusion exceptions that we want to recompose. */
1789 if (a == 0x09AF && b == 0x09BC) { *ab = 0x09DF; return true; } 1840 if (a == 0x09AFu && b == 0x09BCu) { *ab = 0x09DFu; return true; }
1790 1841
1791 return c->unicode->compose (a, b, ab); 1842 return c->unicode->compose (a, b, ab);
1792 } 1843 }
1793 1844
1794 1845
1795 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic = 1846 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic =
1796 { 1847 {
1797 "indic", 1848 "indic",
1798 collect_features_indic, 1849 collect_features_indic,
1799 override_features_indic, 1850 override_features_indic,
1800 data_create_indic, 1851 data_create_indic,
1801 data_destroy_indic, 1852 data_destroy_indic,
1802 NULL, /* preprocess_text */ 1853 NULL, /* preprocess_text */
1803 HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, 1854 HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT,
1804 decompose_indic, 1855 decompose_indic,
1805 compose_indic, 1856 compose_indic,
1806 setup_masks_indic, 1857 setup_masks_indic,
1807 HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, 1858 HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
1808 false, /* fallback_position */ 1859 false, /* fallback_position */
1809 }; 1860 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698