Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 1 | /* |
| 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 Esfahbod | 7aad536 | 2019-06-26 13:21:03 -0700 | [diff] [blame] | 27 | #include "hb.hh" |
| 28 | |
| 29 | #ifndef HB_NO_OT_SHAPE |
| 30 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 31 | #include "hb-ot-shape-complex-myanmar.hh" |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 32 | |
| 33 | |
| 34 | /* |
| 35 | * Myanmar shaper. |
| 36 | */ |
| 37 | |
| 38 | static const hb_tag_t |
Behdad Esfahbod | d8b5353 | 2019-07-02 15:09:26 -0700 | [diff] [blame] | 39 | myanmar_basic_features[] = |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 40 | { |
| 41 | /* |
| 42 | * Basic features. |
Behdad Esfahbod | 982c2f4 | 2018-10-26 15:40:12 -0700 | [diff] [blame] | 43 | * These features are applied in order, one at a time, after reordering. |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 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 Esfahbod | ee9c3a1 | 2013-02-15 06:22:26 -0500 | [diff] [blame] | 49 | }; |
| 50 | static const hb_tag_t |
Behdad Esfahbod | d8b5353 | 2019-07-02 15:09:26 -0700 | [diff] [blame] | 51 | myanmar_other_features[] = |
Behdad Esfahbod | ee9c3a1 | 2013-02-15 06:22:26 -0500 | [diff] [blame] | 52 | { |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 53 | /* |
| 54 | * Other features. |
Behdad Esfahbod | 982c2f4 | 2018-10-26 15:40:12 -0700 | [diff] [blame] | 55 | * These features are applied all at once, after clearing syllables. |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 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'), |
Behdad Esfahbod | 3583fb0 | 2018-09-23 22:33:38 -0400 | [diff] [blame] | 61 | }; |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 62 | |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 63 | static void |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 64 | setup_syllables_myanmar (const hb_ot_shape_plan_t *plan, |
| 65 | hb_font_t *font, |
| 66 | hb_buffer_t *buffer); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 67 | static void |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 68 | reorder_myanmar (const hb_ot_shape_plan_t *plan, |
Behdad Esfahbod | 982c2f4 | 2018-10-26 15:40:12 -0700 | [diff] [blame] | 69 | hb_font_t *font, |
| 70 | hb_buffer_t *buffer); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 71 | |
| 72 | static void |
| 73 | collect_features_myanmar (hb_ot_shape_planner_t *plan) |
| 74 | { |
| 75 | hb_ot_map_builder_t *map = &plan->map; |
| 76 | |
| 77 | /* Do this before any lookups have been applied. */ |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 78 | map->add_gsub_pause (setup_syllables_myanmar); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 79 | |
Behdad Esfahbod | f048ead | 2018-09-24 18:01:53 -0400 | [diff] [blame] | 80 | map->enable_feature (HB_TAG('l','o','c','l')); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 81 | /* The Indic specs do not require ccmp, but we apply it here since if |
| 82 | * there is a use of it, it's typically at the beginning. */ |
Behdad Esfahbod | f048ead | 2018-09-24 18:01:53 -0400 | [diff] [blame] | 83 | map->enable_feature (HB_TAG('c','c','m','p')); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 84 | |
| 85 | |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 86 | map->add_gsub_pause (reorder_myanmar); |
Behdad Esfahbod | 3583fb0 | 2018-09-23 22:33:38 -0400 | [diff] [blame] | 87 | |
Behdad Esfahbod | d8b5353 | 2019-07-02 15:09:26 -0700 | [diff] [blame] | 88 | for (unsigned int i = 0; i < ARRAY_LENGTH (myanmar_basic_features); i++) |
Behdad Esfahbod | ee9c3a1 | 2013-02-15 06:22:26 -0500 | [diff] [blame] | 89 | { |
Behdad Esfahbod | d8b5353 | 2019-07-02 15:09:26 -0700 | [diff] [blame] | 90 | map->enable_feature (myanmar_basic_features[i], F_MANUAL_ZWJ); |
Behdad Esfahbod | dbdbfe3 | 2017-10-15 12:11:08 +0200 | [diff] [blame] | 91 | map->add_gsub_pause (nullptr); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 92 | } |
Behdad Esfahbod | 3583fb0 | 2018-09-23 22:33:38 -0400 | [diff] [blame] | 93 | |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 94 | map->add_gsub_pause (_hb_clear_syllables); |
Behdad Esfahbod | 3583fb0 | 2018-09-23 22:33:38 -0400 | [diff] [blame] | 95 | |
Behdad Esfahbod | d8b5353 | 2019-07-02 15:09:26 -0700 | [diff] [blame] | 96 | for (unsigned int i = 0; i < ARRAY_LENGTH (myanmar_other_features); i++) |
| 97 | map->enable_feature (myanmar_other_features[i], F_MANUAL_ZWJ); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | static void |
| 101 | override_features_myanmar (hb_ot_shape_planner_t *plan) |
| 102 | { |
Behdad Esfahbod | 1676f60 | 2018-09-24 17:55:03 -0400 | [diff] [blame] | 103 | plan->map.disable_feature (HB_TAG('l','i','g','a')); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 107 | enum myanmar_syllable_type_t { |
| 108 | myanmar_consonant_syllable, |
| 109 | myanmar_punctuation_cluster, |
| 110 | myanmar_broken_cluster, |
| 111 | myanmar_non_myanmar_cluster, |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | #include "hb-ot-shape-complex-myanmar-machine.hh" |
| 115 | |
| 116 | |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 117 | static void |
| 118 | setup_masks_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED, |
| 119 | hb_buffer_t *buffer, |
| 120 | hb_font_t *font HB_UNUSED) |
| 121 | { |
| 122 | HB_BUFFER_ALLOCATE_VAR (buffer, myanmar_category); |
| 123 | HB_BUFFER_ALLOCATE_VAR (buffer, myanmar_position); |
| 124 | |
| 125 | /* We cannot setup masks here. We save information about characters |
| 126 | * and setup masks later on in a pause-callback. */ |
| 127 | |
| 128 | unsigned int count = buffer->len; |
Behdad Esfahbod | 7cd33f2 | 2014-07-17 14:22:11 -0400 | [diff] [blame] | 129 | hb_glyph_info_t *info = buffer->info; |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 130 | for (unsigned int i = 0; i < count; i++) |
Behdad Esfahbod | 7cd33f2 | 2014-07-17 14:22:11 -0400 | [diff] [blame] | 131 | set_myanmar_properties (info[i]); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | static void |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 135 | setup_syllables_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED, |
| 136 | hb_font_t *font HB_UNUSED, |
| 137 | hb_buffer_t *buffer) |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 138 | { |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 139 | find_syllables_myanmar (buffer); |
Behdad Esfahbod | 9e005c5 | 2017-08-10 18:45:33 -0700 | [diff] [blame] | 140 | foreach_syllable (buffer, start, end) |
| 141 | buffer->unsafe_to_break (start, end); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | static int |
| 145 | compare_myanmar_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb) |
| 146 | { |
| 147 | int a = pa->myanmar_position(); |
| 148 | int b = pb->myanmar_position(); |
| 149 | |
| 150 | return a < b ? -1 : a == b ? 0 : +1; |
| 151 | } |
| 152 | |
| 153 | |
| 154 | /* Rules from: |
Ebrahim Byagowi | f24b0b9 | 2018-04-12 13:40:45 +0430 | [diff] [blame] | 155 | * https://docs.microsoft.com/en-us/typography/script-development/myanmar */ |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 156 | |
| 157 | static void |
Behdad Esfahbod | 56f71ff | 2015-07-22 11:58:11 +0100 | [diff] [blame] | 158 | initial_reordering_consonant_syllable (hb_buffer_t *buffer, |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 159 | unsigned int start, unsigned int end) |
| 160 | { |
| 161 | hb_glyph_info_t *info = buffer->info; |
| 162 | |
| 163 | unsigned int base = end; |
| 164 | bool has_reph = false; |
| 165 | |
| 166 | { |
| 167 | unsigned int limit = start; |
| 168 | if (start + 3 <= end && |
| 169 | info[start ].myanmar_category() == OT_Ra && |
| 170 | info[start+1].myanmar_category() == OT_As && |
| 171 | info[start+2].myanmar_category() == OT_H) |
| 172 | { |
| 173 | limit += 3; |
| 174 | base = start; |
| 175 | has_reph = true; |
| 176 | } |
| 177 | |
| 178 | { |
| 179 | if (!has_reph) |
| 180 | base = limit; |
| 181 | |
| 182 | for (unsigned int i = limit; i < end; i++) |
| 183 | if (is_consonant (info[i])) |
| 184 | { |
| 185 | base = i; |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /* Reorder! */ |
| 192 | { |
| 193 | unsigned int i = start; |
| 194 | for (; i < start + (has_reph ? 3 : 0); i++) |
| 195 | info[i].myanmar_position() = POS_AFTER_MAIN; |
| 196 | for (; i < base; i++) |
| 197 | info[i].myanmar_position() = POS_PRE_C; |
| 198 | if (i < end) |
| 199 | { |
| 200 | info[i].myanmar_position() = POS_BASE_C; |
| 201 | i++; |
| 202 | } |
Behdad Esfahbod | f9b6605 | 2013-02-12 16:13:56 -0500 | [diff] [blame] | 203 | indic_position_t pos = POS_AFTER_MAIN; |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 204 | /* The following loop may be ugly, but it implements all of |
| 205 | * Myanmar reordering! */ |
| 206 | for (; i < end; i++) |
| 207 | { |
| 208 | if (info[i].myanmar_category() == OT_MR) /* Pre-base reordering */ |
| 209 | { |
| 210 | info[i].myanmar_position() = POS_PRE_C; |
| 211 | continue; |
| 212 | } |
| 213 | if (info[i].myanmar_position() < POS_BASE_C) /* Left matra */ |
| 214 | { |
| 215 | continue; |
| 216 | } |
David Corbett | ccb0367 | 2018-02-02 12:04:04 -0500 | [diff] [blame] | 217 | if (info[i].myanmar_category() == OT_VS) |
| 218 | { |
| 219 | info[i].myanmar_position() = info[i - 1].myanmar_position(); |
| 220 | continue; |
| 221 | } |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 222 | |
| 223 | if (pos == POS_AFTER_MAIN && info[i].myanmar_category() == OT_VBlw) |
| 224 | { |
| 225 | pos = POS_BELOW_C; |
| 226 | info[i].myanmar_position() = pos; |
| 227 | continue; |
| 228 | } |
| 229 | |
| 230 | if (pos == POS_BELOW_C && info[i].myanmar_category() == OT_A) |
| 231 | { |
| 232 | info[i].myanmar_position() = POS_BEFORE_SUB; |
| 233 | continue; |
| 234 | } |
| 235 | if (pos == POS_BELOW_C && info[i].myanmar_category() == OT_VBlw) |
| 236 | { |
| 237 | info[i].myanmar_position() = pos; |
| 238 | continue; |
| 239 | } |
| 240 | if (pos == POS_BELOW_C && info[i].myanmar_category() != OT_A) |
| 241 | { |
Ebrahim Byagowi | a0b4ac4 | 2019-08-24 17:57:14 +0430 | [diff] [blame] | 242 | pos = POS_AFTER_SUB; |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 243 | info[i].myanmar_position() = pos; |
| 244 | continue; |
| 245 | } |
| 246 | info[i].myanmar_position() = pos; |
| 247 | } |
| 248 | } |
| 249 | |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 250 | /* Sit tight, rock 'n roll! */ |
Behdad Esfahbod | c403d63 | 2015-09-01 16:15:25 +0100 | [diff] [blame] | 251 | buffer->sort (start, end, compare_myanmar_order); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | static void |
Behdad Esfahbod | d8b5353 | 2019-07-02 15:09:26 -0700 | [diff] [blame] | 255 | reorder_syllable_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED, |
| 256 | hb_face_t *face HB_UNUSED, |
| 257 | hb_buffer_t *buffer, |
| 258 | unsigned int start, unsigned int end) |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 259 | { |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 260 | myanmar_syllable_type_t syllable_type = (myanmar_syllable_type_t) (buffer->info[start].syllable() & 0x0F); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 261 | switch (syllable_type) { |
Behdad Esfahbod | 56f71ff | 2015-07-22 11:58:11 +0100 | [diff] [blame] | 262 | |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 263 | case myanmar_broken_cluster: /* We already inserted dotted-circles, so just call the consonant_syllable. */ |
| 264 | case myanmar_consonant_syllable: |
Behdad Esfahbod | 56f71ff | 2015-07-22 11:58:11 +0100 | [diff] [blame] | 265 | initial_reordering_consonant_syllable (buffer, start, end); |
| 266 | break; |
| 267 | |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 268 | case myanmar_punctuation_cluster: |
| 269 | case myanmar_non_myanmar_cluster: |
Behdad Esfahbod | 56f71ff | 2015-07-22 11:58:11 +0100 | [diff] [blame] | 270 | break; |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
| 274 | static inline void |
Behdad Esfahbod | 3724f13 | 2019-07-02 15:23:00 -0700 | [diff] [blame] | 275 | insert_dotted_circles_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED, |
| 276 | hb_font_t *font, |
| 277 | hb_buffer_t *buffer) |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 278 | { |
Eric Muller | 30d7c40 | 2019-02-09 02:55:27 -0800 | [diff] [blame] | 279 | if (unlikely (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE)) |
| 280 | return; |
| 281 | |
Behdad Esfahbod | 085793d | 2019-04-24 10:15:59 -0400 | [diff] [blame] | 282 | /* Note: This loop is extra overhead, but should not be measurable. |
| 283 | * TODO Use a buffer scratch flag to remove the loop. */ |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 284 | bool has_broken_syllables = false; |
| 285 | unsigned int count = buffer->len; |
Behdad Esfahbod | 7cd33f2 | 2014-07-17 14:22:11 -0400 | [diff] [blame] | 286 | hb_glyph_info_t *info = buffer->info; |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 287 | for (unsigned int i = 0; i < count; i++) |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 288 | if ((info[i].syllable() & 0x0F) == myanmar_broken_cluster) |
Behdad Esfahbod | 7cd33f2 | 2014-07-17 14:22:11 -0400 | [diff] [blame] | 289 | { |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 290 | has_broken_syllables = true; |
| 291 | break; |
| 292 | } |
| 293 | if (likely (!has_broken_syllables)) |
| 294 | return; |
| 295 | |
| 296 | |
| 297 | hb_codepoint_t dottedcircle_glyph; |
Behdad Esfahbod | 8b5bc14 | 2016-02-24 19:05:23 +0900 | [diff] [blame] | 298 | if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph)) |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 299 | return; |
| 300 | |
| 301 | hb_glyph_info_t dottedcircle = {0}; |
Behdad Esfahbod | 7627100 | 2014-07-11 14:54:42 -0400 | [diff] [blame] | 302 | dottedcircle.codepoint = 0x25CCu; |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 303 | set_myanmar_properties (dottedcircle); |
| 304 | dottedcircle.codepoint = dottedcircle_glyph; |
| 305 | |
| 306 | buffer->clear_output (); |
| 307 | |
| 308 | buffer->idx = 0; |
| 309 | unsigned int last_syllable = 0; |
Behdad Esfahbod | 7185b27 | 2018-05-31 20:03:00 -0700 | [diff] [blame] | 310 | while (buffer->idx < buffer->len && buffer->successful) |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 311 | { |
| 312 | unsigned int syllable = buffer->cur().syllable(); |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 313 | myanmar_syllable_type_t syllable_type = (myanmar_syllable_type_t) (syllable & 0x0F); |
| 314 | if (unlikely (last_syllable != syllable && syllable_type == myanmar_broken_cluster)) |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 315 | { |
| 316 | last_syllable = syllable; |
| 317 | |
Behdad Esfahbod | 6f932bc | 2015-10-21 11:16:49 -0200 | [diff] [blame] | 318 | hb_glyph_info_t ginfo = dottedcircle; |
| 319 | ginfo.cluster = buffer->cur().cluster; |
| 320 | ginfo.mask = buffer->cur().mask; |
| 321 | ginfo.syllable() = buffer->cur().syllable(); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 322 | |
Behdad Esfahbod | 6f932bc | 2015-10-21 11:16:49 -0200 | [diff] [blame] | 323 | buffer->output_info (ginfo); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 324 | } |
| 325 | else |
| 326 | buffer->next_glyph (); |
| 327 | } |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 328 | buffer->swap_buffers (); |
| 329 | } |
| 330 | |
| 331 | static void |
Behdad Esfahbod | d115a9e | 2019-07-02 14:42:45 -0700 | [diff] [blame] | 332 | reorder_myanmar (const hb_ot_shape_plan_t *plan, |
| 333 | hb_font_t *font, |
| 334 | hb_buffer_t *buffer) |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 335 | { |
Behdad Esfahbod | 3724f13 | 2019-07-02 15:23:00 -0700 | [diff] [blame] | 336 | insert_dotted_circles_myanmar (plan, font, buffer); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 337 | |
Behdad Esfahbod | 56f71ff | 2015-07-22 11:58:11 +0100 | [diff] [blame] | 338 | foreach_syllable (buffer, start, end) |
Behdad Esfahbod | d8b5353 | 2019-07-02 15:09:26 -0700 | [diff] [blame] | 339 | reorder_syllable_myanmar (plan, font->face, buffer, start, end); |
Behdad Esfahbod | 98628ca | 2013-02-11 13:36:23 -0500 | [diff] [blame] | 340 | |
| 341 | HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category); |
| 342 | HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_position); |
| 343 | } |
| 344 | |
Behdad Esfahbod | 71b4c99 | 2013-10-28 00:20:59 +0100 | [diff] [blame] | 345 | |
Behdad Esfahbod | 00c5c4a | 2018-10-11 20:15:31 -0400 | [diff] [blame] | 346 | const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar = |
| 347 | { |
| 348 | collect_features_myanmar, |
| 349 | override_features_myanmar, |
| 350 | nullptr, /* data_create */ |
| 351 | nullptr, /* data_destroy */ |
| 352 | nullptr, /* preprocess_text */ |
| 353 | nullptr, /* postprocess_glyphs */ |
| 354 | HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, |
| 355 | nullptr, /* decompose */ |
| 356 | nullptr, /* compose */ |
| 357 | setup_masks_myanmar, |
| 358 | HB_TAG_NONE, /* gpos_tag */ |
| 359 | nullptr, /* reorder_marks */ |
| 360 | HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, |
| 361 | false, /* fallback_position */ |
| 362 | }; |
| 363 | |
| 364 | |
Behdad Esfahbod | bdb53ca | 2018-10-11 20:20:00 -0400 | [diff] [blame] | 365 | /* Ugly Zawgyi encoding. |
| 366 | * Disable all auto processing. |
| 367 | * https://github.com/harfbuzz/harfbuzz/issues/1162 */ |
| 368 | const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar_zawgyi = |
| 369 | { |
| 370 | nullptr, /* collect_features */ |
| 371 | nullptr, /* override_features */ |
| 372 | nullptr, /* data_create */ |
| 373 | nullptr, /* data_destroy */ |
| 374 | nullptr, /* preprocess_text */ |
| 375 | nullptr, /* postprocess_glyphs */ |
| 376 | HB_OT_SHAPE_NORMALIZATION_MODE_NONE, |
| 377 | nullptr, /* decompose */ |
| 378 | nullptr, /* compose */ |
| 379 | nullptr, /* setup_masks */ |
| 380 | HB_TAG_NONE, /* gpos_tag */ |
| 381 | nullptr, /* reorder_marks */ |
| 382 | HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, |
| 383 | false, /* fallback_position */ |
| 384 | }; |
Behdad Esfahbod | 7aad536 | 2019-06-26 13:21:03 -0700 | [diff] [blame] | 385 | |
| 386 | |
| 387 | #endif |