[subset/COLR] Copy VarStore

Fixes https://github.com/harfbuzz/harfbuzz/issues/4085
This commit is contained in:
Behdad Esfahbod 2023-01-27 11:26:57 -07:00
parent 6c46da7710
commit 0f33ea8c4f
2 changed files with 27 additions and 1 deletions

View File

@ -1968,7 +1968,7 @@ struct COLR
colr_prime->layerList.serialize_subset (c, layerList, this);
colr_prime->clipList.serialize_subset (c, clipList, this);
colr_prime->varIdxMap.serialize_copy (c->serializer, varIdxMap, this);
//TODO: subset varStore once it's implemented in fonttools
colr_prime->varStore.serialize_copy (c->serializer, varStore, this);
return_trace (true);
}

View File

@ -2353,6 +2353,9 @@ struct VarRegionList
struct VarData
{
unsigned int get_item_count () const
{ return itemCount; }
unsigned int get_region_index_count () const
{ return regionIndices.len; }
@ -2758,6 +2761,29 @@ struct VariationStore
return_trace (true);
}
VariationStore *copy (hb_serialize_context_t *c) const
{
TRACE_SERIALIZE (this);
auto *out = c->start_embed (this);
if (unlikely (!out)) return_trace (nullptr);
hb_vector_t <hb_inc_bimap_t> inner_maps;
unsigned count = dataSets.len;
for (unsigned i = 0; i < count; i++)
{
hb_inc_bimap_t *map = inner_maps.push ();
auto &data = this+dataSets[i];
unsigned itemCount = data.get_item_count ();
for (unsigned j = 0; j < itemCount; j++)
map->add (j);
}
if (unlikely (!out->serialize (c, this, inner_maps))) return_trace (nullptr);
return_trace (out);
}
bool subset (hb_subset_context_t *c, const hb_array_t<const hb_inc_bimap_t> &inner_maps) const
{
TRACE_SUBSET (this);