diff options
Diffstat (limited to 'thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh')
| -rw-r--r-- | thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh b/thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh index 943d376bdf..490f883fcc 100644 --- a/thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh @@ -45,7 +45,8 @@ struct index_map_subset_plan_t void init (const DeltaSetIndexMap &index_map, hb_inc_bimap_t &outer_map, hb_vector_t<hb_set_t *> &inner_sets, - const hb_subset_plan_t *plan) + const hb_subset_plan_t *plan, + bool bypass_empty = true) { map_count = 0; outer_bit_count = 0; @@ -53,11 +54,10 @@ struct index_map_subset_plan_t max_inners.init (); output_map.init (); - if (&index_map == &Null (DeltaSetIndexMap)) return; + if (bypass_empty && !index_map.get_map_count ()) return; unsigned int last_val = (unsigned int)-1; hb_codepoint_t last_gid = HB_CODEPOINT_INVALID; - hb_codepoint_t num_gid = (hb_codepoint_t) hb_min (index_map.get_map_count (), plan->num_output_glyphs ()); outer_bit_count = (index_map.get_width () * 8) - index_map.get_inner_bit_count (); max_inners.resize (inner_sets.length); @@ -68,24 +68,17 @@ struct index_map_subset_plan_t unsigned count = new_to_old_gid_list.length; for (unsigned j = count; j; j--) { - hb_codepoint_t gid = new_to_old_gid_list[j - 1].first; - if (gid >= num_gid) continue; - - hb_codepoint_t old_gid = new_to_old_gid_list[j - 1].second; + hb_codepoint_t gid = new_to_old_gid_list.arrayZ[j - 1].first; + hb_codepoint_t old_gid = new_to_old_gid_list.arrayZ[j - 1].second; unsigned int v = index_map.map (old_gid); if (last_gid == HB_CODEPOINT_INVALID) { - if (gid + 1 != num_gid) - { - last_gid = gid + 1; - break; - } last_val = v; last_gid = gid; continue; } - if (v != last_val || gid + 1 != last_gid) + if (v != last_val) break; last_gid = gid; @@ -120,8 +113,6 @@ struct index_map_subset_plan_t const hb_vector_t<hb_inc_bimap_t> &inner_maps, const hb_subset_plan_t *plan) { - if (input_map == &Null (DeltaSetIndexMap)) return; - for (unsigned int i = 0; i < max_inners.length; i++) { if (inner_maps[i].get_population () == 0) continue; @@ -129,18 +120,17 @@ struct index_map_subset_plan_t if (bit_count > inner_bit_count) inner_bit_count = bit_count; } - output_map.resize (map_count); - for (hb_codepoint_t gid = 0; gid < output_map.length; gid++) + if (unlikely (!output_map.resize (map_count))) return; + for (const auto &_ : plan->new_to_old_gid_list) { - hb_codepoint_t old_gid; - if (plan->old_gid_for_new_gid (gid, &old_gid)) - { - uint32_t v = input_map->map (old_gid); - unsigned int outer = v >> 16; - output_map[gid] = (outer_map[outer] << 16) | (inner_maps[outer][v & 0xFFFF]); - } - else - output_map[gid] = 0; /* Map unused glyph to outer/inner=0/0 */ + hb_codepoint_t new_gid = _.first; + hb_codepoint_t old_gid = _.second; + + if (unlikely (new_gid >= map_count)) break; + + uint32_t v = input_map->map (old_gid); + unsigned int outer = v >> 16; + output_map.arrayZ[new_gid] = (outer_map[outer] << 16) | (inner_maps[outer][v & 0xFFFF]); } } @@ -184,7 +174,7 @@ struct hvarvvar_subset_plan_t if (unlikely (!index_map_plans.length || !inner_sets.length || !inner_maps.length)) return; bool retain_adv_map = false; - index_map_plans[0].init (*index_maps[0], outer_map, inner_sets, plan); + index_map_plans[0].init (*index_maps[0], outer_map, inner_sets, plan, false); if (index_maps[0] == &Null (DeltaSetIndexMap)) { retain_adv_map = plan->flags & HB_SUBSET_FLAGS_RETAIN_GIDS; @@ -201,13 +191,10 @@ struct hvarvvar_subset_plan_t if (retain_adv_map) { - unsigned num_glyphs = plan->num_output_glyphs (); - for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++) + for (const auto &_ : plan->new_to_old_gid_list) { - if (inner_sets[0]->has (gid)) - inner_maps[0].add (gid); - else - inner_maps[0].skip (); + hb_codepoint_t old_gid = _.second; + inner_maps[0].add (old_gid); } } else |
