Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 2 | * Copyright © 2009,2010 Red Hat, Inc. |
Behdad Esfahbod | 06a44e8 | 2013-04-21 15:13:08 -0400 | [diff] [blame] | 3 | * Copyright © 2010,2011,2013 Google, Inc. |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 4 | * |
| 5 | * This is part of HarfBuzz, a text shaping library. |
| 6 | * |
| 7 | * Permission is hereby granted, without written agreement and without |
| 8 | * license or royalty fees, to use, copy, modify, and distribute this |
| 9 | * software and its documentation for any purpose, provided that the |
| 10 | * above copyright notice and the following two paragraphs appear in |
| 11 | * all copies of this software. |
| 12 | * |
| 13 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 14 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 15 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 16 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 17 | * DAMAGE. |
| 18 | * |
| 19 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 20 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 22 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 23 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 24 | * |
| 25 | * Red Hat Author(s): Behdad Esfahbod |
| 26 | * Google Author(s): Behdad Esfahbod |
| 27 | */ |
| 28 | |
| 29 | #include "hb-ot-map-private.hh" |
| 30 | |
Behdad Esfahbod | 2265be0 | 2013-05-02 14:25:09 -0400 | [diff] [blame] | 31 | #include "hb-ot-layout-private.hh" |
| 32 | |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 33 | |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 34 | void |
Behdad Esfahbod | 895fb5d | 2010-10-12 16:00:21 -0400 | [diff] [blame] | 35 | hb_ot_map_t::add_lookups (hb_face_t *face, |
Behdad Esfahbod | d2ba016 | 2010-10-12 15:35:45 -0400 | [diff] [blame] | 36 | unsigned int table_index, |
| 37 | unsigned int feature_index, |
Behdad Esfahbod | cfc507c | 2013-02-14 10:40:12 -0500 | [diff] [blame] | 38 | hb_mask_t mask, |
Behdad Esfahbod | a8cf7b4 | 2013-03-19 05:53:26 -0400 | [diff] [blame] | 39 | bool auto_zwj) |
Behdad Esfahbod | d2ba016 | 2010-10-12 15:35:45 -0400 | [diff] [blame] | 40 | { |
Behdad Esfahbod | 265ac61 | 2011-05-05 14:38:16 -0400 | [diff] [blame] | 41 | unsigned int lookup_indices[32]; |
| 42 | unsigned int offset, len; |
Behdad Esfahbod | d2ba016 | 2010-10-12 15:35:45 -0400 | [diff] [blame] | 43 | |
Behdad Esfahbod | 265ac61 | 2011-05-05 14:38:16 -0400 | [diff] [blame] | 44 | offset = 0; |
| 45 | do { |
| 46 | len = ARRAY_LENGTH (lookup_indices); |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 47 | hb_ot_layout_feature_get_lookups (face, |
| 48 | table_tags[table_index], |
| 49 | feature_index, |
| 50 | offset, &len, |
| 51 | lookup_indices); |
Behdad Esfahbod | d2ba016 | 2010-10-12 15:35:45 -0400 | [diff] [blame] | 52 | |
Behdad Esfahbod | 265ac61 | 2011-05-05 14:38:16 -0400 | [diff] [blame] | 53 | for (unsigned int i = 0; i < len; i++) { |
Behdad Esfahbod | 90645fb | 2011-05-27 18:13:31 -0400 | [diff] [blame] | 54 | hb_ot_map_t::lookup_map_t *lookup = lookups[table_index].push (); |
Behdad Esfahbod | 265ac61 | 2011-05-05 14:38:16 -0400 | [diff] [blame] | 55 | if (unlikely (!lookup)) |
| 56 | return; |
| 57 | lookup->mask = mask; |
| 58 | lookup->index = lookup_indices[i]; |
Behdad Esfahbod | a8cf7b4 | 2013-03-19 05:53:26 -0400 | [diff] [blame] | 59 | lookup->auto_zwj = auto_zwj; |
Behdad Esfahbod | 265ac61 | 2011-05-05 14:38:16 -0400 | [diff] [blame] | 60 | } |
Behdad Esfahbod | d2ba016 | 2010-10-12 15:35:45 -0400 | [diff] [blame] | 61 | |
Behdad Esfahbod | 265ac61 | 2011-05-05 14:38:16 -0400 | [diff] [blame] | 62 | offset += len; |
| 63 | } while (len == ARRAY_LENGTH (lookup_indices)); |
Behdad Esfahbod | d2ba016 | 2010-10-12 15:35:45 -0400 | [diff] [blame] | 64 | } |
| 65 | |
Behdad Esfahbod | 6fddf2d | 2012-11-12 17:57:24 -0800 | [diff] [blame] | 66 | hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_, |
| 67 | const hb_segment_properties_t *props_) |
| 68 | { |
| 69 | memset (this, 0, sizeof (*this)); |
| 70 | |
| 71 | face = face_; |
| 72 | props = *props_; |
| 73 | |
| 74 | |
| 75 | /* Fetch script/language indices for GSUB/GPOS. We need these later to skip |
| 76 | * features not available in either table and not waste precious bits for them. */ |
| 77 | |
| 78 | hb_tag_t script_tags[3] = {HB_TAG_NONE, HB_TAG_NONE, HB_TAG_NONE}; |
| 79 | hb_tag_t language_tag; |
| 80 | |
| 81 | hb_ot_tags_from_script (props.script, &script_tags[0], &script_tags[1]); |
| 82 | language_tag = hb_ot_tag_from_language (props.language); |
| 83 | |
| 84 | for (unsigned int table_index = 0; table_index < 2; table_index++) { |
| 85 | hb_tag_t table_tag = table_tags[table_index]; |
Behdad Esfahbod | 851784f | 2012-11-14 16:24:05 -0800 | [diff] [blame] | 86 | found_script[table_index] = hb_ot_layout_table_choose_script (face, table_tag, script_tags, &script_index[table_index], &chosen_script[table_index]); |
Behdad Esfahbod | 6fddf2d | 2012-11-12 17:57:24 -0800 | [diff] [blame] | 87 | hb_ot_layout_script_find_language (face, table_tag, script_index[table_index], language_tag, &language_index[table_index]); |
| 88 | } |
| 89 | } |
Behdad Esfahbod | d2ba016 | 2010-10-12 15:35:45 -0400 | [diff] [blame] | 90 | |
Behdad Esfahbod | ec54486 | 2013-02-14 11:25:10 -0500 | [diff] [blame] | 91 | void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value, |
| 92 | hb_ot_map_feature_flags_t flags) |
Behdad Esfahbod | 51881a6 | 2011-05-27 18:15:56 -0400 | [diff] [blame] | 93 | { |
| 94 | feature_info_t *info = feature_infos.push(); |
| 95 | if (unlikely (!info)) return; |
| 96 | info->tag = tag; |
| 97 | info->seq = feature_infos.len; |
| 98 | info->max_value = value; |
Behdad Esfahbod | ec54486 | 2013-02-14 11:25:10 -0500 | [diff] [blame] | 99 | info->flags = flags; |
| 100 | info->default_value = (flags & F_GLOBAL) ? value : 0; |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 101 | info->stage[0] = current_stage[0]; |
| 102 | info->stage[1] = current_stage[1]; |
| 103 | } |
| 104 | |
Behdad Esfahbod | 3276c35 | 2013-05-02 15:16:59 -0400 | [diff] [blame] | 105 | |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 106 | void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const |
Behdad Esfahbod | d2984a2 | 2012-04-23 17:21:14 -0400 | [diff] [blame] | 107 | { |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 108 | for (unsigned int i = 0; i < lookups[table_index].len; i++) |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 109 | hb_set_add (lookups_out, lookups[table_index][i].index); |
Behdad Esfahbod | d2984a2 | 2012-04-23 17:21:14 -0400 | [diff] [blame] | 110 | } |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 111 | |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame] | 112 | void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func) |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 113 | { |
Behdad Esfahbod | 8ac3c9c | 2013-04-21 15:19:38 -0400 | [diff] [blame] | 114 | stage_info_t *s = stages[table_index].push (); |
| 115 | if (likely (s)) { |
| 116 | s->index = current_stage[table_index]; |
Behdad Esfahbod | 893f57b | 2013-04-21 15:21:49 -0400 | [diff] [blame] | 117 | s->pause_func = pause_func; |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | current_stage[table_index]++; |
Behdad Esfahbod | 51881a6 | 2011-05-27 18:15:56 -0400 | [diff] [blame] | 121 | } |
| 122 | |
Behdad Esfahbod | d2ba016 | 2010-10-12 15:35:45 -0400 | [diff] [blame] | 123 | void |
Behdad Esfahbod | 6fddf2d | 2012-11-12 17:57:24 -0800 | [diff] [blame] | 124 | hb_ot_map_builder_t::compile (hb_ot_map_t &m) |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 125 | { |
Behdad Esfahbod | 6fddf2d | 2012-11-12 17:57:24 -0800 | [diff] [blame] | 126 | m.global_mask = 1; |
| 127 | |
Behdad Esfahbod | 851784f | 2012-11-14 16:24:05 -0800 | [diff] [blame] | 128 | for (unsigned int table_index = 0; table_index < 2; table_index++) { |
Behdad Esfahbod | 6fddf2d | 2012-11-12 17:57:24 -0800 | [diff] [blame] | 129 | m.chosen_script[table_index] = chosen_script[table_index]; |
Behdad Esfahbod | 851784f | 2012-11-14 16:24:05 -0800 | [diff] [blame] | 130 | m.found_script[table_index] = found_script[table_index]; |
| 131 | } |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 132 | |
Behdad Esfahbod | 44b0a4d | 2011-05-05 13:42:19 -0400 | [diff] [blame] | 133 | if (!feature_infos.len) |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 134 | return; |
| 135 | |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 136 | /* Sort features and merge duplicates */ |
Behdad Esfahbod | 31f18ab | 2011-06-15 09:49:58 -0400 | [diff] [blame] | 137 | { |
| 138 | feature_infos.sort (); |
| 139 | unsigned int j = 0; |
| 140 | for (unsigned int i = 1; i < feature_infos.len; i++) |
| 141 | if (feature_infos[i].tag != feature_infos[j].tag) |
| 142 | feature_infos[++j] = feature_infos[i]; |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 143 | else { |
Behdad Esfahbod | ec54486 | 2013-02-14 11:25:10 -0500 | [diff] [blame] | 144 | if (feature_infos[i].flags & F_GLOBAL) { |
| 145 | feature_infos[j].flags |= F_GLOBAL; |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 146 | feature_infos[j].max_value = feature_infos[i].max_value; |
| 147 | feature_infos[j].default_value = feature_infos[i].default_value; |
| 148 | } else { |
Behdad Esfahbod | ec54486 | 2013-02-14 11:25:10 -0500 | [diff] [blame] | 149 | feature_infos[j].flags &= ~F_GLOBAL; |
Behdad Esfahbod | 31f18ab | 2011-06-15 09:49:58 -0400 | [diff] [blame] | 150 | feature_infos[j].max_value = MAX (feature_infos[j].max_value, feature_infos[i].max_value); |
Behdad Esfahbod | 398238a | 2013-02-15 07:40:10 -0500 | [diff] [blame] | 151 | /* Inherit default_value from j */ |
Behdad Esfahbod | 31f18ab | 2011-06-15 09:49:58 -0400 | [diff] [blame] | 152 | } |
Behdad Esfahbod | ec54486 | 2013-02-14 11:25:10 -0500 | [diff] [blame] | 153 | feature_infos[j].flags |= (feature_infos[i].flags & F_HAS_FALLBACK); |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 154 | feature_infos[j].stage[0] = MIN (feature_infos[j].stage[0], feature_infos[i].stage[0]); |
| 155 | feature_infos[j].stage[1] = MIN (feature_infos[j].stage[1], feature_infos[i].stage[1]); |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 156 | } |
Behdad Esfahbod | 31f18ab | 2011-06-15 09:49:58 -0400 | [diff] [blame] | 157 | feature_infos.shrink (j + 1); |
| 158 | } |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 159 | |
| 160 | |
| 161 | /* Allocate bits now */ |
| 162 | unsigned int next_bit = 1; |
Behdad Esfahbod | 6843569 | 2011-05-05 14:12:37 -0400 | [diff] [blame] | 163 | for (unsigned int i = 0; i < feature_infos.len; i++) { |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 164 | const feature_info_t *info = &feature_infos[i]; |
| 165 | |
| 166 | unsigned int bits_needed; |
| 167 | |
Behdad Esfahbod | ec54486 | 2013-02-14 11:25:10 -0500 | [diff] [blame] | 168 | if ((info->flags & F_GLOBAL) && info->max_value == 1) |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 169 | /* Uses the global bit */ |
| 170 | bits_needed = 0; |
| 171 | else |
Behdad Esfahbod | 852912f | 2010-10-13 15:34:50 -0400 | [diff] [blame] | 172 | bits_needed = _hb_bit_storage (info->max_value); |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 173 | |
Behdad Esfahbod | 852912f | 2010-10-13 15:34:50 -0400 | [diff] [blame] | 174 | if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t)) |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 175 | continue; /* Feature disabled, or not enough bits. */ |
| 176 | |
| 177 | |
| 178 | bool found = false; |
| 179 | unsigned int feature_index[2]; |
| 180 | for (unsigned int table_index = 0; table_index < 2; table_index++) |
Behdad Esfahbod | 895fb5d | 2010-10-12 16:00:21 -0400 | [diff] [blame] | 181 | found |= hb_ot_layout_language_find_feature (face, |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 182 | table_tags[table_index], |
| 183 | script_index[table_index], |
| 184 | language_index[table_index], |
| 185 | info->tag, |
| 186 | &feature_index[table_index]); |
Behdad Esfahbod | ec54486 | 2013-02-14 11:25:10 -0500 | [diff] [blame] | 187 | if (!found && !(info->flags & F_HAS_FALLBACK)) |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 188 | continue; |
| 189 | |
| 190 | |
Behdad Esfahbod | 90645fb | 2011-05-27 18:13:31 -0400 | [diff] [blame] | 191 | hb_ot_map_t::feature_map_t *map = m.features.push (); |
Behdad Esfahbod | 6843569 | 2011-05-05 14:12:37 -0400 | [diff] [blame] | 192 | if (unlikely (!map)) |
| 193 | break; |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 194 | |
| 195 | map->tag = info->tag; |
| 196 | map->index[0] = feature_index[0]; |
| 197 | map->index[1] = feature_index[1]; |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 198 | map->stage[0] = info->stage[0]; |
| 199 | map->stage[1] = info->stage[1]; |
Behdad Esfahbod | a8cf7b4 | 2013-03-19 05:53:26 -0400 | [diff] [blame] | 200 | map->auto_zwj = !(info->flags & F_MANUAL_ZWJ); |
Behdad Esfahbod | ec54486 | 2013-02-14 11:25:10 -0500 | [diff] [blame] | 201 | if ((info->flags & F_GLOBAL) && info->max_value == 1) { |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 202 | /* Uses the global bit */ |
| 203 | map->shift = 0; |
| 204 | map->mask = 1; |
| 205 | } else { |
| 206 | map->shift = next_bit; |
| 207 | map->mask = (1 << (next_bit + bits_needed)) - (1 << next_bit); |
| 208 | next_bit += bits_needed; |
Behdad Esfahbod | 398238a | 2013-02-15 07:40:10 -0500 | [diff] [blame] | 209 | m.global_mask |= (info->default_value << map->shift) & map->mask; |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 210 | } |
Behdad Esfahbod | 39dede9 | 2010-10-13 15:54:06 -0400 | [diff] [blame] | 211 | map->_1_mask = (1 << map->shift) & map->mask; |
Behdad Esfahbod | fabd311 | 2012-09-05 22:19:28 -0400 | [diff] [blame] | 212 | map->needs_fallback = !found; |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 213 | |
| 214 | } |
Behdad Esfahbod | 6843569 | 2011-05-05 14:12:37 -0400 | [diff] [blame] | 215 | feature_infos.shrink (0); /* Done with these */ |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 216 | |
| 217 | |
Behdad Esfahbod | 3e38c0f | 2012-08-02 09:44:18 -0400 | [diff] [blame] | 218 | add_gsub_pause (NULL); |
| 219 | add_gpos_pause (NULL); |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 220 | |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 221 | for (unsigned int table_index = 0; table_index < 2; table_index++) { |
| 222 | hb_tag_t table_tag = table_tags[table_index]; |
| 223 | |
| 224 | /* Collect lookup indices for features */ |
| 225 | |
| 226 | unsigned int required_feature_index; |
Behdad Esfahbod | 895fb5d | 2010-10-12 16:00:21 -0400 | [diff] [blame] | 227 | if (hb_ot_layout_language_get_required_feature_index (face, |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 228 | table_tag, |
| 229 | script_index[table_index], |
| 230 | language_index[table_index], |
| 231 | &required_feature_index)) |
Behdad Esfahbod | cfc507c | 2013-02-14 10:40:12 -0500 | [diff] [blame] | 232 | m.add_lookups (face, table_index, required_feature_index, 1, true); |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 233 | |
Behdad Esfahbod | 8ac3c9c | 2013-04-21 15:19:38 -0400 | [diff] [blame] | 234 | unsigned int stage_index = 0; |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 235 | unsigned int last_num_lookups = 0; |
| 236 | for (unsigned stage = 0; stage < current_stage[table_index]; stage++) |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 237 | { |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 238 | for (unsigned i = 0; i < m.features.len; i++) |
| 239 | if (m.features[i].stage[table_index] == stage) |
Behdad Esfahbod | cfc507c | 2013-02-14 10:40:12 -0500 | [diff] [blame] | 240 | m.add_lookups (face, table_index, |
| 241 | m.features[i].index[table_index], |
| 242 | m.features[i].mask, |
Behdad Esfahbod | a8cf7b4 | 2013-03-19 05:53:26 -0400 | [diff] [blame] | 243 | m.features[i].auto_zwj); |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 244 | |
| 245 | /* Sort lookups and merge duplicates */ |
| 246 | if (last_num_lookups < m.lookups[table_index].len) |
| 247 | { |
| 248 | m.lookups[table_index].sort (last_num_lookups, m.lookups[table_index].len); |
| 249 | |
| 250 | unsigned int j = last_num_lookups; |
| 251 | for (unsigned int i = j + 1; i < m.lookups[table_index].len; i++) |
| 252 | if (m.lookups[table_index][i].index != m.lookups[table_index][j].index) |
| 253 | m.lookups[table_index][++j] = m.lookups[table_index][i]; |
| 254 | else |
Behdad Esfahbod | cfc507c | 2013-02-14 10:40:12 -0500 | [diff] [blame] | 255 | { |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 256 | m.lookups[table_index][j].mask |= m.lookups[table_index][i].mask; |
Behdad Esfahbod | a8cf7b4 | 2013-03-19 05:53:26 -0400 | [diff] [blame] | 257 | m.lookups[table_index][j].auto_zwj &= m.lookups[table_index][i].auto_zwj; |
Behdad Esfahbod | cfc507c | 2013-02-14 10:40:12 -0500 | [diff] [blame] | 258 | } |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 259 | m.lookups[table_index].shrink (j + 1); |
| 260 | } |
| 261 | |
| 262 | last_num_lookups = m.lookups[table_index].len; |
| 263 | |
Behdad Esfahbod | 8ac3c9c | 2013-04-21 15:19:38 -0400 | [diff] [blame] | 264 | if (stage_index < stages[table_index].len && stages[table_index][stage_index].index == stage) { |
Behdad Esfahbod | 893f57b | 2013-04-21 15:21:49 -0400 | [diff] [blame] | 265 | hb_ot_map_t::stage_map_t *stage_map = m.stages[table_index].push (); |
| 266 | if (likely (stage_map)) { |
| 267 | stage_map->last_lookup = last_num_lookups; |
| 268 | stage_map->pause_func = stages[table_index][stage_index].pause_func; |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 269 | } |
| 270 | |
Behdad Esfahbod | 8ac3c9c | 2013-04-21 15:19:38 -0400 | [diff] [blame] | 271 | stage_index++; |
Behdad Esfahbod | b70c96d | 2011-07-07 21:07:41 -0400 | [diff] [blame] | 272 | } |
Behdad Esfahbod | 5a2b0b3 | 2010-10-08 20:14:57 -0400 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | } |