[subset] don't let VariationStore subset() produce inner_maps
Make it a subset-planning object so VariationStore can subset to specified inner_maps. Also add a layout_variation_idx_delta_map in subset_plan
This commit is contained in:
parent
29d5c7f67a
commit
e03043bd0b
|
@ -2562,7 +2562,7 @@ struct VariationStore
|
|||
|
||||
bool serialize (hb_serialize_context_t *c,
|
||||
const VariationStore *src,
|
||||
const hb_array_t <hb_inc_bimap_t> &inner_maps)
|
||||
const hb_array_t <const hb_inc_bimap_t> &inner_maps)
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
#ifdef HB_NO_VAR
|
||||
|
@ -2617,7 +2617,7 @@ struct VariationStore
|
|||
return_trace (true);
|
||||
}
|
||||
|
||||
bool subset (hb_subset_context_t *c) const
|
||||
bool subset (hb_subset_context_t *c, const hb_array_t<const hb_inc_bimap_t> &inner_maps) const
|
||||
{
|
||||
TRACE_SUBSET (this);
|
||||
#ifdef HB_NO_VAR
|
||||
|
@ -2627,22 +2627,7 @@ struct VariationStore
|
|||
VariationStore *varstore_prime = c->serializer->start_embed<VariationStore> ();
|
||||
if (unlikely (!varstore_prime)) return_trace (false);
|
||||
|
||||
const hb_set_t *variation_indices = c->plan->layout_variation_indices;
|
||||
if (variation_indices->is_empty ()) return_trace (false);
|
||||
|
||||
hb_vector_t<hb_inc_bimap_t> inner_maps;
|
||||
inner_maps.resize ((unsigned) dataSets.len);
|
||||
|
||||
for (unsigned idx : c->plan->layout_variation_indices->iter ())
|
||||
{
|
||||
uint16_t major = idx >> 16;
|
||||
uint16_t minor = idx & 0xFFFF;
|
||||
|
||||
if (major >= inner_maps.length)
|
||||
return_trace (false);
|
||||
inner_maps[major].add (minor);
|
||||
}
|
||||
varstore_prime->serialize (c->serializer, this, inner_maps.as_array ());
|
||||
varstore_prime->serialize (c->serializer, this, inner_maps);
|
||||
|
||||
return_trace (
|
||||
!c->serializer->in_error()
|
||||
|
|
|
@ -586,7 +586,7 @@ struct GDEFVersion1_2
|
|||
bool subset_varstore = false;
|
||||
if (version.to_int () >= 0x00010003u)
|
||||
{
|
||||
subset_varstore = out->varStore.serialize_subset (c, varStore, this);
|
||||
subset_varstore = out->varStore.serialize_subset (c, varStore, this, c->plan->gdef_varstore_inner_maps.as_array ());
|
||||
}
|
||||
|
||||
if (subset_varstore)
|
||||
|
|
|
@ -269,11 +269,26 @@ _closure_glyphs_lookups_features (hb_subset_plan_t *plan,
|
|||
|
||||
#ifndef HB_NO_VAR
|
||||
static inline void
|
||||
_collect_layout_variation_indices (hb_subset_plan_t* plan,
|
||||
const hb_set_t *glyphset,
|
||||
const hb_map_t *gpos_lookups,
|
||||
hb_set_t *layout_variation_indices,
|
||||
hb_map_t *layout_variation_idx_map)
|
||||
_generate_varstore_inner_maps (const hb_set_t& varidx_set,
|
||||
unsigned subtable_count,
|
||||
hb_vector_t<hb_inc_bimap_t> &inner_maps /* OUT */)
|
||||
{
|
||||
if (varidx_set.is_empty () || subtable_count == 0) return;
|
||||
|
||||
inner_maps.resize (subtable_count);
|
||||
for (unsigned idx : varidx_set)
|
||||
{
|
||||
uint16_t major = idx >> 16;
|
||||
uint16_t minor = idx & 0xFFFF;
|
||||
|
||||
if (major >= subtable_count)
|
||||
continue;
|
||||
inner_maps[major].add (minor);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
_collect_layout_variation_indices (hb_subset_plan_t* plan)
|
||||
{
|
||||
hb_blob_ptr_t<OT::GDEF> gdef = plan->source_table<OT::GDEF> ();
|
||||
hb_blob_ptr_t<GPOS> gpos = plan->source_table<GPOS> ();
|
||||
|
@ -284,13 +299,18 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan,
|
|||
gpos.destroy ();
|
||||
return;
|
||||
}
|
||||
OT::hb_collect_variation_indices_context_t c (layout_variation_indices, glyphset, gpos_lookups);
|
||||
|
||||
hb_set_t varidx_set;
|
||||
OT::hb_collect_variation_indices_context_t c (&varidx_set, plan->_glyphset_gsub, plan->gpos_lookups);
|
||||
gdef->collect_variation_indices (&c);
|
||||
|
||||
if (hb_ot_layout_has_positioning (plan->source))
|
||||
gpos->collect_variation_indices (&c);
|
||||
|
||||
gdef->remap_layout_variation_indices (layout_variation_indices, layout_variation_idx_map);
|
||||
gdef->remap_layout_variation_indices (&varidx_set, plan->layout_variation_idx_delta_map);
|
||||
|
||||
unsigned subtable_count = gdef->has_var_store () ? gdef->get_var_store ().get_sub_table_count () : 0;
|
||||
_generate_varstore_inner_maps (varidx_set, subtable_count, plan->gdef_varstore_inner_maps);
|
||||
|
||||
gdef.destroy ();
|
||||
gpos.destroy ();
|
||||
|
@ -506,11 +526,7 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
|||
|
||||
#ifndef HB_NO_VAR
|
||||
if (close_over_gdef)
|
||||
_collect_layout_variation_indices (plan,
|
||||
plan->_glyphset_gsub,
|
||||
plan->gpos_lookups,
|
||||
plan->layout_variation_indices,
|
||||
plan->layout_variation_idx_map);
|
||||
_collect_layout_variation_indices (plan);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -682,8 +698,8 @@ hb_subset_plan_create_or_fail (hb_face_t *face,
|
|||
plan->gpos_features = hb_map_create ();
|
||||
plan->colrv1_layers = hb_map_create ();
|
||||
plan->colr_palettes = hb_map_create ();
|
||||
plan->layout_variation_indices = hb_set_create ();
|
||||
plan->layout_variation_idx_map = hb_map_create ();
|
||||
plan->check_success (plan->layout_variation_idx_delta_map = hb_hashmap_create<unsigned, hb_pair_t<unsigned, int>> ());
|
||||
plan->gdef_varstore_inner_maps.init ();
|
||||
|
||||
plan->check_success (plan->sanitized_table_cache = hb_hashmap_create<hb_tag_t, hb::unique_ptr<hb_blob_t>> ());
|
||||
plan->check_success (plan->axes_location = hb_hashmap_create<hb_tag_t, int> ());
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "hb-subset-input.hh"
|
||||
|
||||
#include "hb-map.hh"
|
||||
#include "hb-bimap.hh"
|
||||
#include "hb-set.hh"
|
||||
|
||||
struct hb_subset_plan_t
|
||||
|
@ -66,8 +67,6 @@ struct hb_subset_plan_t
|
|||
hb_map_destroy (gpos_features);
|
||||
hb_map_destroy (colrv1_layers);
|
||||
hb_map_destroy (colr_palettes);
|
||||
hb_set_destroy (layout_variation_indices);
|
||||
hb_map_destroy (layout_variation_idx_map);
|
||||
|
||||
hb_hashmap_destroy (gsub_langsys);
|
||||
hb_hashmap_destroy (gpos_langsys);
|
||||
|
@ -75,6 +74,7 @@ struct hb_subset_plan_t
|
|||
hb_hashmap_destroy (sanitized_table_cache);
|
||||
hb_hashmap_destroy (hmtx_map);
|
||||
hb_hashmap_destroy (vmtx_map);
|
||||
hb_hashmap_destroy (layout_variation_idx_delta_map);
|
||||
|
||||
if (user_axes_location)
|
||||
{
|
||||
|
@ -147,10 +147,11 @@ struct hb_subset_plan_t
|
|||
hb_map_t *colrv1_layers;
|
||||
hb_map_t *colr_palettes;
|
||||
|
||||
//The set of layout item variation store delta set indices to be retained
|
||||
hb_set_t *layout_variation_indices;
|
||||
//Old -> New layout item variation store delta set index mapping
|
||||
hb_map_t *layout_variation_idx_map;
|
||||
//Old layout item variation index -> (New varidx, delta) mapping
|
||||
hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map;
|
||||
|
||||
//gdef varstore retained varidx mapping
|
||||
hb_vector_t<hb_inc_bimap_t> gdef_varstore_inner_maps;
|
||||
|
||||
hb_hashmap_t<hb_tag_t, hb::unique_ptr<hb_blob_t>>* sanitized_table_cache;
|
||||
//normalized axes location map
|
||||
|
|
Loading…
Reference in New Issue