mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-14 17:13:40 +00:00
[subset-plan] Keep a reverse-gid vector
To speed up iteration.
This commit is contained in:
parent
6b0d386797
commit
9f54ab922f
3 changed files with 19 additions and 8 deletions
|
@ -211,15 +211,17 @@ struct hmtxvmtx
|
|||
}
|
||||
|
||||
auto it =
|
||||
+ hb_range (c->plan->num_output_glyphs ())
|
||||
| hb_map ([c, &_mtx, mtx_map] (unsigned _)
|
||||
+ hb_enumerate (c->plan->new_to_old_gid_list)
|
||||
| hb_map ([c, &_mtx, mtx_map] (const hb_pair_t<hb_codepoint_t, hb_codepoint_t> &_)
|
||||
{
|
||||
hb_pair_t<unsigned, int> *v = nullptr;
|
||||
if (!mtx_map->has (_, &v))
|
||||
hb_codepoint_t new_gid = _.first;
|
||||
hb_codepoint_t old_gid = _.second;
|
||||
if (old_gid == HB_MAP_VALUE_INVALID)
|
||||
return hb_pair (0u, 0);
|
||||
|
||||
hb_pair_t<unsigned, int> *v = nullptr;
|
||||
if (!mtx_map->has (new_gid, &v))
|
||||
{
|
||||
hb_codepoint_t old_gid;
|
||||
if (!c->plan->old_gid_for_new_gid (_, &old_gid))
|
||||
return hb_pair (0u, 0);
|
||||
int lsb = 0;
|
||||
if (!_mtx.get_leading_bearing_without_var_unscaled (old_gid, &lsb))
|
||||
(void) _glyf_get_leading_bearing_without_var_unscaled (c->plan->source, old_gid, !T::is_horizontal, &lsb);
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
HB_SUBSET_PLAN_MEMBER (hb_set_t, unicodes)
|
||||
HB_SUBSET_PLAN_MEMBER (hb_sorted_vector_t E(<hb_pair_t<hb_codepoint_t, hb_codepoint_t>>), unicode_to_new_gid_list)
|
||||
|
||||
HB_SUBSET_PLAN_MEMBER (hb_vector_t<hb_codepoint_t>, new_to_old_gid_list)
|
||||
|
||||
// name_ids we would like to retain
|
||||
HB_SUBSET_PLAN_MEMBER (hb_set_t, name_ids)
|
||||
|
||||
|
|
|
@ -755,7 +755,6 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
|||
|
||||
_remove_invalid_gids (&plan->_glyphset, plan->source->get_num_glyphs ());
|
||||
|
||||
|
||||
#ifndef HB_NO_VAR
|
||||
if (!drop_tables->has (HB_OT_TAG_GDEF))
|
||||
_collect_layout_variation_indices (plan);
|
||||
|
@ -783,6 +782,7 @@ _create_old_gid_to_new_gid_map (const hb_face_t *face,
|
|||
const hb_map_t *requested_glyph_map,
|
||||
hb_map_t *glyph_map, /* OUT */
|
||||
hb_map_t *reverse_glyph_map, /* OUT */
|
||||
hb_vector_t<hb_codepoint_t> *new_to_old_gid_list /* OUT */,
|
||||
unsigned int *num_glyphs /* OUT */)
|
||||
{
|
||||
unsigned pop = all_gids_to_retain->get_population ();
|
||||
|
@ -863,6 +863,12 @@ _create_old_gid_to_new_gid_map (const hb_face_t *face,
|
|||
| hb_sink (glyph_map)
|
||||
;
|
||||
|
||||
auto &l = *new_to_old_gid_list;
|
||||
l.resize (*num_glyphs);
|
||||
hb_memset (l.arrayZ, 0xff, l.length * sizeof (l[0]));
|
||||
for (auto _ : *reverse_glyph_map)
|
||||
l[_.first] = _.second;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1086,6 +1092,7 @@ hb_subset_plan_t::hb_subset_plan_t (hb_face_t *face,
|
|||
&input->glyph_map,
|
||||
glyph_map,
|
||||
reverse_glyph_map,
|
||||
&new_to_old_gid_list,
|
||||
&_num_output_glyphs))) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue