blob: 00368d8e47406418c97db3df8e5b336b82b616dd [file] [log] [blame]
Behdad Esfahbod98628ca2013-02-11 13:36:23 -05001/*
2 * Copyright © 2011,2012,2013 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
Behdad Esfahbodf9b66052013-02-12 16:13:56 -050027#include "hb-ot-shape-complex-indic-private.hh"
Behdad Esfahbod98628ca2013-02-11 13:36:23 -050028
29/* buffer var allocations */
30#define myanmar_category() complex_var_u8_0() /* myanmar_category_t */
Behdad Esfahbod3a83d332013-02-12 12:14:10 -050031#define myanmar_position() complex_var_u8_1() /* myanmar_position_t */
Behdad Esfahbod98628ca2013-02-11 13:36:23 -050032
33
34/*
35 * Myanmar shaper.
36 */
37
38static const hb_tag_t
Behdad Esfahbodee9c3a12013-02-15 06:22:26 -050039basic_features[] =
Behdad Esfahbod98628ca2013-02-11 13:36:23 -050040{
41 /*
42 * Basic features.
43 * These features are applied in order, one at a time, after initial_reordering.
44 */
45 HB_TAG('r','p','h','f'),
46 HB_TAG('p','r','e','f'),
47 HB_TAG('b','l','w','f'),
48 HB_TAG('p','s','t','f'),
Behdad Esfahbodee9c3a12013-02-15 06:22:26 -050049};
50static const hb_tag_t
51other_features[] =
52{
Behdad Esfahbod98628ca2013-02-11 13:36:23 -050053 /*
54 * Other features.
55 * These features are applied all at once, after final_reordering.
56 */
57 HB_TAG('p','r','e','s'),
58 HB_TAG('a','b','v','s'),
59 HB_TAG('b','l','w','s'),
60 HB_TAG('p','s','t','s'),
61 /* Positioning features, though we don't care about the types. */
62 HB_TAG('d','i','s','t'),
Behdad Esfahbod5e7432b2013-10-15 12:28:23 +020063 /* Pre-release version of Windows 8 Myanmar font had abvm,blwm
64 * features. The released Windows 8 version of the font (as well
65 * as the released spec) used 'mark' instead. The Windows 8
66 * shaper however didn't apply 'mark' but did apply 'mkmk'.
67 * Perhaps it applied abvm/blwm. This was fixed in a Windows 8
68 * update, so now it applies mark/mkmk. We are guessing that
69 * it still applies abvm/blwm too.
70 */
71 HB_TAG('a','b','v','m'),
72 HB_TAG('b','l','w','m'),
Behdad Esfahbod98628ca2013-02-11 13:36:23 -050073};
74
Behdad Esfahbod98628ca2013-02-11 13:36:23 -050075static void
76setup_syllables (const hb_ot_shape_plan_t *plan,
77 hb_font_t *font,
78 hb_buffer_t *buffer);
79static void
80initial_reordering (const hb_ot_shape_plan_t *plan,
81 hb_font_t *font,
82 hb_buffer_t *buffer);
83static void
84final_reordering (const hb_ot_shape_plan_t *plan,
85 hb_font_t *font,
86 hb_buffer_t *buffer);
87
88static void
89collect_features_myanmar (hb_ot_shape_planner_t *plan)
90{
91 hb_ot_map_builder_t *map = &plan->map;
92
93 /* Do this before any lookups have been applied. */
94 map->add_gsub_pause (setup_syllables);
95
Behdad Esfahbode7ffcfa2013-02-14 11:05:56 -050096 map->add_global_bool_feature (HB_TAG('l','o','c','l'));
Behdad Esfahbod98628ca2013-02-11 13:36:23 -050097 /* The Indic specs do not require ccmp, but we apply it here since if
98 * there is a use of it, it's typically at the beginning. */
Behdad Esfahbode7ffcfa2013-02-14 11:05:56 -050099 map->add_global_bool_feature (HB_TAG('c','c','m','p'));
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500100
101
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500102 map->add_gsub_pause (initial_reordering);
Behdad Esfahbodee9c3a12013-02-15 06:22:26 -0500103 for (unsigned int i = 0; i < ARRAY_LENGTH (basic_features); i++)
104 {
Behdad Esfahboda8cf7b42013-03-19 05:53:26 -0400105 map->add_feature (basic_features[i], 1, F_GLOBAL | F_MANUAL_ZWJ);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500106 map->add_gsub_pause (NULL);
107 }
108 map->add_gsub_pause (final_reordering);
Behdad Esfahbodee9c3a12013-02-15 06:22:26 -0500109 for (unsigned int i = 0; i < ARRAY_LENGTH (other_features); i++)
Behdad Esfahboda8cf7b42013-03-19 05:53:26 -0400110 map->add_feature (other_features[i], 1, F_GLOBAL | F_MANUAL_ZWJ);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500111}
112
113static void
114override_features_myanmar (hb_ot_shape_planner_t *plan)
115{
Behdad Esfahbodec544862013-02-14 11:25:10 -0500116 plan->map.add_feature (HB_TAG('l','i','g','a'), 0, F_GLOBAL);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500117}
118
119
120enum syllable_type_t {
121 consonant_syllable,
Behdad Esfahbod9174a9d2013-11-25 18:10:38 -0500122 punctuation_cluster,
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500123 broken_cluster,
124 non_myanmar_cluster,
125};
126
127#include "hb-ot-shape-complex-myanmar-machine.hh"
128
129
130/* Note: This enum is duplicated in the -machine.rl source file.
131 * Not sure how to avoid duplication. */
132enum myanmar_category_t {
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500133 OT_As = 18, /* Asat */
134 OT_D = 19, /* Digits except zero */
135 OT_D0 = 20, /* Digit zero */
136 OT_DB = OT_N, /* Dot below */
Behdad Esfahbodcf78dd42014-05-27 17:53:37 -0400137 OT_GB = OT_PLACEHOLDER,
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500138 OT_MH = 21, /* Various consonant medial types */
139 OT_MR = 22, /* Various consonant medial types */
140 OT_MW = 23, /* Various consonant medial types */
141 OT_MY = 24, /* Various consonant medial types */
142 OT_PT = 25, /* Pwo and other tones */
143 OT_VAbv = 26,
144 OT_VBlw = 27,
145 OT_VPre = 28,
146 OT_VPst = 29,
Behdad Esfahbod9174a9d2013-11-25 18:10:38 -0500147 OT_VS = 30, /* Variation selectors */
148 OT_P = 31 /* Punctuation */
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500149};
150
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500151
152static inline bool
153is_one_of (const hb_glyph_info_t &info, unsigned int flags)
154{
155 /* If it ligated, all bets are off. */
Behdad Esfahboda1f7b282013-10-18 01:09:08 +0200156 if (_hb_glyph_info_ligated (&info)) return false;
Behdad Esfahbodf8160a42015-07-21 15:50:02 +0100157 return !!(FLAG_SAFE (info.myanmar_category()) & flags);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500158}
159
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500160static inline bool
161is_consonant (const hb_glyph_info_t &info)
162{
163 return is_one_of (info, CONSONANT_FLAGS);
164}
165
166
167static inline void
168set_myanmar_properties (hb_glyph_info_t &info)
169{
170 hb_codepoint_t u = info.codepoint;
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500171 unsigned int type = hb_indic_get_categories (u);
Behdad Esfahbod76271002014-07-11 14:54:42 -0400172 indic_category_t cat = (indic_category_t) (type & 0x7Fu);
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500173 indic_position_t pos = (indic_position_t) (type >> 8);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500174
175 /* Myanmar
176 * http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm#analyze
177 */
Behdad Esfahbod76271002014-07-11 14:54:42 -0400178 if (unlikely (hb_in_range (u, 0xFE00u, 0xFE0Fu)))
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500179 cat = (indic_category_t) OT_VS;
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500180
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500181 switch (u)
182 {
Behdad Esfahbod76271002014-07-11 14:54:42 -0400183 case 0x104Eu:
Behdad Esfahbod096b71e2013-11-25 18:03:34 -0500184 cat = (indic_category_t) OT_C; /* The spec says C, IndicSyllableCategory doesn't have. */
185 break;
186
Behdad Esfahbod76271002014-07-11 14:54:42 -0400187 case 0x002Du: case 0x00A0u: case 0x00D7u: case 0x2012u:
188 case 0x2013u: case 0x2014u: case 0x2015u: case 0x2022u:
189 case 0x25CCu: case 0x25FBu: case 0x25FCu: case 0x25FDu:
190 case 0x25FEu:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500191 cat = (indic_category_t) OT_GB;
Behdad Esfahbod0572c142013-02-11 16:06:02 -0500192 break;
193
Behdad Esfahbod76271002014-07-11 14:54:42 -0400194 case 0x1004u: case 0x101Bu: case 0x105Au:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500195 cat = (indic_category_t) OT_Ra;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500196 break;
197
Behdad Esfahbod76271002014-07-11 14:54:42 -0400198 case 0x1032u: case 0x1036u:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500199 cat = (indic_category_t) OT_A;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500200 break;
201
Behdad Esfahbod76271002014-07-11 14:54:42 -0400202 case 0x103Au:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500203 cat = (indic_category_t) OT_As;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500204 break;
205
Behdad Esfahbod76271002014-07-11 14:54:42 -0400206 case 0x1041u: case 0x1042u: case 0x1043u: case 0x1044u:
207 case 0x1045u: case 0x1046u: case 0x1047u: case 0x1048u:
208 case 0x1049u: case 0x1090u: case 0x1091u: case 0x1092u:
209 case 0x1093u: case 0x1094u: case 0x1095u: case 0x1096u:
210 case 0x1097u: case 0x1098u: case 0x1099u:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500211 cat = (indic_category_t) OT_D;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500212 break;
213
Behdad Esfahbod76271002014-07-11 14:54:42 -0400214 case 0x1040u:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500215 cat = (indic_category_t) OT_D; /* XXX The spec says D0, but Uniscribe doesn't seem to do. */
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500216 break;
217
Behdad Esfahbod76271002014-07-11 14:54:42 -0400218 case 0x103Eu: case 0x1060u:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500219 cat = (indic_category_t) OT_MH;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500220 break;
221
Behdad Esfahbod76271002014-07-11 14:54:42 -0400222 case 0x103Cu:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500223 cat = (indic_category_t) OT_MR;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500224 break;
225
Behdad Esfahbod76271002014-07-11 14:54:42 -0400226 case 0x103Du: case 0x1082u:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500227 cat = (indic_category_t) OT_MW;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500228 break;
229
Behdad Esfahbod76271002014-07-11 14:54:42 -0400230 case 0x103Bu: case 0x105Eu: case 0x105Fu:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500231 cat = (indic_category_t) OT_MY;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500232 break;
233
Behdad Esfahbod76271002014-07-11 14:54:42 -0400234 case 0x1063u: case 0x1064u: case 0x1069u: case 0x106Au:
235 case 0x106Bu: case 0x106Cu: case 0x106Du: case 0xAA7Bu:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500236 cat = (indic_category_t) OT_PT;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500237 break;
238
Behdad Esfahbod76271002014-07-11 14:54:42 -0400239 case 0x1038u: case 0x1087u: case 0x1088u: case 0x1089u:
240 case 0x108Au: case 0x108Bu: case 0x108Cu: case 0x108Du:
241 case 0x108Fu: case 0x109Au: case 0x109Bu: case 0x109Cu:
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500242 cat = (indic_category_t) OT_SM;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500243 break;
Behdad Esfahbod9174a9d2013-11-25 18:10:38 -0500244
Behdad Esfahbod76271002014-07-11 14:54:42 -0400245 case 0x104Au: case 0x104Bu:
Behdad Esfahbod9174a9d2013-11-25 18:10:38 -0500246 cat = (indic_category_t) OT_P;
247 break;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500248 }
249
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500250 if (cat == OT_M)
251 {
252 switch ((int) pos)
253 {
254 case POS_PRE_C: cat = (indic_category_t) OT_VPre;
255 pos = POS_PRE_M; break;
256 case POS_ABOVE_C: cat = (indic_category_t) OT_VAbv; break;
257 case POS_BELOW_C: cat = (indic_category_t) OT_VBlw; break;
258 case POS_POST_C: cat = (indic_category_t) OT_VPst; break;
259 }
260 }
261
262 info.myanmar_category() = (myanmar_category_t) cat;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500263 info.myanmar_position() = pos;
264}
265
266
267
268static void
269setup_masks_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED,
270 hb_buffer_t *buffer,
271 hb_font_t *font HB_UNUSED)
272{
273 HB_BUFFER_ALLOCATE_VAR (buffer, myanmar_category);
274 HB_BUFFER_ALLOCATE_VAR (buffer, myanmar_position);
275
276 /* We cannot setup masks here. We save information about characters
277 * and setup masks later on in a pause-callback. */
278
279 unsigned int count = buffer->len;
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -0400280 hb_glyph_info_t *info = buffer->info;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500281 for (unsigned int i = 0; i < count; i++)
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -0400282 set_myanmar_properties (info[i]);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500283}
284
285static void
286setup_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED,
287 hb_font_t *font HB_UNUSED,
288 hb_buffer_t *buffer)
289{
290 find_syllables (buffer);
291}
292
293static int
294compare_myanmar_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
295{
296 int a = pa->myanmar_position();
297 int b = pb->myanmar_position();
298
299 return a < b ? -1 : a == b ? 0 : +1;
300}
301
302
303/* Rules from:
304 * http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm */
305
306static void
Behdad Esfahbod56f71ff2015-07-22 11:58:11 +0100307initial_reordering_consonant_syllable (hb_buffer_t *buffer,
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500308 unsigned int start, unsigned int end)
309{
310 hb_glyph_info_t *info = buffer->info;
311
312 unsigned int base = end;
313 bool has_reph = false;
314
315 {
316 unsigned int limit = start;
317 if (start + 3 <= end &&
318 info[start ].myanmar_category() == OT_Ra &&
319 info[start+1].myanmar_category() == OT_As &&
320 info[start+2].myanmar_category() == OT_H)
321 {
322 limit += 3;
323 base = start;
324 has_reph = true;
325 }
326
327 {
328 if (!has_reph)
329 base = limit;
330
331 for (unsigned int i = limit; i < end; i++)
332 if (is_consonant (info[i]))
333 {
334 base = i;
335 break;
336 }
337 }
338 }
339
340 /* Reorder! */
341 {
342 unsigned int i = start;
343 for (; i < start + (has_reph ? 3 : 0); i++)
344 info[i].myanmar_position() = POS_AFTER_MAIN;
345 for (; i < base; i++)
346 info[i].myanmar_position() = POS_PRE_C;
347 if (i < end)
348 {
349 info[i].myanmar_position() = POS_BASE_C;
350 i++;
351 }
Behdad Esfahbodf9b66052013-02-12 16:13:56 -0500352 indic_position_t pos = POS_AFTER_MAIN;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500353 /* The following loop may be ugly, but it implements all of
354 * Myanmar reordering! */
355 for (; i < end; i++)
356 {
357 if (info[i].myanmar_category() == OT_MR) /* Pre-base reordering */
358 {
359 info[i].myanmar_position() = POS_PRE_C;
360 continue;
361 }
362 if (info[i].myanmar_position() < POS_BASE_C) /* Left matra */
363 {
364 continue;
365 }
366
367 if (pos == POS_AFTER_MAIN && info[i].myanmar_category() == OT_VBlw)
368 {
369 pos = POS_BELOW_C;
370 info[i].myanmar_position() = pos;
371 continue;
372 }
373
374 if (pos == POS_BELOW_C && info[i].myanmar_category() == OT_A)
375 {
376 info[i].myanmar_position() = POS_BEFORE_SUB;
377 continue;
378 }
379 if (pos == POS_BELOW_C && info[i].myanmar_category() == OT_VBlw)
380 {
381 info[i].myanmar_position() = pos;
382 continue;
383 }
384 if (pos == POS_BELOW_C && info[i].myanmar_category() != OT_A)
385 {
386 pos = POS_AFTER_SUB;
387 info[i].myanmar_position() = pos;
388 continue;
389 }
390 info[i].myanmar_position() = pos;
391 }
392 }
393
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500394 /* Sit tight, rock 'n roll! */
Behdad Esfahbodc403d632015-09-01 16:15:25 +0100395 buffer->sort (start, end, compare_myanmar_order);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500396}
397
398static void
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500399initial_reordering_syllable (const hb_ot_shape_plan_t *plan,
400 hb_face_t *face,
401 hb_buffer_t *buffer,
402 unsigned int start, unsigned int end)
403{
404 syllable_type_t syllable_type = (syllable_type_t) (buffer->info[start].syllable() & 0x0F);
405 switch (syllable_type) {
Behdad Esfahbod56f71ff2015-07-22 11:58:11 +0100406
407 case broken_cluster: /* We already inserted dotted-circles, so just call the consonant_syllable. */
408 case consonant_syllable:
409 initial_reordering_consonant_syllable (buffer, start, end);
410 break;
411
412 case punctuation_cluster:
413 case non_myanmar_cluster:
414 break;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500415 }
416}
417
418static inline void
419insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
420 hb_font_t *font,
421 hb_buffer_t *buffer)
422{
423 /* Note: This loop is extra overhead, but should not be measurable. */
424 bool has_broken_syllables = false;
425 unsigned int count = buffer->len;
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -0400426 hb_glyph_info_t *info = buffer->info;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500427 for (unsigned int i = 0; i < count; i++)
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -0400428 if ((info[i].syllable() & 0x0F) == broken_cluster)
429 {
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500430 has_broken_syllables = true;
431 break;
432 }
433 if (likely (!has_broken_syllables))
434 return;
435
436
437 hb_codepoint_t dottedcircle_glyph;
Behdad Esfahbod76271002014-07-11 14:54:42 -0400438 if (!font->get_glyph (0x25CCu, 0, &dottedcircle_glyph))
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500439 return;
440
441 hb_glyph_info_t dottedcircle = {0};
Behdad Esfahbod76271002014-07-11 14:54:42 -0400442 dottedcircle.codepoint = 0x25CCu;
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500443 set_myanmar_properties (dottedcircle);
444 dottedcircle.codepoint = dottedcircle_glyph;
445
446 buffer->clear_output ();
447
448 buffer->idx = 0;
449 unsigned int last_syllable = 0;
450 while (buffer->idx < buffer->len)
451 {
452 unsigned int syllable = buffer->cur().syllable();
453 syllable_type_t syllable_type = (syllable_type_t) (syllable & 0x0F);
454 if (unlikely (last_syllable != syllable && syllable_type == broken_cluster))
455 {
456 last_syllable = syllable;
457
Behdad Esfahbod6f932bc2015-10-21 11:16:49 -0200458 hb_glyph_info_t ginfo = dottedcircle;
459 ginfo.cluster = buffer->cur().cluster;
460 ginfo.mask = buffer->cur().mask;
461 ginfo.syllable() = buffer->cur().syllable();
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500462
Behdad Esfahbod6f932bc2015-10-21 11:16:49 -0200463 buffer->output_info (ginfo);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500464 }
465 else
466 buffer->next_glyph ();
467 }
468
469 buffer->swap_buffers ();
470}
471
472static void
473initial_reordering (const hb_ot_shape_plan_t *plan,
474 hb_font_t *font,
475 hb_buffer_t *buffer)
476{
477 insert_dotted_circles (plan, font, buffer);
478
Behdad Esfahbod56f71ff2015-07-22 11:58:11 +0100479 foreach_syllable (buffer, start, end)
480 initial_reordering_syllable (plan, font->face, buffer, start, end);
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500481}
482
483static void
484final_reordering (const hb_ot_shape_plan_t *plan,
485 hb_font_t *font HB_UNUSED,
486 hb_buffer_t *buffer)
487{
488 hb_glyph_info_t *info = buffer->info;
489 unsigned int count = buffer->len;
490
491 /* Zero syllables now... */
492 for (unsigned int i = 0; i < count; i++)
493 info[i].syllable() = 0;
494
495 HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category);
496 HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_position);
497}
498
Behdad Esfahbod71b4c992013-10-28 00:20:59 +0100499
Behdad Esfahbod6f2d9ba2014-07-26 19:17:44 -0400500/* Uniscribe seems to have a shaper for 'mymr' that is like the
501 * generic shaper, except that it zeros mark advances GDEF_LATE. */
502const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar_old =
503{
504 "default",
505 NULL, /* collect_features */
506 NULL, /* override_features */
507 NULL, /* data_create */
508 NULL, /* data_destroy */
509 NULL, /* preprocess_text */
Behdad Esfahbod13686332015-11-05 13:24:15 -0800510 NULL, /* postprocess_glyphs */
Behdad Esfahbod6f2d9ba2014-07-26 19:17:44 -0400511 HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT,
512 NULL, /* decompose */
513 NULL, /* compose */
514 NULL, /* setup_masks */
515 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
516 true, /* fallback_position */
517};
518
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500519const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar =
520{
521 "myanmar",
522 collect_features_myanmar,
523 override_features_myanmar,
524 NULL, /* data_create */
525 NULL, /* data_destroy */
526 NULL, /* preprocess_text */
Behdad Esfahbod13686332015-11-05 13:24:15 -0800527 NULL, /* postprocess_glyphs */
Behdad Esfahbod3d6ca0d2013-12-31 16:04:35 +0800528 HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT,
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500529 NULL, /* decompose */
530 NULL, /* compose */
531 setup_masks_myanmar,
Behdad Esfahbod71b4c992013-10-28 00:20:59 +0100532 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY,
Behdad Esfahbod98628ca2013-02-11 13:36:23 -0500533 false, /* fallback_position */
534};