1 | // WARNING: this file was generated by ../scripts/gen-vowel-constraints.py |
2 | |
3 | use crate::buffer::{Buffer, BufferFlags}; |
4 | use crate::script; |
5 | |
6 | fn output_dotted_circle(buffer: &mut Buffer) { |
7 | buffer.output_glyph(glyph_index:0x25CC); |
8 | { |
9 | let out_idx: usize = buffer.out_len - 1; |
10 | buffer.out_info_mut()[out_idx].reset_continuation(); |
11 | } |
12 | } |
13 | |
14 | fn output_with_dotted_circle(buffer: &mut Buffer) { |
15 | output_dotted_circle(buffer); |
16 | buffer.next_glyph(); |
17 | } |
18 | |
19 | pub fn preprocess_text_vowel_constraints(buffer: &mut Buffer) { |
20 | if buffer |
21 | .flags |
22 | .contains(BufferFlags::DO_NOT_INSERT_DOTTED_CIRCLE) |
23 | { |
24 | return; |
25 | } |
26 | |
27 | // UGLY UGLY UGLY business of adding dotted-circle in the middle of |
28 | // vowel-sequences that look like another vowel. Data for each script |
29 | // collected from the USE script development spec. |
30 | // |
31 | // https://github.com/harfbuzz/harfbuzz/issues/1019 |
32 | buffer.clear_output(); |
33 | match buffer.script { |
34 | Some(script::DEVANAGARI) => { |
35 | buffer.idx = 0; |
36 | while buffer.idx + 1 < buffer.len { |
37 | #[allow (unused_mut)] |
38 | let mut matched = false; |
39 | match buffer.cur(0).glyph_id { |
40 | 0x0905 => match buffer.cur(1).glyph_id { |
41 | 0x093A | 0x093B | 0x093E | 0x0945 | 0x0946 | 0x0949 | 0x094A | 0x094B |
42 | | 0x094C | 0x094F | 0x0956 | 0x0957 => { |
43 | matched = true; |
44 | } |
45 | _ => {} |
46 | }, |
47 | 0x0906 => match buffer.cur(1).glyph_id { |
48 | 0x093A | 0x0945 | 0x0946 | 0x0947 | 0x0948 => { |
49 | matched = true; |
50 | } |
51 | _ => {} |
52 | }, |
53 | 0x0909 => { |
54 | matched = 0x0941 == buffer.cur(1).glyph_id; |
55 | } |
56 | 0x090F => match buffer.cur(1).glyph_id { |
57 | 0x0945 | 0x0946 | 0x0947 => { |
58 | matched = true; |
59 | } |
60 | _ => {} |
61 | }, |
62 | 0x0930 => { |
63 | if 0x094D == buffer.cur(1).glyph_id |
64 | && buffer.idx + 2 < buffer.len |
65 | && 0x0907 == buffer.cur(2).glyph_id |
66 | { |
67 | buffer.next_glyph(); |
68 | buffer.next_glyph(); |
69 | output_dotted_circle(buffer); |
70 | } |
71 | } |
72 | _ => {} |
73 | } |
74 | buffer.next_glyph(); |
75 | if matched { |
76 | output_with_dotted_circle(buffer); |
77 | } |
78 | } |
79 | } |
80 | |
81 | Some(script::BENGALI) => { |
82 | buffer.idx = 0; |
83 | while buffer.idx + 1 < buffer.len { |
84 | #[allow (unused_mut)] |
85 | let mut matched = false; |
86 | match buffer.cur(0).glyph_id { |
87 | 0x0985 => { |
88 | matched = 0x09BE == buffer.cur(1).glyph_id; |
89 | } |
90 | 0x098B => { |
91 | matched = 0x09C3 == buffer.cur(1).glyph_id; |
92 | } |
93 | 0x098C => { |
94 | matched = 0x09E2 == buffer.cur(1).glyph_id; |
95 | } |
96 | _ => {} |
97 | } |
98 | buffer.next_glyph(); |
99 | if matched { |
100 | output_with_dotted_circle(buffer); |
101 | } |
102 | } |
103 | } |
104 | |
105 | Some(script::GURMUKHI) => { |
106 | buffer.idx = 0; |
107 | while buffer.idx + 1 < buffer.len { |
108 | #[allow (unused_mut)] |
109 | let mut matched = false; |
110 | match buffer.cur(0).glyph_id { |
111 | 0x0A05 => match buffer.cur(1).glyph_id { |
112 | 0x0A3E | 0x0A48 | 0x0A4C => { |
113 | matched = true; |
114 | } |
115 | _ => {} |
116 | }, |
117 | 0x0A72 => match buffer.cur(1).glyph_id { |
118 | 0x0A3F | 0x0A40 | 0x0A47 => { |
119 | matched = true; |
120 | } |
121 | _ => {} |
122 | }, |
123 | 0x0A73 => match buffer.cur(1).glyph_id { |
124 | 0x0A41 | 0x0A42 | 0x0A4B => { |
125 | matched = true; |
126 | } |
127 | _ => {} |
128 | }, |
129 | _ => {} |
130 | } |
131 | buffer.next_glyph(); |
132 | if matched { |
133 | output_with_dotted_circle(buffer); |
134 | } |
135 | } |
136 | } |
137 | |
138 | Some(script::GUJARATI) => { |
139 | buffer.idx = 0; |
140 | while buffer.idx + 1 < buffer.len { |
141 | #[allow (unused_mut)] |
142 | let mut matched = false; |
143 | match buffer.cur(0).glyph_id { |
144 | 0x0A85 => match buffer.cur(1).glyph_id { |
145 | 0x0ABE | 0x0AC5 | 0x0AC7 | 0x0AC8 | 0x0AC9 | 0x0ACB | 0x0ACC => { |
146 | matched = true; |
147 | } |
148 | _ => {} |
149 | }, |
150 | 0x0AC5 => { |
151 | matched = 0x0ABE == buffer.cur(1).glyph_id; |
152 | } |
153 | _ => {} |
154 | } |
155 | buffer.next_glyph(); |
156 | if matched { |
157 | output_with_dotted_circle(buffer); |
158 | } |
159 | } |
160 | } |
161 | |
162 | Some(script::ORIYA) => { |
163 | buffer.idx = 0; |
164 | while buffer.idx + 1 < buffer.len { |
165 | #[allow (unused_mut)] |
166 | let mut matched = false; |
167 | match buffer.cur(0).glyph_id { |
168 | 0x0B05 => { |
169 | matched = 0x0B3E == buffer.cur(1).glyph_id; |
170 | } |
171 | 0x0B0F | 0x0B13 => { |
172 | matched = 0x0B57 == buffer.cur(1).glyph_id; |
173 | } |
174 | _ => {} |
175 | } |
176 | buffer.next_glyph(); |
177 | if matched { |
178 | output_with_dotted_circle(buffer); |
179 | } |
180 | } |
181 | } |
182 | |
183 | Some(script::TAMIL) => { |
184 | buffer.idx = 0; |
185 | while buffer.idx + 1 < buffer.len { |
186 | #[allow (unused_mut)] |
187 | let mut matched = false; |
188 | if 0x0B85 == buffer.cur(0).glyph_id && 0x0BC2 == buffer.cur(1).glyph_id { |
189 | buffer.next_glyph(); |
190 | output_dotted_circle(buffer); |
191 | } |
192 | buffer.next_glyph(); |
193 | if matched { |
194 | output_with_dotted_circle(buffer); |
195 | } |
196 | } |
197 | } |
198 | |
199 | Some(script::TELUGU) => { |
200 | buffer.idx = 0; |
201 | while buffer.idx + 1 < buffer.len { |
202 | #[allow (unused_mut)] |
203 | let mut matched = false; |
204 | match buffer.cur(0).glyph_id { |
205 | 0x0C12 => match buffer.cur(1).glyph_id { |
206 | 0x0C4C | 0x0C55 => { |
207 | matched = true; |
208 | } |
209 | _ => {} |
210 | }, |
211 | 0x0C3F | 0x0C46 | 0x0C4A => { |
212 | matched = 0x0C55 == buffer.cur(1).glyph_id; |
213 | } |
214 | _ => {} |
215 | } |
216 | buffer.next_glyph(); |
217 | if matched { |
218 | output_with_dotted_circle(buffer); |
219 | } |
220 | } |
221 | } |
222 | |
223 | Some(script::KANNADA) => { |
224 | buffer.idx = 0; |
225 | while buffer.idx + 1 < buffer.len { |
226 | #[allow (unused_mut)] |
227 | let mut matched = false; |
228 | match buffer.cur(0).glyph_id { |
229 | 0x0C89 | 0x0C8B => { |
230 | matched = 0x0CBE == buffer.cur(1).glyph_id; |
231 | } |
232 | 0x0C92 => { |
233 | matched = 0x0CCC == buffer.cur(1).glyph_id; |
234 | } |
235 | _ => {} |
236 | } |
237 | buffer.next_glyph(); |
238 | if matched { |
239 | output_with_dotted_circle(buffer); |
240 | } |
241 | } |
242 | } |
243 | |
244 | Some(script::MALAYALAM) => { |
245 | buffer.idx = 0; |
246 | while buffer.idx + 1 < buffer.len { |
247 | #[allow (unused_mut)] |
248 | let mut matched = false; |
249 | match buffer.cur(0).glyph_id { |
250 | 0x0D07 | 0x0D09 => { |
251 | matched = 0x0D57 == buffer.cur(1).glyph_id; |
252 | } |
253 | 0x0D0E => { |
254 | matched = 0x0D46 == buffer.cur(1).glyph_id; |
255 | } |
256 | 0x0D12 => match buffer.cur(1).glyph_id { |
257 | 0x0D3E | 0x0D57 => { |
258 | matched = true; |
259 | } |
260 | _ => {} |
261 | }, |
262 | _ => {} |
263 | } |
264 | buffer.next_glyph(); |
265 | if matched { |
266 | output_with_dotted_circle(buffer); |
267 | } |
268 | } |
269 | } |
270 | |
271 | Some(script::SINHALA) => { |
272 | buffer.idx = 0; |
273 | while buffer.idx + 1 < buffer.len { |
274 | #[allow (unused_mut)] |
275 | let mut matched = false; |
276 | match buffer.cur(0).glyph_id { |
277 | 0x0D85 => match buffer.cur(1).glyph_id { |
278 | 0x0DCF | 0x0DD0 | 0x0DD1 => { |
279 | matched = true; |
280 | } |
281 | _ => {} |
282 | }, |
283 | 0x0D8B | 0x0D8F | 0x0D94 => { |
284 | matched = 0x0DDF == buffer.cur(1).glyph_id; |
285 | } |
286 | 0x0D8D => { |
287 | matched = 0x0DD8 == buffer.cur(1).glyph_id; |
288 | } |
289 | 0x0D91 => match buffer.cur(1).glyph_id { |
290 | 0x0DCA | 0x0DD9 | 0x0DDA | 0x0DDC | 0x0DDD | 0x0DDE => { |
291 | matched = true; |
292 | } |
293 | _ => {} |
294 | }, |
295 | _ => {} |
296 | } |
297 | buffer.next_glyph(); |
298 | if matched { |
299 | output_with_dotted_circle(buffer); |
300 | } |
301 | } |
302 | } |
303 | |
304 | Some(script::BRAHMI) => { |
305 | buffer.idx = 0; |
306 | while buffer.idx + 1 < buffer.len { |
307 | #[allow (unused_mut)] |
308 | let mut matched = false; |
309 | match buffer.cur(0).glyph_id { |
310 | 0x11005 => { |
311 | matched = 0x11038 == buffer.cur(1).glyph_id; |
312 | } |
313 | 0x1100B => { |
314 | matched = 0x1103E == buffer.cur(1).glyph_id; |
315 | } |
316 | 0x1100F => { |
317 | matched = 0x11042 == buffer.cur(1).glyph_id; |
318 | } |
319 | _ => {} |
320 | } |
321 | buffer.next_glyph(); |
322 | if matched { |
323 | output_with_dotted_circle(buffer); |
324 | } |
325 | } |
326 | } |
327 | |
328 | Some(script::KHUDAWADI) => { |
329 | buffer.idx = 0; |
330 | while buffer.idx + 1 < buffer.len { |
331 | #[allow (unused_mut)] |
332 | let mut matched = false; |
333 | match buffer.cur(0).glyph_id { |
334 | 0x112B0 => match buffer.cur(1).glyph_id { |
335 | 0x112E0 | 0x112E5 | 0x112E6 | 0x112E7 | 0x112E8 => { |
336 | matched = true; |
337 | } |
338 | _ => {} |
339 | }, |
340 | _ => {} |
341 | } |
342 | buffer.next_glyph(); |
343 | if matched { |
344 | output_with_dotted_circle(buffer); |
345 | } |
346 | } |
347 | } |
348 | |
349 | Some(script::TIRHUTA) => { |
350 | buffer.idx = 0; |
351 | while buffer.idx + 1 < buffer.len { |
352 | #[allow (unused_mut)] |
353 | let mut matched = false; |
354 | match buffer.cur(0).glyph_id { |
355 | 0x11481 => { |
356 | matched = 0x114B0 == buffer.cur(1).glyph_id; |
357 | } |
358 | 0x1148B | 0x1148D => { |
359 | matched = 0x114BA == buffer.cur(1).glyph_id; |
360 | } |
361 | 0x114AA => match buffer.cur(1).glyph_id { |
362 | 0x114B5 | 0x114B6 => { |
363 | matched = true; |
364 | } |
365 | _ => {} |
366 | }, |
367 | _ => {} |
368 | } |
369 | buffer.next_glyph(); |
370 | if matched { |
371 | output_with_dotted_circle(buffer); |
372 | } |
373 | } |
374 | } |
375 | |
376 | Some(script::MODI) => { |
377 | buffer.idx = 0; |
378 | while buffer.idx + 1 < buffer.len { |
379 | #[allow (unused_mut)] |
380 | let mut matched = false; |
381 | match buffer.cur(0).glyph_id { |
382 | 0x11600 | 0x11601 => match buffer.cur(1).glyph_id { |
383 | 0x11639 | 0x1163A => { |
384 | matched = true; |
385 | } |
386 | _ => {} |
387 | }, |
388 | _ => {} |
389 | } |
390 | buffer.next_glyph(); |
391 | if matched { |
392 | output_with_dotted_circle(buffer); |
393 | } |
394 | } |
395 | } |
396 | |
397 | Some(script::TAKRI) => { |
398 | buffer.idx = 0; |
399 | while buffer.idx + 1 < buffer.len { |
400 | #[allow (unused_mut)] |
401 | let mut matched = false; |
402 | match buffer.cur(0).glyph_id { |
403 | 0x11680 => match buffer.cur(1).glyph_id { |
404 | 0x116AD | 0x116B4 | 0x116B5 => { |
405 | matched = true; |
406 | } |
407 | _ => {} |
408 | }, |
409 | 0x11686 => { |
410 | matched = 0x116B2 == buffer.cur(1).glyph_id; |
411 | } |
412 | _ => {} |
413 | } |
414 | buffer.next_glyph(); |
415 | if matched { |
416 | output_with_dotted_circle(buffer); |
417 | } |
418 | } |
419 | } |
420 | |
421 | _ => {} |
422 | } |
423 | buffer.sync(); |
424 | } |
425 | |