Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 27aba59 | 2012-05-24 15:00:01 -0400 | [diff] [blame] | 2 | * Copyright © 2011,2012 Google, Inc. |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 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 | 3ed4634 | 2012-04-19 22:34:06 -0400 | [diff] [blame] | 27 | #include "hb-ot-shape-complex-indic-private.hh" |
Behdad Esfahbod | a913b02 | 2012-05-11 20:59:26 +0200 | [diff] [blame] | 28 | #include "hb-ot-shape-private.hh" |
Behdad Esfahbod | 49c5ec5 | 2012-07-23 20:14:13 -0400 | [diff] [blame] | 29 | #include "hb-ot-layout-private.hh" |
Behdad Esfahbod | 352372a | 2011-07-30 19:04:02 -0400 | [diff] [blame] | 30 | |
Behdad Esfahbod | 1d00204 | 2012-08-02 05:01:11 -0400 | [diff] [blame] | 31 | |
Behdad Esfahbod | a3e04be | 2012-07-16 13:47:19 -0400 | [diff] [blame] | 32 | #define OLD_INDIC_TAG(script) (((hb_tag_t) script) | 0x20000000) |
| 33 | #define IS_OLD_INDIC_TAG(tag) ( \ |
Behdad Esfahbod | 1d00204 | 2012-08-02 05:01:11 -0400 | [diff] [blame] | 34 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_BENGALI) || \ |
| 35 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_DEVANAGARI) || \ |
| 36 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_GUJARATI) || \ |
| 37 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_GURMUKHI) || \ |
| 38 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_KANNADA) || \ |
| 39 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_MALAYALAM) || \ |
| 40 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_ORIYA) || \ |
| 41 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_TAMIL) || \ |
| 42 | (tag) == OLD_INDIC_TAG (HB_SCRIPT_TELUGU) || \ |
| 43 | 0) |
| 44 | |
| 45 | |
Behdad Esfahbod | a2b471d | 2012-06-05 15:17:44 -0400 | [diff] [blame] | 46 | struct indic_options_t |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 47 | { |
Behdad Esfahbod | a2b471d | 2012-06-05 15:17:44 -0400 | [diff] [blame] | 48 | int initialized : 1; |
| 49 | int uniscribe_bug_compatible : 1; |
| 50 | }; |
| 51 | |
| 52 | union indic_options_union_t { |
| 53 | int i; |
| 54 | indic_options_t opts; |
| 55 | }; |
| 56 | ASSERT_STATIC (sizeof (int) == sizeof (indic_options_union_t)); |
| 57 | |
| 58 | static indic_options_union_t |
| 59 | indic_options_init (void) |
| 60 | { |
| 61 | indic_options_union_t u; |
| 62 | u.i = 0; |
| 63 | u.opts.initialized = 1; |
| 64 | |
| 65 | char *c = getenv ("HB_OT_INDIC_OPTIONS"); |
| 66 | u.opts.uniscribe_bug_compatible = c && strstr (c, "uniscribe-bug-compatible"); |
| 67 | |
| 68 | return u; |
| 69 | } |
| 70 | |
| 71 | inline indic_options_t |
| 72 | indic_options (void) |
| 73 | { |
| 74 | static indic_options_union_t options; |
| 75 | |
| 76 | if (unlikely (!options.i)) { |
| 77 | /* This is idempotent and threadsafe. */ |
| 78 | options = indic_options_init (); |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 79 | } |
| 80 | |
Behdad Esfahbod | a2b471d | 2012-06-05 15:17:44 -0400 | [diff] [blame] | 81 | return options.opts; |
| 82 | } |
| 83 | |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 84 | |
Behdad Esfahbod | 3614ba2 | 2012-08-02 07:13:55 -0400 | [diff] [blame] | 85 | struct indic_shape_plan_t |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 86 | { |
Behdad Esfahbod | 3614ba2 | 2012-08-02 07:13:55 -0400 | [diff] [blame] | 87 | struct would_apply_feature_t |
Behdad Esfahbod | 610e5e8 | 2012-08-02 05:27:46 -0400 | [diff] [blame] | 88 | { |
Behdad Esfahbod | 3614ba2 | 2012-08-02 07:13:55 -0400 | [diff] [blame] | 89 | would_apply_feature_t (const hb_ot_map_t *map, hb_tag_t feature_tag) |
Behdad Esfahbod | 610e5e8 | 2012-08-02 05:27:46 -0400 | [diff] [blame] | 90 | { |
| 91 | map->get_stage_lookups (0/*GSUB*/, |
| 92 | map->get_feature_stage (0/*GSUB*/, feature_tag), |
| 93 | &lookups, &count); |
| 94 | } |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 95 | |
Behdad Esfahbod | 610e5e8 | 2012-08-02 05:27:46 -0400 | [diff] [blame] | 96 | inline bool would_substitute (hb_codepoint_t *glyphs, |
| 97 | unsigned int glyphs_count, |
| 98 | hb_face_t *face) const |
| 99 | { |
| 100 | for (unsigned int i = 0; i < count; i++) |
| 101 | if (hb_ot_layout_would_substitute_lookup_fast (face, glyphs, glyphs_count, lookups[i].index)) |
| 102 | return true; |
| 103 | return false; |
| 104 | } |
Behdad Esfahbod | 0de771b | 2012-07-16 13:39:36 -0400 | [diff] [blame] | 105 | |
Behdad Esfahbod | 610e5e8 | 2012-08-02 05:27:46 -0400 | [diff] [blame] | 106 | private: |
| 107 | const hb_ot_map_t::lookup_map_t *lookups; |
| 108 | unsigned int count; |
| 109 | }; |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 110 | |
Behdad Esfahbod | 3614ba2 | 2012-08-02 07:13:55 -0400 | [diff] [blame] | 111 | indic_shape_plan_t (const hb_ot_map_t *map_) : |
| 112 | map (map_), |
| 113 | pref (map_, HB_TAG('p','r','e','f')), |
| 114 | blwf (map_, HB_TAG('b','l','w','f')), |
| 115 | pstf (map_, HB_TAG('p','s','t','f')), |
| 116 | is_old_spec (IS_OLD_INDIC_TAG (map->get_chosen_script (0))) {} |
Behdad Esfahbod | f055442 | 2012-07-19 16:20:21 -0400 | [diff] [blame] | 117 | |
Behdad Esfahbod | 610e5e8 | 2012-08-02 05:27:46 -0400 | [diff] [blame] | 118 | const hb_ot_map_t *map; |
Behdad Esfahbod | 3614ba2 | 2012-08-02 07:13:55 -0400 | [diff] [blame] | 119 | would_apply_feature_t pref; |
| 120 | would_apply_feature_t blwf; |
| 121 | would_apply_feature_t pstf; |
| 122 | bool is_old_spec; |
Behdad Esfahbod | 610e5e8 | 2012-08-02 05:27:46 -0400 | [diff] [blame] | 123 | }; |
Behdad Esfahbod | f055442 | 2012-07-19 16:20:21 -0400 | [diff] [blame] | 124 | |
| 125 | static indic_position_t |
Behdad Esfahbod | 8ef3d53 | 2012-08-02 07:53:18 -0400 | [diff] [blame] | 126 | consonant_position_from_font (const indic_shape_plan_t *indic_plan, |
| 127 | hb_codepoint_t *glyphs, unsigned int glyphs_len, |
| 128 | hb_face_t *face) |
Behdad Esfahbod | f055442 | 2012-07-19 16:20:21 -0400 | [diff] [blame] | 129 | { |
Behdad Esfahbod | 3614ba2 | 2012-08-02 07:13:55 -0400 | [diff] [blame] | 130 | if (indic_plan->pref.would_substitute (glyphs, ARRAY_LENGTH (glyphs), face)) return POS_BELOW_C; |
| 131 | if (indic_plan->blwf.would_substitute (glyphs, ARRAY_LENGTH (glyphs), face)) return POS_BELOW_C; |
| 132 | if (indic_plan->pstf.would_substitute (glyphs, ARRAY_LENGTH (glyphs), face)) return POS_POST_C; |
Behdad Esfahbod | f055442 | 2012-07-19 16:20:21 -0400 | [diff] [blame] | 133 | return POS_BASE_C; |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 134 | } |
| 135 | |
Behdad Esfahbod | 9ccc638 | 2012-07-19 12:32:16 -0400 | [diff] [blame] | 136 | |
| 137 | |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 138 | struct feature_list_t { |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 139 | hb_tag_t tag; |
| 140 | hb_bool_t is_global; |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 141 | }; |
| 142 | |
Behdad Esfahbod | d5c4edc | 2012-07-17 10:40:59 -0400 | [diff] [blame] | 143 | /* These features are applied one at a time, given the order in this table. */ |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 144 | static const feature_list_t |
| 145 | indic_basic_features[] = |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 146 | { |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 147 | {HB_TAG('n','u','k','t'), true}, |
Behdad Esfahbod | e047534 | 2012-07-19 20:24:14 -0400 | [diff] [blame] | 148 | {HB_TAG('a','k','h','n'), true}, |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 149 | {HB_TAG('r','p','h','f'), false}, |
Behdad Esfahbod | 1ac075b | 2012-05-09 11:06:47 +0200 | [diff] [blame] | 150 | {HB_TAG('r','k','r','f'), true}, |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 151 | {HB_TAG('p','r','e','f'), false}, |
| 152 | {HB_TAG('b','l','w','f'), false}, |
| 153 | {HB_TAG('h','a','l','f'), false}, |
Behdad Esfahbod | 29f106d | 2012-07-16 12:05:35 -0400 | [diff] [blame] | 154 | {HB_TAG('a','b','v','f'), false}, |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 155 | {HB_TAG('p','s','t','f'), false}, |
Behdad Esfahbod | 0201e0a | 2012-07-17 13:55:10 -0400 | [diff] [blame] | 156 | {HB_TAG('c','f','a','r'), false}, |
Behdad Esfahbod | 20b68e6 | 2012-07-20 10:47:46 -0400 | [diff] [blame] | 157 | {HB_TAG('c','j','c','t'), true}, |
Behdad Esfahbod | 1d6846d | 2012-05-13 18:09:29 +0200 | [diff] [blame] | 158 | {HB_TAG('v','a','t','u'), true}, |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | /* Same order as the indic_basic_features array */ |
| 162 | enum { |
| 163 | _NUKT, |
Behdad Esfahbod | e047534 | 2012-07-19 20:24:14 -0400 | [diff] [blame] | 164 | _AKHN, |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 165 | RPHF, |
Behdad Esfahbod | df6d45c | 2012-05-09 11:38:31 +0200 | [diff] [blame] | 166 | _RKRF, |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 167 | PREF, |
| 168 | BLWF, |
| 169 | HALF, |
Behdad Esfahbod | 29f106d | 2012-07-16 12:05:35 -0400 | [diff] [blame] | 170 | ABVF, |
Behdad Esfahbod | c7fe56a | 2011-06-24 19:05:34 -0400 | [diff] [blame] | 171 | PSTF, |
Behdad Esfahbod | 0201e0a | 2012-07-17 13:55:10 -0400 | [diff] [blame] | 172 | CFAR, |
Behdad Esfahbod | 20b68e6 | 2012-07-20 10:47:46 -0400 | [diff] [blame] | 173 | _CJCT, |
Behdad Esfahbod | 1d6846d | 2012-05-13 18:09:29 +0200 | [diff] [blame] | 174 | VATU |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 175 | }; |
| 176 | |
Behdad Esfahbod | d5c4edc | 2012-07-17 10:40:59 -0400 | [diff] [blame] | 177 | /* These features are applied all at once. */ |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 178 | static const feature_list_t |
| 179 | indic_other_features[] = |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 180 | { |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 181 | {HB_TAG('i','n','i','t'), false}, |
| 182 | {HB_TAG('p','r','e','s'), true}, |
| 183 | {HB_TAG('a','b','v','s'), true}, |
| 184 | {HB_TAG('b','l','w','s'), true}, |
| 185 | {HB_TAG('p','s','t','s'), true}, |
| 186 | {HB_TAG('h','a','l','n'), true}, |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 187 | |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 188 | {HB_TAG('d','i','s','t'), true}, |
| 189 | {HB_TAG('a','b','v','m'), true}, |
| 190 | {HB_TAG('b','l','w','m'), true}, |
| 191 | }; |
| 192 | |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 193 | |
| 194 | static void |
| 195 | initial_reordering (const hb_ot_map_t *map, |
Behdad Esfahbod | afbcc24 | 2012-08-02 08:36:40 -0400 | [diff] [blame] | 196 | hb_font_t *font, |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame^] | 197 | hb_buffer_t *buffer); |
Behdad Esfahbod | f6fd378 | 2011-07-08 00:22:40 -0400 | [diff] [blame] | 198 | static void |
| 199 | final_reordering (const hb_ot_map_t *map, |
Behdad Esfahbod | afbcc24 | 2012-08-02 08:36:40 -0400 | [diff] [blame] | 200 | hb_font_t *font, |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame^] | 201 | hb_buffer_t *buffer); |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 202 | |
Behdad Esfahbod | 693918e | 2012-07-30 21:08:51 -0400 | [diff] [blame] | 203 | static void |
Behdad Esfahbod | 16c6a27 | 2012-08-02 09:38:28 -0400 | [diff] [blame] | 204 | collect_features_indic (hb_ot_shape_planner_t *plan) |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 205 | { |
Behdad Esfahbod | 16c6a27 | 2012-08-02 09:38:28 -0400 | [diff] [blame] | 206 | hb_ot_map_builder_t *map = &plan->map; |
| 207 | |
Behdad Esfahbod | f6fd378 | 2011-07-08 00:22:40 -0400 | [diff] [blame] | 208 | map->add_bool_feature (HB_TAG('l','o','c','l')); |
Behdad Esfahbod | a54a550 | 2011-07-20 16:42:10 -0400 | [diff] [blame] | 209 | /* The Indic specs do not require ccmp, but we apply it here since if |
| 210 | * there is a use of it, it's typically at the beginning. */ |
Behdad Esfahbod | f6fd378 | 2011-07-08 00:22:40 -0400 | [diff] [blame] | 211 | map->add_bool_feature (HB_TAG('c','c','m','p')); |
| 212 | |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame^] | 213 | map->add_gsub_pause (initial_reordering); |
Behdad Esfahbod | f6fd378 | 2011-07-08 00:22:40 -0400 | [diff] [blame] | 214 | |
Behdad Esfahbod | 412b918 | 2012-05-09 11:07:18 +0200 | [diff] [blame] | 215 | for (unsigned int i = 0; i < ARRAY_LENGTH (indic_basic_features); i++) { |
Behdad Esfahbod | 76f7681 | 2011-07-07 22:25:25 -0400 | [diff] [blame] | 216 | map->add_bool_feature (indic_basic_features[i].tag, indic_basic_features[i].is_global); |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame^] | 217 | map->add_gsub_pause (NULL); |
Behdad Esfahbod | 412b918 | 2012-05-09 11:07:18 +0200 | [diff] [blame] | 218 | } |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 219 | |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame^] | 220 | map->add_gsub_pause (final_reordering); |
Behdad Esfahbod | f6fd378 | 2011-07-08 00:22:40 -0400 | [diff] [blame] | 221 | |
Behdad Esfahbod | d5c4edc | 2012-07-17 10:40:59 -0400 | [diff] [blame] | 222 | for (unsigned int i = 0; i < ARRAY_LENGTH (indic_other_features); i++) |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 223 | map->add_bool_feature (indic_other_features[i].tag, indic_other_features[i].is_global); |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 224 | } |
| 225 | |
Behdad Esfahbod | 693918e | 2012-07-30 21:08:51 -0400 | [diff] [blame] | 226 | static void |
Behdad Esfahbod | 16c6a27 | 2012-08-02 09:38:28 -0400 | [diff] [blame] | 227 | override_features_indic (hb_ot_shape_planner_t *plan) |
Behdad Esfahbod | d96838e | 2012-07-16 20:26:57 -0400 | [diff] [blame] | 228 | { |
Behdad Esfahbod | af92b4c | 2012-07-16 20:31:24 -0400 | [diff] [blame] | 229 | /* Uniscribe does not apply 'kern'. */ |
| 230 | if (indic_options ().uniscribe_bug_compatible) |
Behdad Esfahbod | 16c6a27 | 2012-08-02 09:38:28 -0400 | [diff] [blame] | 231 | plan->map.add_feature (HB_TAG('k','e','r','n'), 0, true); |
Behdad Esfahbod | d96838e | 2012-07-16 20:26:57 -0400 | [diff] [blame] | 232 | } |
| 233 | |
Behdad Esfahbod | 867361c | 2011-06-17 18:35:46 -0400 | [diff] [blame] | 234 | |
Behdad Esfahbod | 693918e | 2012-07-30 21:08:51 -0400 | [diff] [blame] | 235 | static void |
Behdad Esfahbod | 16c6a27 | 2012-08-02 09:38:28 -0400 | [diff] [blame] | 236 | setup_masks_indic (const hb_ot_shape_plan_t *plan HB_UNUSED, |
| 237 | hb_buffer_t *buffer, |
| 238 | hb_font_t *font HB_UNUSED) |
Behdad Esfahbod | 24eacf1 | 2012-08-02 08:42:11 -0400 | [diff] [blame] | 239 | { |
| 240 | HB_BUFFER_ALLOCATE_VAR (buffer, indic_category); |
| 241 | HB_BUFFER_ALLOCATE_VAR (buffer, indic_position); |
| 242 | |
| 243 | /* We cannot setup masks here. We save information about characters |
| 244 | * and setup masks later on in a pause-callback. */ |
| 245 | |
| 246 | unsigned int count = buffer->len; |
| 247 | for (unsigned int i = 0; i < count; i++) |
| 248 | set_indic_properties (buffer->info[i]); |
| 249 | } |
| 250 | |
| 251 | static int |
| 252 | compare_indic_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb) |
| 253 | { |
| 254 | int a = pa->indic_position(); |
| 255 | int b = pb->indic_position(); |
| 256 | |
| 257 | return a < b ? -1 : a == b ? 0 : +1; |
| 258 | } |
| 259 | |
| 260 | |
| 261 | |
| 262 | static void |
Behdad Esfahbod | 8ef3d53 | 2012-08-02 07:53:18 -0400 | [diff] [blame] | 263 | update_consonant_positions (const hb_ot_map_t *map, |
| 264 | hb_buffer_t *buffer, |
| 265 | hb_font_t *font) |
| 266 | { |
| 267 | hb_codepoint_t virama; |
| 268 | switch ((int) buffer->props.script) { |
| 269 | case HB_SCRIPT_DEVANAGARI: virama = 0x094D; break; |
| 270 | case HB_SCRIPT_BENGALI: virama = 0x09CD; break; |
| 271 | case HB_SCRIPT_GURMUKHI: virama = 0x0A4D; break; |
| 272 | case HB_SCRIPT_GUJARATI: virama = 0x0ACD; break; |
| 273 | case HB_SCRIPT_ORIYA: virama = 0x0B4D; break; |
| 274 | case HB_SCRIPT_TAMIL: virama = 0x0BCD; break; |
| 275 | case HB_SCRIPT_TELUGU: virama = 0x0C4D; break; |
| 276 | case HB_SCRIPT_KANNADA: virama = 0x0CCD; break; |
| 277 | case HB_SCRIPT_MALAYALAM: virama = 0x0D4D; break; |
| 278 | case HB_SCRIPT_SINHALA: virama = 0x0DCA; break; |
| 279 | case HB_SCRIPT_KHMER: virama = 0x17D2; break; |
Behdad Esfahbod | 24eacf1 | 2012-08-02 08:42:11 -0400 | [diff] [blame] | 280 | default: virama = 0; break; |
Behdad Esfahbod | 8ef3d53 | 2012-08-02 07:53:18 -0400 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | indic_shape_plan_t indic_plan (map); |
| 284 | |
| 285 | unsigned int consonant_pos = indic_plan.is_old_spec ? 0 : 1; |
| 286 | hb_codepoint_t glyphs[2]; |
| 287 | if (virama && font->get_glyph (virama, 0, &glyphs[1 - consonant_pos])) |
| 288 | { |
Behdad Esfahbod | 24eacf1 | 2012-08-02 08:42:11 -0400 | [diff] [blame] | 289 | /* Technically speaking, the spec says we should apply 'locl' to virama too. |
| 290 | * Maybe one day... */ |
Behdad Esfahbod | 8ef3d53 | 2012-08-02 07:53:18 -0400 | [diff] [blame] | 291 | hb_face_t *face = font->face; |
| 292 | unsigned int count = buffer->len; |
| 293 | for (unsigned int i = 0; i < count; i++) |
| 294 | if (buffer->info[i].indic_position() == POS_BASE_C) { |
Behdad Esfahbod | 24eacf1 | 2012-08-02 08:42:11 -0400 | [diff] [blame] | 295 | glyphs[consonant_pos] = buffer->info[i].codepoint; |
Behdad Esfahbod | 8ef3d53 | 2012-08-02 07:53:18 -0400 | [diff] [blame] | 296 | buffer->info[i].indic_position() = consonant_position_from_font (&indic_plan, glyphs, 2, face); |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
Behdad Esfahbod | 867361c | 2011-06-17 18:35:46 -0400 | [diff] [blame] | 301 | |
Behdad Esfahbod | 7ea58db | 2012-05-11 18:58:57 +0200 | [diff] [blame] | 302 | /* Rules from: |
| 303 | * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx */ |
| 304 | |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 305 | static void |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 306 | initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *basic_mask_array, |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 307 | unsigned int start, unsigned int end) |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 308 | { |
Behdad Esfahbod | ee58f3b | 2011-07-30 19:15:53 -0400 | [diff] [blame] | 309 | hb_glyph_info_t *info = buffer->info; |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 310 | |
Behdad Esfahbod | 617f4ac | 2012-05-13 16:48:03 +0200 | [diff] [blame] | 311 | |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 312 | /* 1. Find base consonant: |
| 313 | * |
| 314 | * The shaping engine finds the base consonant of the syllable, using the |
| 315 | * following algorithm: starting from the end of the syllable, move backwards |
| 316 | * until a consonant is found that does not have a below-base or post-base |
| 317 | * form (post-base forms have to follow below-base forms), or that is not a |
| 318 | * pre-base reordering Ra, or arrive at the first consonant. The consonant |
| 319 | * stopped at will be the base. |
| 320 | * |
| 321 | * o If the syllable starts with Ra + Halant (in a script that has Reph) |
| 322 | * and has more than one consonant, Ra is excluded from candidates for |
| 323 | * base consonants. |
| 324 | */ |
| 325 | |
Behdad Esfahbod | 5e72071 | 2011-07-31 17:51:50 -0400 | [diff] [blame] | 326 | unsigned int base = end; |
Behdad Esfahbod | 76b3409 | 2012-05-09 11:43:43 +0200 | [diff] [blame] | 327 | bool has_reph = false; |
| 328 | |
Behdad Esfahbod | 76b3409 | 2012-05-09 11:43:43 +0200 | [diff] [blame] | 329 | { |
Behdad Esfahbod | 617f4ac | 2012-05-13 16:48:03 +0200 | [diff] [blame] | 330 | /* -> If the syllable starts with Ra + Halant (in a script that has Reph) |
| 331 | * and has more than one consonant, Ra is excluded from candidates for |
| 332 | * base consonants. */ |
| 333 | unsigned int limit = start; |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 334 | if (basic_mask_array[RPHF] && |
Behdad Esfahbod | 617f4ac | 2012-05-13 16:48:03 +0200 | [diff] [blame] | 335 | start + 3 <= end && |
| 336 | info[start].indic_category() == OT_Ra && |
| 337 | info[start + 1].indic_category() == OT_H && |
Behdad Esfahbod | f31d97e | 2012-07-20 14:13:35 -0400 | [diff] [blame] | 338 | (unlikely (buffer->props.script == HB_SCRIPT_SINHALA || buffer->props.script == HB_SCRIPT_TELUGU) ? |
| 339 | info[start + 2].indic_category() == OT_ZWJ /* In Sinhala & Telugu, form Reph only if ZWJ is present */: |
Behdad Esfahbod | 3285e10 | 2012-07-18 17:22:14 -0400 | [diff] [blame] | 340 | !is_joiner (info[start + 2] /* In other scripts, any joiner blocks Reph formation */ ) |
| 341 | )) |
Behdad Esfahbod | 617f4ac | 2012-05-13 16:48:03 +0200 | [diff] [blame] | 342 | { |
| 343 | limit += 2; |
Behdad Esfahbod | 3285e10 | 2012-07-18 17:22:14 -0400 | [diff] [blame] | 344 | while (limit < end && is_joiner (info[limit])) |
| 345 | limit++; |
Behdad Esfahbod | 617f4ac | 2012-05-13 16:48:03 +0200 | [diff] [blame] | 346 | base = start; |
| 347 | has_reph = true; |
| 348 | }; |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 349 | |
Behdad Esfahbod | 14dbdd9 | 2012-07-18 13:13:03 -0400 | [diff] [blame] | 350 | enum base_position_t { |
| 351 | BASE_FIRST, |
| 352 | BASE_LAST |
| 353 | } base_pos; |
| 354 | |
| 355 | switch ((hb_tag_t) buffer->props.script) |
| 356 | { |
Behdad Esfahbod | 34c2150 | 2012-07-23 23:51:29 -0400 | [diff] [blame] | 357 | case HB_SCRIPT_SINHALA: |
Behdad Esfahbod | 14dbdd9 | 2012-07-18 13:13:03 -0400 | [diff] [blame] | 358 | case HB_SCRIPT_KHMER: |
| 359 | base_pos = BASE_FIRST; |
| 360 | break; |
| 361 | |
| 362 | default: |
| 363 | base_pos = BASE_LAST; |
| 364 | break; |
| 365 | } |
| 366 | |
| 367 | if (base_pos == BASE_LAST) |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 368 | { |
| 369 | /* -> starting from the end of the syllable, move backwards */ |
| 370 | unsigned int i = end; |
Behdad Esfahbod | 92a1ad7 | 2012-07-20 18:38:27 -0400 | [diff] [blame] | 371 | bool seen_below = false; |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 372 | do { |
| 373 | i--; |
| 374 | /* -> until a consonant is found */ |
| 375 | if (is_consonant (info[i])) |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 376 | { |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 377 | /* -> that does not have a below-base or post-base form |
| 378 | * (post-base forms have to follow below-base forms), */ |
| 379 | if (info[i].indic_position() != POS_BELOW_C && |
Behdad Esfahbod | 92a1ad7 | 2012-07-20 18:38:27 -0400 | [diff] [blame] | 380 | (info[i].indic_position() != POS_POST_C || seen_below)) |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 381 | { |
| 382 | base = i; |
| 383 | break; |
| 384 | } |
Behdad Esfahbod | 92a1ad7 | 2012-07-20 18:38:27 -0400 | [diff] [blame] | 385 | if (info[i].indic_position() == POS_BELOW_C) |
| 386 | seen_below = true; |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 387 | |
| 388 | /* -> or that is not a pre-base reordering Ra, |
| 389 | * |
Behdad Esfahbod | 25e302d | 2012-07-17 14:25:14 -0400 | [diff] [blame] | 390 | * IMPLEMENTATION NOTES: |
| 391 | * |
| 392 | * Our pre-base reordering Ra's are marked POS_BELOW, so will be skipped |
| 393 | * by the logic above already. |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 394 | */ |
| 395 | |
| 396 | /* -> or arrive at the first consonant. The consonant stopped at will |
| 397 | * be the base. */ |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 398 | base = i; |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 399 | } |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 400 | else |
Behdad Esfahbod | a9e45c3 | 2012-07-20 11:04:15 -0400 | [diff] [blame] | 401 | { |
Behdad Esfahbod | 88f413b | 2012-07-24 03:04:36 -0400 | [diff] [blame] | 402 | /* A ZWJ after a Halant stops the base search, and requests an explicit |
| 403 | * half form. |
| 404 | * A ZWJ before a Halant, requests a subjoined form instead, and hence |
| 405 | * search continues. This is particularly important for Bengali |
| 406 | * sequence Ra,H,Ya that shouls form Ya-Phalaa by subjoining Ya. */ |
| 407 | if (start < i && |
| 408 | info[i].indic_category() == OT_ZWJ && |
| 409 | info[i - 1].indic_category() == OT_H) |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 410 | break; |
Behdad Esfahbod | a9e45c3 | 2012-07-20 11:04:15 -0400 | [diff] [blame] | 411 | } |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 412 | } while (i > limit); |
| 413 | } |
| 414 | else |
| 415 | { |
| 416 | /* In scripts without half forms (eg. Khmer), the first consonant is always the base. */ |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 417 | |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 418 | if (!has_reph) |
| 419 | base = limit; |
Behdad Esfahbod | 34c2150 | 2012-07-23 23:51:29 -0400 | [diff] [blame] | 420 | |
| 421 | /* Find the last base consonant that is not blocked by ZWJ. If there is |
Behdad Esfahbod | 71fd5e8 | 2012-07-24 00:21:16 -0400 | [diff] [blame] | 422 | * a ZWJ right before a base consonant, that would request a subjoined form. */ |
Behdad Esfahbod | 34c2150 | 2012-07-23 23:51:29 -0400 | [diff] [blame] | 423 | for (unsigned int i = limit; i < end; i++) |
| 424 | if (is_consonant (info[i]) && info[i].indic_position() == POS_BASE_C) |
Behdad Esfahbod | 71fd5e8 | 2012-07-24 00:21:16 -0400 | [diff] [blame] | 425 | { |
| 426 | if (limit < i && info[i - 1].indic_category() == OT_ZWJ) |
| 427 | break; |
| 428 | else |
| 429 | base = i; |
| 430 | } |
Behdad Esfahbod | 34c2150 | 2012-07-23 23:51:29 -0400 | [diff] [blame] | 431 | |
| 432 | /* Mark all subsequent consonants as below. */ |
| 433 | for (unsigned int i = base + 1; i < end; i++) |
| 434 | if (is_consonant (info[i]) && info[i].indic_position() == POS_BASE_C) |
| 435 | info[i].indic_position() = POS_BELOW_C; |
Behdad Esfahbod | 5d32690 | 2012-07-17 14:23:28 -0400 | [diff] [blame] | 436 | } |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 437 | |
Behdad Esfahbod | 617f4ac | 2012-05-13 16:48:03 +0200 | [diff] [blame] | 438 | /* -> If the syllable starts with Ra + Halant (in a script that has Reph) |
| 439 | * and has more than one consonant, Ra is excluded from candidates for |
Behdad Esfahbod | 2278eef | 2012-07-24 00:26:43 -0400 | [diff] [blame] | 440 | * base consonants. |
| 441 | * |
| 442 | * Only do this for unforced Reph. (ie. not for Ra,H,ZWJ. */ |
| 443 | if (has_reph && base == start && start + 2 == limit) { |
Behdad Esfahbod | 617f4ac | 2012-05-13 16:48:03 +0200 | [diff] [blame] | 444 | /* Have no other consonant, so Reph is not formed and Ra becomes base. */ |
| 445 | has_reph = false; |
| 446 | } |
Behdad Esfahbod | 5e4e21f | 2012-05-13 16:46:08 +0200 | [diff] [blame] | 447 | } |
Behdad Esfahbod | 2278eef | 2012-07-24 00:26:43 -0400 | [diff] [blame] | 448 | |
Behdad Esfahbod | 34c2150 | 2012-07-23 23:51:29 -0400 | [diff] [blame] | 449 | if (base < end) |
| 450 | info[base].indic_position() = POS_BASE_C; |
Behdad Esfahbod | 3d25079 | 2012-05-10 11:37:42 +0200 | [diff] [blame] | 451 | |
| 452 | |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 453 | /* 2. Decompose and reorder Matras: |
| 454 | * |
| 455 | * Each matra and any syllable modifier sign in the cluster are moved to the |
| 456 | * appropriate position relative to the consonant(s) in the cluster. The |
| 457 | * shaping engine decomposes two- or three-part matras into their constituent |
| 458 | * parts before any repositioning. Matra characters are classified by which |
| 459 | * consonant in a conjunct they have affinity for and are reordered to the |
| 460 | * following positions: |
| 461 | * |
| 462 | * o Before first half form in the syllable |
| 463 | * o After subjoined consonants |
| 464 | * o After post-form consonant |
| 465 | * o After main consonant (for above marks) |
| 466 | * |
| 467 | * IMPLEMENTATION NOTES: |
| 468 | * |
| 469 | * The normalize() routine has already decomposed matras for us, so we don't |
| 470 | * need to worry about that. |
| 471 | */ |
| 472 | |
| 473 | |
| 474 | /* 3. Reorder marks to canonical order: |
| 475 | * |
| 476 | * Adjacent nukta and halant or nukta and vedic sign are always repositioned |
| 477 | * if necessary, so that the nukta is first. |
| 478 | * |
| 479 | * IMPLEMENTATION NOTES: |
| 480 | * |
| 481 | * We don't need to do this: the normalize() routine already did this for us. |
| 482 | */ |
| 483 | |
| 484 | |
Behdad Esfahbod | 45d6f29 | 2011-07-30 14:44:30 -0400 | [diff] [blame] | 485 | /* Reorder characters */ |
| 486 | |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 487 | for (unsigned int i = start; i < base; i++) |
Behdad Esfahbod | 900cf3d | 2012-07-20 10:18:23 -0400 | [diff] [blame] | 488 | info[i].indic_position() = MIN (POS_PRE_C, (indic_position_t) info[i].indic_position()); |
Behdad Esfahbod | 55f70eb | 2012-07-17 12:50:13 -0400 | [diff] [blame] | 489 | |
Behdad Esfahbod | 075d671 | 2012-07-18 15:41:53 -0400 | [diff] [blame] | 490 | if (base < end) |
| 491 | info[base].indic_position() = POS_BASE_C; |
Behdad Esfahbod | 45d6f29 | 2011-07-30 14:44:30 -0400 | [diff] [blame] | 492 | |
Behdad Esfahbod | 55f70eb | 2012-07-17 12:50:13 -0400 | [diff] [blame] | 493 | /* Mark final consonants. A final consonant is one appearing after a matra, |
| 494 | * like in Khmer. */ |
| 495 | for (unsigned int i = base + 1; i < end; i++) |
| 496 | if (info[i].indic_category() == OT_M) { |
| 497 | for (unsigned int j = i + 1; j < end; j++) |
| 498 | if (is_consonant (info[j])) { |
| 499 | info[j].indic_position() = POS_FINAL_C; |
| 500 | break; |
| 501 | } |
| 502 | break; |
| 503 | } |
| 504 | |
Behdad Esfahbod | fd06bf5 | 2011-07-30 20:14:44 -0400 | [diff] [blame] | 505 | /* Handle beginning Ra */ |
Behdad Esfahbod | 5e4e21f | 2012-05-13 16:46:08 +0200 | [diff] [blame] | 506 | if (has_reph) |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 507 | info[start].indic_position() = POS_RA_TO_BECOME_REPH; |
Behdad Esfahbod | fd06bf5 | 2011-07-30 20:14:44 -0400 | [diff] [blame] | 508 | |
Behdad Esfahbod | f5bc272 | 2011-07-30 21:08:10 -0400 | [diff] [blame] | 509 | /* For old-style Indic script tags, move the first post-base Halant after |
| 510 | * last consonant. */ |
Behdad Esfahbod | a3e04be | 2012-07-16 13:47:19 -0400 | [diff] [blame] | 511 | if (IS_OLD_INDIC_TAG (map->get_chosen_script (0))) { |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 512 | for (unsigned int i = base + 1; i < end; i++) |
Behdad Esfahbod | f5bc272 | 2011-07-30 21:08:10 -0400 | [diff] [blame] | 513 | if (info[i].indic_category() == OT_H) { |
| 514 | unsigned int j; |
| 515 | for (j = end - 1; j > i; j--) |
Behdad Esfahbod | 190eb31 | 2012-05-10 12:17:16 +0200 | [diff] [blame] | 516 | if (is_consonant (info[j])) |
Behdad Esfahbod | f5bc272 | 2011-07-30 21:08:10 -0400 | [diff] [blame] | 517 | break; |
| 518 | if (j > i) { |
| 519 | /* Move Halant to after last consonant. */ |
| 520 | hb_glyph_info_t t = info[i]; |
| 521 | memmove (&info[i], &info[i + 1], (j - i) * sizeof (info[0])); |
| 522 | info[j] = t; |
| 523 | } |
| 524 | break; |
| 525 | } |
| 526 | } |
| 527 | |
Behdad Esfahbod | 81202bd | 2012-07-20 15:10:02 -0400 | [diff] [blame] | 528 | /* Attach misc marks to previous char to move with them. */ |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 529 | { |
Behdad Esfahbod | 81202bd | 2012-07-20 15:10:02 -0400 | [diff] [blame] | 530 | indic_position_t last_pos = POS_START; |
| 531 | for (unsigned int i = start; i < end; i++) |
| 532 | { |
| 533 | if ((FLAG (info[i].indic_category()) & (JOINER_FLAGS | FLAG (OT_N) | FLAG (OT_RS) | HALANT_OR_COENG_FLAGS))) |
| 534 | { |
| 535 | info[i].indic_position() = last_pos; |
| 536 | if (unlikely (indic_options ().uniscribe_bug_compatible && |
| 537 | info[i].indic_category() == OT_H && |
| 538 | info[i].indic_position() == POS_PRE_M)) |
| 539 | { |
| 540 | /* |
| 541 | * Uniscribe doesn't move the Halant with Left Matra. |
| 542 | * TEST: U+092B,U+093F,U+094DE |
| 543 | */ |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 544 | for (unsigned int j = i; j > start; j--) |
Behdad Esfahbod | 6a091df | 2012-05-11 21:42:27 +0200 | [diff] [blame] | 545 | if (info[j - 1].indic_position() != POS_PRE_M) { |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 546 | info[i].indic_position() = info[j - 1].indic_position(); |
| 547 | break; |
| 548 | } |
Behdad Esfahbod | 81202bd | 2012-07-20 15:10:02 -0400 | [diff] [blame] | 549 | } |
| 550 | } else if (info[i].indic_position() != POS_SMVD) { |
| 551 | last_pos = (indic_position_t) info[i].indic_position(); |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 552 | } |
Behdad Esfahbod | 81202bd | 2012-07-20 15:10:02 -0400 | [diff] [blame] | 553 | } |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 554 | } |
Behdad Esfahbod | 74ccc6a | 2012-07-17 11:16:19 -0400 | [diff] [blame] | 555 | /* Re-attach ZWJ, ZWNJ, and halant to next char, for after-base consonants. */ |
| 556 | { |
| 557 | unsigned int last_halant = end; |
| 558 | for (unsigned int i = base + 1; i < end; i++) |
Behdad Esfahbod | deb521d | 2012-07-17 11:37:32 -0400 | [diff] [blame] | 559 | if (is_halant_or_coeng (info[i])) |
Behdad Esfahbod | 74ccc6a | 2012-07-17 11:16:19 -0400 | [diff] [blame] | 560 | last_halant = i; |
| 561 | else if (is_consonant (info[i])) { |
| 562 | for (unsigned int j = last_halant; j < i; j++) |
Behdad Esfahbod | 81202bd | 2012-07-20 15:10:02 -0400 | [diff] [blame] | 563 | if (info[j].indic_position() != POS_SMVD) |
| 564 | info[j].indic_position() = info[i].indic_position(); |
Behdad Esfahbod | 74ccc6a | 2012-07-17 11:16:19 -0400 | [diff] [blame] | 565 | } |
| 566 | } |
Behdad Esfahbod | 45d6f29 | 2011-07-30 14:44:30 -0400 | [diff] [blame] | 567 | |
Behdad Esfahbod | a391ff5 | 2012-05-10 11:31:20 +0200 | [diff] [blame] | 568 | { |
Behdad Esfahbod | 7b2a7da | 2012-07-22 23:58:55 -0400 | [diff] [blame] | 569 | /* Things are out-of-control for post base positions, they may shuffle |
| 570 | * around like crazy, so merge clusters. For pre-base stuff, we handle |
| 571 | * cluster issues in final reordering. */ |
| 572 | buffer->merge_clusters (base, end); |
Behdad Esfahbod | a391ff5 | 2012-05-10 11:31:20 +0200 | [diff] [blame] | 573 | /* Sit tight, rock 'n roll! */ |
Behdad Esfahbod | d3637ed | 2012-05-10 10:51:38 +0200 | [diff] [blame] | 574 | hb_bubble_sort (info + start, end - start, compare_indic_order); |
Behdad Esfahbod | a391ff5 | 2012-05-10 11:31:20 +0200 | [diff] [blame] | 575 | /* Find base again */ |
| 576 | base = end; |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 577 | for (unsigned int i = start; i < end; i++) |
Behdad Esfahbod | a391ff5 | 2012-05-10 11:31:20 +0200 | [diff] [blame] | 578 | if (info[i].indic_position() == POS_BASE_C) { |
| 579 | base = i; |
| 580 | break; |
| 581 | } |
| 582 | } |
Behdad Esfahbod | 45d6f29 | 2011-07-30 14:44:30 -0400 | [diff] [blame] | 583 | |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 584 | /* Setup masks now */ |
| 585 | |
Behdad Esfahbod | 2816839 | 2011-07-31 16:00:35 -0400 | [diff] [blame] | 586 | { |
| 587 | hb_mask_t mask; |
| 588 | |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 589 | /* Reph */ |
Behdad Esfahbod | 668c604 | 2012-05-11 15:34:13 +0200 | [diff] [blame] | 590 | for (unsigned int i = start; i < end && info[i].indic_position() == POS_RA_TO_BECOME_REPH; i++) |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 591 | info[i].mask |= basic_mask_array[RPHF]; |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 592 | |
Behdad Esfahbod | 2816839 | 2011-07-31 16:00:35 -0400 | [diff] [blame] | 593 | /* Pre-base */ |
Behdad Esfahbod | 20b68e6 | 2012-07-20 10:47:46 -0400 | [diff] [blame] | 594 | mask = basic_mask_array[HALF]; |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 595 | for (unsigned int i = start; i < base; i++) |
Behdad Esfahbod | 2816839 | 2011-07-31 16:00:35 -0400 | [diff] [blame] | 596 | info[i].mask |= mask; |
| 597 | /* Base */ |
Behdad Esfahbod | 20b68e6 | 2012-07-20 10:47:46 -0400 | [diff] [blame] | 598 | mask = 0; |
Behdad Esfahbod | 075d671 | 2012-07-18 15:41:53 -0400 | [diff] [blame] | 599 | if (base < end) |
| 600 | info[base].mask |= mask; |
Behdad Esfahbod | 2816839 | 2011-07-31 16:00:35 -0400 | [diff] [blame] | 601 | /* Post-base */ |
Behdad Esfahbod | 20b68e6 | 2012-07-20 10:47:46 -0400 | [diff] [blame] | 602 | mask = basic_mask_array[BLWF] | basic_mask_array[ABVF] | basic_mask_array[PSTF]; |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 603 | for (unsigned int i = base + 1; i < end; i++) |
Behdad Esfahbod | 2816839 | 2011-07-31 16:00:35 -0400 | [diff] [blame] | 604 | info[i].mask |= mask; |
| 605 | } |
Behdad Esfahbod | 9da0487 | 2011-07-31 13:46:44 -0400 | [diff] [blame] | 606 | |
Behdad Esfahbod | 17d7de9 | 2012-07-16 15:20:15 -0400 | [diff] [blame] | 607 | /* XXX This will not match for old-Indic spec since the Halant-Ra order is reversed already. */ |
Behdad Esfahbod | 5f0eaaa | 2012-07-20 15:47:24 -0400 | [diff] [blame] | 608 | if (basic_mask_array[PREF] && base + 2 < end) |
Behdad Esfahbod | 17d7de9 | 2012-07-16 15:20:15 -0400 | [diff] [blame] | 609 | { |
Behdad Esfahbod | 771a8f5 | 2012-07-23 20:07:50 -0400 | [diff] [blame] | 610 | /* Find a Halant,Ra sequence and mark it for pre-base reordering processing. */ |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 611 | for (unsigned int i = base + 1; i + 1 < end; i++) |
Behdad Esfahbod | deb521d | 2012-07-17 11:37:32 -0400 | [diff] [blame] | 612 | if (is_halant_or_coeng (info[i]) && |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 613 | info[i + 1].indic_category() == OT_Ra) |
| 614 | { |
Behdad Esfahbod | 0201e0a | 2012-07-17 13:55:10 -0400 | [diff] [blame] | 615 | info[i++].mask |= basic_mask_array[PREF]; |
| 616 | info[i++].mask |= basic_mask_array[PREF]; |
| 617 | |
| 618 | /* Mark the subsequent stuff with 'cfar'. Used in Khmer. |
| 619 | * Read the feature spec. |
| 620 | * This allows distinguishing the following cases with MS Khmer fonts: |
| 621 | * U+1784,U+17D2,U+179A,U+17D2,U+1782 |
| 622 | * U+1784,U+17D2,U+1782,U+17D2,U+179A |
| 623 | */ |
| 624 | for (; i < end; i++) |
| 625 | info[i].mask |= basic_mask_array[CFAR]; |
| 626 | |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 627 | break; |
| 628 | } |
Behdad Esfahbod | 17d7de9 | 2012-07-16 15:20:15 -0400 | [diff] [blame] | 629 | } |
| 630 | |
Behdad Esfahbod | 9da0487 | 2011-07-31 13:46:44 -0400 | [diff] [blame] | 631 | /* Apply ZWJ/ZWNJ effects */ |
Behdad Esfahbod | 3c2ea94 | 2012-05-11 16:23:38 +0200 | [diff] [blame] | 632 | for (unsigned int i = start + 1; i < end; i++) |
Behdad Esfahbod | 9da0487 | 2011-07-31 13:46:44 -0400 | [diff] [blame] | 633 | if (is_joiner (info[i])) { |
| 634 | bool non_joiner = info[i].indic_category() == OT_ZWNJ; |
Behdad Esfahbod | 6b37bc8 | 2011-07-31 15:57:00 -0400 | [diff] [blame] | 635 | unsigned int j = i; |
Behdad Esfahbod | 9da0487 | 2011-07-31 13:46:44 -0400 | [diff] [blame] | 636 | |
| 637 | do { |
Behdad Esfahbod | 9da0487 | 2011-07-31 13:46:44 -0400 | [diff] [blame] | 638 | j--; |
Behdad Esfahbod | 6b37bc8 | 2011-07-31 15:57:00 -0400 | [diff] [blame] | 639 | |
Behdad Esfahbod | 20b68e6 | 2012-07-20 10:47:46 -0400 | [diff] [blame] | 640 | /* A ZWJ disables CJCT, however, it's mere presence is enough |
| 641 | * to disable ligation. No explicit action needed. */ |
| 642 | |
| 643 | /* A ZWNJ disables HALF. */ |
Behdad Esfahbod | 6b37bc8 | 2011-07-31 15:57:00 -0400 | [diff] [blame] | 644 | if (non_joiner) |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 645 | info[j].mask &= ~basic_mask_array[HALF]; |
Behdad Esfahbod | 6b37bc8 | 2011-07-31 15:57:00 -0400 | [diff] [blame] | 646 | |
Behdad Esfahbod | 9da0487 | 2011-07-31 13:46:44 -0400 | [diff] [blame] | 647 | } while (j > start && !is_consonant (info[j])); |
| 648 | } |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | |
| 652 | static void |
Behdad Esfahbod | 9f377ed | 2012-05-13 16:13:44 +0200 | [diff] [blame] | 653 | initial_reordering_vowel_syllable (const hb_ot_map_t *map, |
| 654 | hb_buffer_t *buffer, |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 655 | hb_mask_t *basic_mask_array, |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 656 | unsigned int start, unsigned int end) |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 657 | { |
Behdad Esfahbod | c5306b6 | 2012-05-10 12:07:33 +0200 | [diff] [blame] | 658 | /* We made the vowels look like consonants. So let's call the consonant logic! */ |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 659 | initial_reordering_consonant_syllable (map, buffer, basic_mask_array, start, end); |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | static void |
Behdad Esfahbod | 9f377ed | 2012-05-13 16:13:44 +0200 | [diff] [blame] | 663 | initial_reordering_standalone_cluster (const hb_ot_map_t *map, |
| 664 | hb_buffer_t *buffer, |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 665 | hb_mask_t *basic_mask_array, |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 666 | unsigned int start, unsigned int end) |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 667 | { |
Behdad Esfahbod | 18c06e1 | 2012-05-11 20:02:14 +0200 | [diff] [blame] | 668 | /* We treat NBSP/dotted-circle as if they are consonants, so we should just chain. |
| 669 | * Only if not in compatibility mode that is... */ |
| 670 | |
Behdad Esfahbod | a2b471d | 2012-06-05 15:17:44 -0400 | [diff] [blame] | 671 | if (indic_options ().uniscribe_bug_compatible) |
Behdad Esfahbod | 18c06e1 | 2012-05-11 20:02:14 +0200 | [diff] [blame] | 672 | { |
| 673 | /* For dotted-circle, this is what Uniscribe does: |
| 674 | * If dotted-circle is the last glyph, it just does nothing. |
| 675 | * Ie. It doesn't form Reph. */ |
| 676 | if (buffer->info[end - 1].indic_category() == OT_DOTTEDCIRCLE) |
| 677 | return; |
| 678 | } |
| 679 | |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 680 | initial_reordering_consonant_syllable (map, buffer, basic_mask_array, start, end); |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | static void |
Behdad Esfahbod | 9f377ed | 2012-05-13 16:13:44 +0200 | [diff] [blame] | 684 | initial_reordering_non_indic (const hb_ot_map_t *map HB_UNUSED, |
| 685 | hb_buffer_t *buffer HB_UNUSED, |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 686 | hb_mask_t *basic_mask_array HB_UNUSED, |
Behdad Esfahbod | 3f18236 | 2012-05-13 16:20:10 +0200 | [diff] [blame] | 687 | unsigned int start HB_UNUSED, unsigned int end HB_UNUSED) |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 688 | { |
| 689 | /* Nothing to do right now. If we ever switch to using the output |
| 690 | * buffer in the reordering process, we'd need to next_glyph() here. */ |
| 691 | } |
| 692 | |
| 693 | #include "hb-ot-shape-complex-indic-machine.hh" |
| 694 | |
| 695 | static void |
| 696 | initial_reordering (const hb_ot_map_t *map, |
Behdad Esfahbod | 24eacf1 | 2012-08-02 08:42:11 -0400 | [diff] [blame] | 697 | hb_font_t *font, |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame^] | 698 | hb_buffer_t *buffer) |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 699 | { |
Behdad Esfahbod | 24eacf1 | 2012-08-02 08:42:11 -0400 | [diff] [blame] | 700 | update_consonant_positions (map, buffer, font); |
| 701 | |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 702 | hb_mask_t basic_mask_array[ARRAY_LENGTH (indic_basic_features)] = {0}; |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 703 | unsigned int num_masks = ARRAY_LENGTH (indic_basic_features); |
| 704 | for (unsigned int i = 0; i < num_masks; i++) |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 705 | basic_mask_array[i] = map->get_1_mask (indic_basic_features[i].tag); |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 706 | |
Behdad Esfahbod | 70fe77b | 2012-07-16 14:52:18 -0400 | [diff] [blame] | 707 | find_syllables (map, buffer, basic_mask_array); |
Behdad Esfahbod | b9ddbd5 | 2011-06-02 17:43:12 -0400 | [diff] [blame] | 708 | } |
| 709 | |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 710 | static void |
Behdad Esfahbod | 46e645e | 2012-07-16 15:30:05 -0400 | [diff] [blame] | 711 | final_reordering_syllable (hb_buffer_t *buffer, |
| 712 | hb_mask_t init_mask, hb_mask_t pref_mask, |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 713 | unsigned int start, unsigned int end) |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 714 | { |
Behdad Esfahbod | 4ac9e98 | 2012-05-10 12:53:53 +0200 | [diff] [blame] | 715 | hb_glyph_info_t *info = buffer->info; |
| 716 | |
Behdad Esfahbod | e7be057 | 2011-07-31 15:18:57 -0400 | [diff] [blame] | 717 | /* 4. Final reordering: |
| 718 | * |
| 719 | * After the localized forms and basic shaping forms GSUB features have been |
| 720 | * applied (see below), the shaping engine performs some final glyph |
| 721 | * reordering before applying all the remaining font features to the entire |
| 722 | * cluster. |
Behdad Esfahbod | 4ac9e98 | 2012-05-10 12:53:53 +0200 | [diff] [blame] | 723 | */ |
| 724 | |
| 725 | /* Find base again */ |
Behdad Esfahbod | 5f0eaaa | 2012-07-20 15:47:24 -0400 | [diff] [blame] | 726 | unsigned int base; |
| 727 | for (base = start; base < end; base++) |
| 728 | if (info[base].indic_position() >= POS_BASE_C) { |
| 729 | if (start < base && info[base].indic_position() > POS_BASE_C) |
| 730 | base--; |
| 731 | break; |
| 732 | } |
Behdad Esfahbod | 4ac9e98 | 2012-05-10 12:53:53 +0200 | [diff] [blame] | 733 | |
Behdad Esfahbod | 4705a70 | 2012-05-10 13:09:08 +0200 | [diff] [blame] | 734 | |
Behdad Esfahbod | 4ac9e98 | 2012-05-10 12:53:53 +0200 | [diff] [blame] | 735 | /* o Reorder matras: |
Behdad Esfahbod | e7be057 | 2011-07-31 15:18:57 -0400 | [diff] [blame] | 736 | * |
| 737 | * If a pre-base matra character had been reordered before applying basic |
| 738 | * features, the glyph can be moved closer to the main consonant based on |
| 739 | * whether half-forms had been formed. Actual position for the matra is |
| 740 | * defined as “after last standalone halant glyph, after initial matra |
| 741 | * position and before the main consonant”. If ZWJ or ZWNJ follow this |
| 742 | * halant, position is moved after it. |
Behdad Esfahbod | 4ac9e98 | 2012-05-10 12:53:53 +0200 | [diff] [blame] | 743 | */ |
| 744 | |
Behdad Esfahbod | 65c43ac | 2012-07-24 03:36:47 -0400 | [diff] [blame] | 745 | if (start + 1 < end && start < base) /* Otherwise there can't be any pre-base matra characters. */ |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 746 | { |
Behdad Esfahbod | 65c43ac | 2012-07-24 03:36:47 -0400 | [diff] [blame] | 747 | /* If we lost track of base, alas, position before last thingy. */ |
| 748 | unsigned int new_pos = base == end ? base - 2 : base - 1; |
Behdad Esfahbod | 4ac9e98 | 2012-05-10 12:53:53 +0200 | [diff] [blame] | 749 | |
Behdad Esfahbod | 65c43ac | 2012-07-24 03:36:47 -0400 | [diff] [blame] | 750 | /* Malayalam does not have "half" forms or explicit virama forms. |
| 751 | * The glyphs formed by 'half' are Chillus. We want to position |
| 752 | * matra after them all. |
| 753 | */ |
| 754 | if (buffer->props.script != HB_SCRIPT_MALAYALAM) |
| 755 | { |
| 756 | while (new_pos > start && |
| 757 | !(is_one_of (info[new_pos], (FLAG (OT_M) | FLAG (OT_H) | FLAG (OT_Coeng))))) |
| 758 | new_pos--; |
| 759 | |
| 760 | /* If we found no Halant we are done. |
| 761 | * Otherwise only proceed if the Halant does |
| 762 | * not belong to the Matra itself! */ |
| 763 | if (is_halant_or_coeng (info[new_pos]) && |
| 764 | info[new_pos].indic_position() != POS_PRE_M) |
| 765 | { |
| 766 | /* -> If ZWJ or ZWNJ follow this halant, position is moved after it. */ |
| 767 | if (new_pos + 1 < end && is_joiner (info[new_pos + 1])) |
| 768 | new_pos++; |
| 769 | } |
| 770 | else |
| 771 | new_pos = start; /* No move. */ |
| 772 | } |
| 773 | |
| 774 | if (start < new_pos) |
| 775 | { |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 776 | /* Now go see if there's actually any matras... */ |
Behdad Esfahbod | 921ce5b | 2012-07-16 15:26:56 -0400 | [diff] [blame] | 777 | for (unsigned int i = new_pos; i > start; i--) |
Behdad Esfahbod | 6a091df | 2012-05-11 21:42:27 +0200 | [diff] [blame] | 778 | if (info[i - 1].indic_position () == POS_PRE_M) |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 779 | { |
Behdad Esfahbod | 1a1dbe9 | 2012-07-16 15:40:33 -0400 | [diff] [blame] | 780 | unsigned int old_pos = i - 1; |
| 781 | hb_glyph_info_t tmp = info[old_pos]; |
| 782 | memmove (&info[old_pos], &info[old_pos + 1], (new_pos - old_pos) * sizeof (info[0])); |
| 783 | info[new_pos] = tmp; |
Behdad Esfahbod | 921ce5b | 2012-07-16 15:26:56 -0400 | [diff] [blame] | 784 | new_pos--; |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 785 | } |
Behdad Esfahbod | 2cc933a | 2012-07-23 08:22:55 -0400 | [diff] [blame] | 786 | buffer->merge_clusters (new_pos, MIN (end, base + 1)); |
Behdad Esfahbod | abb3239 | 2012-07-22 23:55:19 -0400 | [diff] [blame] | 787 | } else { |
Behdad Esfahbod | e6b01a8 | 2012-07-23 00:11:26 -0400 | [diff] [blame] | 788 | for (unsigned int i = start; i < base; i++) |
Behdad Esfahbod | abb3239 | 2012-07-22 23:55:19 -0400 | [diff] [blame] | 789 | if (info[i].indic_position () == POS_PRE_M) { |
Behdad Esfahbod | 2cc933a | 2012-07-23 08:22:55 -0400 | [diff] [blame] | 790 | buffer->merge_clusters (i, MIN (end, base + 1)); |
Behdad Esfahbod | abb3239 | 2012-07-22 23:55:19 -0400 | [diff] [blame] | 791 | break; |
| 792 | } |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 793 | } |
Behdad Esfahbod | 4ac9e98 | 2012-05-10 12:53:53 +0200 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | |
| 797 | /* o Reorder reph: |
Behdad Esfahbod | e7be057 | 2011-07-31 15:18:57 -0400 | [diff] [blame] | 798 | * |
| 799 | * Reph’s original position is always at the beginning of the syllable, |
| 800 | * (i.e. it is not reordered at the character reordering stage). However, |
| 801 | * it will be reordered according to the basic-forms shaping results. |
| 802 | * Possible positions for reph, depending on the script, are; after main, |
| 803 | * before post-base consonant forms, and after post-base consonant forms. |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 804 | */ |
| 805 | |
| 806 | /* If there's anything after the Ra that has the REPH pos, it ought to be halant. |
| 807 | * Which means that the font has failed to ligate the Reph. In which case, we |
| 808 | * shouldn't move. */ |
| 809 | if (start + 1 < end && |
| 810 | info[start].indic_position() == POS_RA_TO_BECOME_REPH && |
| 811 | info[start + 1].indic_position() != POS_RA_TO_BECOME_REPH) |
| 812 | { |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 813 | unsigned int new_reph_pos; |
| 814 | |
| 815 | enum reph_position_t { |
Behdad Esfahbod | f893672 | 2012-05-11 21:10:03 +0200 | [diff] [blame] | 816 | REPH_AFTER_MAIN, |
| 817 | REPH_BEFORE_SUBSCRIPT, |
| 818 | REPH_AFTER_SUBSCRIPT, |
| 819 | REPH_BEFORE_POSTSCRIPT, |
Behdad Esfahbod | 9fc7a11 | 2012-06-04 08:28:19 -0400 | [diff] [blame] | 820 | REPH_AFTER_POSTSCRIPT |
Behdad Esfahbod | f893672 | 2012-05-11 21:10:03 +0200 | [diff] [blame] | 821 | } reph_pos; |
| 822 | |
| 823 | /* XXX Figure out old behavior too */ |
Behdad Esfahbod | 7f852b6 | 2012-05-11 23:10:31 +0200 | [diff] [blame] | 824 | switch ((hb_tag_t) buffer->props.script) |
Behdad Esfahbod | f893672 | 2012-05-11 21:10:03 +0200 | [diff] [blame] | 825 | { |
| 826 | case HB_SCRIPT_MALAYALAM: |
| 827 | case HB_SCRIPT_ORIYA: |
Behdad Esfahbod | 34c2150 | 2012-07-23 23:51:29 -0400 | [diff] [blame] | 828 | case HB_SCRIPT_SINHALA: |
Behdad Esfahbod | f893672 | 2012-05-11 21:10:03 +0200 | [diff] [blame] | 829 | reph_pos = REPH_AFTER_MAIN; |
| 830 | break; |
| 831 | |
| 832 | case HB_SCRIPT_GURMUKHI: |
| 833 | reph_pos = REPH_BEFORE_SUBSCRIPT; |
| 834 | break; |
| 835 | |
| 836 | case HB_SCRIPT_BENGALI: |
| 837 | reph_pos = REPH_AFTER_SUBSCRIPT; |
| 838 | break; |
| 839 | |
| 840 | default: |
| 841 | case HB_SCRIPT_DEVANAGARI: |
| 842 | case HB_SCRIPT_GUJARATI: |
| 843 | reph_pos = REPH_BEFORE_POSTSCRIPT; |
| 844 | break; |
| 845 | |
| 846 | case HB_SCRIPT_KANNADA: |
| 847 | case HB_SCRIPT_TAMIL: |
| 848 | case HB_SCRIPT_TELUGU: |
| 849 | reph_pos = REPH_AFTER_POSTSCRIPT; |
| 850 | break; |
| 851 | } |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 852 | |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 853 | /* 1. If reph should be positioned after post-base consonant forms, |
| 854 | * proceed to step 5. |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 855 | */ |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 856 | if (reph_pos == REPH_AFTER_POSTSCRIPT) |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 857 | { |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 858 | goto reph_step_5; |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | /* 2. If the reph repositioning class is not after post-base: target |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 862 | * position is after the first explicit halant glyph between the |
| 863 | * first post-reph consonant and last main consonant. If ZWJ or ZWNJ |
| 864 | * are following this halant, position is moved after it. If such |
| 865 | * position is found, this is the target position. Otherwise, |
| 866 | * proceed to the next step. |
| 867 | * |
| 868 | * Note: in old-implementation fonts, where classifications were |
| 869 | * fixed in shaping engine, there was no case where reph position |
| 870 | * will be found on this step. |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 871 | */ |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 872 | { |
| 873 | new_reph_pos = start + 1; |
Behdad Esfahbod | deb521d | 2012-07-17 11:37:32 -0400 | [diff] [blame] | 874 | while (new_reph_pos < base && !is_halant_or_coeng (info[new_reph_pos])) |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 875 | new_reph_pos++; |
| 876 | |
Behdad Esfahbod | deb521d | 2012-07-17 11:37:32 -0400 | [diff] [blame] | 877 | if (new_reph_pos < base && is_halant_or_coeng (info[new_reph_pos])) { |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 878 | /* ->If ZWJ or ZWNJ are following this halant, position is moved after it. */ |
| 879 | if (new_reph_pos + 1 < base && is_joiner (info[new_reph_pos + 1])) |
| 880 | new_reph_pos++; |
| 881 | goto reph_move; |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | /* 3. If reph should be repositioned after the main consonant: find the |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 886 | * first consonant not ligated with main, or find the first |
| 887 | * consonant that is not a potential pre-base reordering Ra. |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 888 | */ |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 889 | if (reph_pos == REPH_AFTER_MAIN) |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 890 | { |
Behdad Esfahbod | b504e06 | 2012-07-16 15:21:12 -0400 | [diff] [blame] | 891 | new_reph_pos = base; |
| 892 | /* XXX Skip potential pre-base reordering Ra. */ |
Behdad Esfahbod | 34ae336 | 2012-07-20 16:17:28 -0400 | [diff] [blame] | 893 | while (new_reph_pos + 1 < end && info[new_reph_pos + 1].indic_position() <= POS_AFTER_MAIN) |
Behdad Esfahbod | b504e06 | 2012-07-16 15:21:12 -0400 | [diff] [blame] | 894 | new_reph_pos++; |
| 895 | if (new_reph_pos < end) |
| 896 | goto reph_move; |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | /* 4. If reph should be positioned before post-base consonant, find |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 900 | * first post-base classified consonant not ligated with main. If no |
| 901 | * consonant is found, the target position should be before the |
| 902 | * first matra, syllable modifier sign or vedic sign. |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 903 | */ |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 904 | /* This is our take on what step 4 is trying to say (and failing, BADLY). */ |
| 905 | if (reph_pos == REPH_AFTER_SUBSCRIPT) |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 906 | { |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 907 | new_reph_pos = base; |
| 908 | while (new_reph_pos < end && |
Behdad Esfahbod | be8b9f5 | 2012-07-19 12:11:12 -0400 | [diff] [blame] | 909 | !( FLAG (info[new_reph_pos + 1].indic_position()) & (FLAG (POS_POST_C) | FLAG (POS_AFTER_POST) | FLAG (POS_SMVD)))) |
Behdad Esfahbod | 9d0d319 | 2012-05-11 21:36:32 +0200 | [diff] [blame] | 910 | new_reph_pos++; |
| 911 | if (new_reph_pos < end) |
| 912 | goto reph_move; |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | /* 5. If no consonant is found in steps 3 or 4, move reph to a position |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 916 | * immediately before the first post-base matra, syllable modifier |
| 917 | * sign or vedic sign that has a reordering class after the intended |
| 918 | * reph position. For example, if the reordering position for reph |
| 919 | * is post-main, it will skip above-base matras that also have a |
| 920 | * post-main position. |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 921 | */ |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 922 | reph_step_5: |
| 923 | { |
Behdad Esfahbod | d0e68db | 2012-07-20 11:25:41 -0400 | [diff] [blame] | 924 | /* Copied from step 2. */ |
| 925 | new_reph_pos = start + 1; |
| 926 | while (new_reph_pos < base && !is_halant_or_coeng (info[new_reph_pos])) |
| 927 | new_reph_pos++; |
| 928 | |
| 929 | if (new_reph_pos < base && is_halant_or_coeng (info[new_reph_pos])) { |
| 930 | /* ->If ZWJ or ZWNJ are following this halant, position is moved after it. */ |
| 931 | if (new_reph_pos + 1 < base && is_joiner (info[new_reph_pos + 1])) |
| 932 | new_reph_pos++; |
| 933 | goto reph_move; |
| 934 | } |
Behdad Esfahbod | 8df5636 | 2012-05-10 15:41:04 +0200 | [diff] [blame] | 935 | } |
| 936 | |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 937 | /* 6. Otherwise, reorder reph to the end of the syllable. |
| 938 | */ |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 939 | { |
| 940 | new_reph_pos = end - 1; |
| 941 | while (new_reph_pos > start && info[new_reph_pos].indic_position() == POS_SMVD) |
| 942 | new_reph_pos--; |
| 943 | |
Behdad Esfahbod | 892eb78 | 2012-05-11 16:54:40 +0200 | [diff] [blame] | 944 | /* |
| 945 | * If the Reph is to be ending up after a Matra,Halant sequence, |
| 946 | * position it before that Halant so it can interact with the Matra. |
| 947 | * However, if it's a plain Consonant,Halant we shouldn't do that. |
| 948 | * Uniscribe doesn't do this. |
| 949 | * TEST: U+0930,U+094D,U+0915,U+094B,U+094D |
| 950 | */ |
Behdad Esfahbod | a2b471d | 2012-06-05 15:17:44 -0400 | [diff] [blame] | 951 | if (!indic_options ().uniscribe_bug_compatible && |
Behdad Esfahbod | deb521d | 2012-07-17 11:37:32 -0400 | [diff] [blame] | 952 | unlikely (is_halant_or_coeng (info[new_reph_pos]))) { |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 953 | for (unsigned int i = base + 1; i < new_reph_pos; i++) |
| 954 | if (info[i].indic_category() == OT_M) { |
| 955 | /* Ok, got it. */ |
| 956 | new_reph_pos--; |
| 957 | } |
| 958 | } |
| 959 | goto reph_move; |
| 960 | } |
| 961 | |
| 962 | reph_move: |
| 963 | { |
Behdad Esfahbod | e6b01a8 | 2012-07-23 00:11:26 -0400 | [diff] [blame] | 964 | /* Yay, one big cluster! Merge before moving. */ |
| 965 | buffer->merge_clusters (start, end); |
| 966 | |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 967 | /* Move */ |
| 968 | hb_glyph_info_t reph = info[start]; |
| 969 | memmove (&info[start], &info[start + 1], (new_reph_pos - start) * sizeof (info[0])); |
| 970 | info[new_reph_pos] = reph; |
Behdad Esfahbod | 02b2922 | 2012-05-10 21:44:50 +0200 | [diff] [blame] | 971 | } |
Behdad Esfahbod | dbb1058 | 2012-05-10 13:45:52 +0200 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | |
| 975 | /* o Reorder pre-base reordering consonants: |
Behdad Esfahbod | e7be057 | 2011-07-31 15:18:57 -0400 | [diff] [blame] | 976 | * |
| 977 | * If a pre-base reordering consonant is found, reorder it according to |
| 978 | * the following rules: |
Behdad Esfahbod | e7be057 | 2011-07-31 15:18:57 -0400 | [diff] [blame] | 979 | */ |
| 980 | |
Behdad Esfahbod | 46e645e | 2012-07-16 15:30:05 -0400 | [diff] [blame] | 981 | if (pref_mask && base + 1 < end) /* Otherwise there can't be any pre-base reordering Ra. */ |
| 982 | { |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 983 | for (unsigned int i = base + 1; i < end; i++) |
| 984 | if ((info[i].mask & pref_mask) != 0) |
Behdad Esfahbod | 7881812 | 2012-07-16 15:49:08 -0400 | [diff] [blame] | 985 | { |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 986 | /* 1. Only reorder a glyph produced by substitution during application |
| 987 | * of the <pref> feature. (Note that a font may shape a Ra consonant with |
| 988 | * the feature generally but block it in certain contexts.) |
| 989 | */ |
| 990 | if (i + 1 == end || (info[i + 1].mask & pref_mask) == 0) |
| 991 | { |
| 992 | /* |
| 993 | * 2. Try to find a target position the same way as for pre-base matra. |
| 994 | * If it is found, reorder pre-base consonant glyph. |
| 995 | * |
| 996 | * 3. If position is not found, reorder immediately before main |
| 997 | * consonant. |
| 998 | */ |
| 999 | |
| 1000 | unsigned int new_pos = base; |
Behdad Esfahbod | 0afb84c | 2012-07-24 01:44:47 -0400 | [diff] [blame] | 1001 | while (new_pos > start && |
| 1002 | !(is_one_of (info[new_pos - 1], FLAG(OT_M) | HALANT_OR_COENG_FLAGS))) |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 1003 | new_pos--; |
| 1004 | |
Behdad Esfahbod | d90b8e8 | 2012-07-24 02:10:20 -0400 | [diff] [blame] | 1005 | /* In Khmer coeng model, a V,Ra can go *after* matras. If it goes after a |
| 1006 | * split matra, it should be reordered to *before* the left part of such matra. */ |
| 1007 | if (new_pos > start && info[new_pos - 1].indic_category() == OT_M) |
| 1008 | { |
| 1009 | unsigned int old_pos = i; |
| 1010 | for (unsigned int i = base + 1; i < old_pos; i++) |
| 1011 | if (info[i].indic_category() == OT_M) |
| 1012 | { |
| 1013 | new_pos--; |
| 1014 | break; |
| 1015 | } |
| 1016 | } |
| 1017 | |
Behdad Esfahbod | deb521d | 2012-07-17 11:37:32 -0400 | [diff] [blame] | 1018 | if (new_pos > start && is_halant_or_coeng (info[new_pos - 1])) |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 1019 | /* -> If ZWJ or ZWNJ follow this halant, position is moved after it. */ |
| 1020 | if (new_pos < end && is_joiner (info[new_pos])) |
| 1021 | new_pos++; |
| 1022 | |
| 1023 | { |
| 1024 | unsigned int old_pos = i; |
Behdad Esfahbod | e6b01a8 | 2012-07-23 00:11:26 -0400 | [diff] [blame] | 1025 | buffer->merge_clusters (new_pos, old_pos + 1); |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 1026 | hb_glyph_info_t tmp = info[old_pos]; |
| 1027 | memmove (&info[new_pos + 1], &info[new_pos], (old_pos - new_pos) * sizeof (info[0])); |
| 1028 | info[new_pos] = tmp; |
Behdad Esfahbod | 8e7b588 | 2012-07-16 17:04:46 -0400 | [diff] [blame] | 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | break; |
Behdad Esfahbod | 7881812 | 2012-07-16 15:49:08 -0400 | [diff] [blame] | 1033 | } |
Behdad Esfahbod | 46e645e | 2012-07-16 15:30:05 -0400 | [diff] [blame] | 1034 | } |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 1035 | |
| 1036 | |
Behdad Esfahbod | a913b02 | 2012-05-11 20:59:26 +0200 | [diff] [blame] | 1037 | /* Apply 'init' to the Left Matra if it's a word start. */ |
Behdad Esfahbod | 6a091df | 2012-05-11 21:42:27 +0200 | [diff] [blame] | 1038 | if (info[start].indic_position () == POS_PRE_M && |
Behdad Esfahbod | a913b02 | 2012-05-11 20:59:26 +0200 | [diff] [blame] | 1039 | (!start || |
Behdad Esfahbod | eace47b | 2012-05-13 15:54:43 +0200 | [diff] [blame] | 1040 | !(FLAG (_hb_glyph_info_get_general_category (&info[start - 1])) & |
Behdad Esfahbod | 2c372b8 | 2012-07-20 13:37:48 -0400 | [diff] [blame] | 1041 | FLAG_RANGE (HB_UNICODE_GENERAL_CATEGORY_FORMAT, HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)))) |
Behdad Esfahbod | 46e645e | 2012-07-16 15:30:05 -0400 | [diff] [blame] | 1042 | info[start].mask |= init_mask; |
Behdad Esfahbod | a913b02 | 2012-05-11 20:59:26 +0200 | [diff] [blame] | 1043 | |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 1044 | |
Behdad Esfahbod | 8ed248d | 2012-07-20 11:42:24 -0400 | [diff] [blame] | 1045 | /* |
| 1046 | * Finish off the clusters and go home! |
| 1047 | */ |
Behdad Esfahbod | decf6ff | 2012-07-20 13:51:31 -0400 | [diff] [blame] | 1048 | if (indic_options ().uniscribe_bug_compatible) |
Behdad Esfahbod | ebe2973 | 2012-05-11 16:43:12 +0200 | [diff] [blame] | 1049 | { |
Behdad Esfahbod | 30c3d5e | 2012-07-20 13:56:32 -0400 | [diff] [blame] | 1050 | /* Uniscribe merges the entire cluster. |
Behdad Esfahbod | 21d2803 | 2012-05-10 18:34:34 +0200 | [diff] [blame] | 1051 | * This means, half forms are submerged into the main consonants cluster. |
| 1052 | * This is unnecessary, and makes cursor positioning harder, but that's what |
| 1053 | * Uniscribe does. */ |
Behdad Esfahbod | e6b01a8 | 2012-07-23 00:11:26 -0400 | [diff] [blame] | 1054 | buffer->merge_clusters (start, end); |
Behdad Esfahbod | 21d2803 | 2012-05-10 18:34:34 +0200 | [diff] [blame] | 1055 | } |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 1056 | } |
Behdad Esfahbod | e7be057 | 2011-07-31 15:18:57 -0400 | [diff] [blame] | 1057 | |
| 1058 | |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 1059 | static void |
| 1060 | final_reordering (const hb_ot_map_t *map, |
Behdad Esfahbod | afbcc24 | 2012-08-02 08:36:40 -0400 | [diff] [blame] | 1061 | hb_font_t *font HB_UNUSED, |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame^] | 1062 | hb_buffer_t *buffer) |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 1063 | { |
| 1064 | unsigned int count = buffer->len; |
| 1065 | if (!count) return; |
Behdad Esfahbod | e7be057 | 2011-07-31 15:18:57 -0400 | [diff] [blame] | 1066 | |
Behdad Esfahbod | 46e645e | 2012-07-16 15:30:05 -0400 | [diff] [blame] | 1067 | hb_mask_t init_mask = map->get_1_mask (HB_TAG('i','n','i','t')); |
| 1068 | hb_mask_t pref_mask = map->get_1_mask (HB_TAG('p','r','e','f')); |
Behdad Esfahbod | eed903b | 2012-05-11 20:50:53 +0200 | [diff] [blame] | 1069 | |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 1070 | hb_glyph_info_t *info = buffer->info; |
| 1071 | unsigned int last = 0; |
Behdad Esfahbod | cee7187 | 2012-05-11 11:41:39 +0200 | [diff] [blame] | 1072 | unsigned int last_syllable = info[0].syllable(); |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 1073 | for (unsigned int i = 1; i < count; i++) |
Behdad Esfahbod | cee7187 | 2012-05-11 11:41:39 +0200 | [diff] [blame] | 1074 | if (last_syllable != info[i].syllable()) { |
Behdad Esfahbod | 46e645e | 2012-07-16 15:30:05 -0400 | [diff] [blame] | 1075 | final_reordering_syllable (buffer, init_mask, pref_mask, last, i); |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 1076 | last = i; |
Behdad Esfahbod | cee7187 | 2012-05-11 11:41:39 +0200 | [diff] [blame] | 1077 | last_syllable = info[last].syllable(); |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 1078 | } |
Behdad Esfahbod | 46e645e | 2012-07-16 15:30:05 -0400 | [diff] [blame] | 1079 | final_reordering_syllable (buffer, init_mask, pref_mask, last, count); |
Behdad Esfahbod | ef24cc8 | 2012-05-09 17:56:03 +0200 | [diff] [blame] | 1080 | |
Behdad Esfahbod | 743807a | 2011-07-29 16:37:02 -0400 | [diff] [blame] | 1081 | HB_BUFFER_DEALLOCATE_VAR (buffer, indic_category); |
| 1082 | HB_BUFFER_DEALLOCATE_VAR (buffer, indic_position); |
| 1083 | } |
| 1084 | |
| 1085 | |
Behdad Esfahbod | 693918e | 2012-07-30 21:08:51 -0400 | [diff] [blame] | 1086 | const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic = |
| 1087 | { |
| 1088 | "indic", |
| 1089 | collect_features_indic, |
| 1090 | override_features_indic, |
| 1091 | NULL, /* normalization_preference */ |
| 1092 | setup_masks_indic, |
Behdad Esfahbod | 1e7d860 | 2012-07-31 23:41:06 -0400 | [diff] [blame] | 1093 | false, /* zero_width_attached_marks */ |
Behdad Esfahbod | 693918e | 2012-07-30 21:08:51 -0400 | [diff] [blame] | 1094 | }; |