[instance] update GDEF table
This commit is contained in:
parent
b72995ff16
commit
9ab6605f20
|
@ -3166,21 +3166,22 @@ struct VariationDevice
|
|||
VariationStore::cache_t *store_cache = nullptr) const
|
||||
{ return font->em_scalef_y (get_delta (font, store, store_cache)); }
|
||||
|
||||
VariationDevice* copy (hb_serialize_context_t *c, const hb_map_t *layout_variation_idx_map) const
|
||||
VariationDevice* copy (hb_serialize_context_t *c,
|
||||
const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
if (!layout_variation_idx_delta_map) return_trace (nullptr);
|
||||
auto snap = c->snapshot ();
|
||||
auto *out = c->embed (this);
|
||||
if (unlikely (!out)) return_trace (nullptr);
|
||||
if (!layout_variation_idx_map || layout_variation_idx_map->is_empty ()) return_trace (out);
|
||||
|
||||
/* TODO Just get() and bail if NO_VARIATION. Needs to setup the map to return that. */
|
||||
if (!layout_variation_idx_map->has (varIdx))
|
||||
if (!layout_variation_idx_delta_map->has (varIdx))
|
||||
{
|
||||
c->revert (snap);
|
||||
return_trace (nullptr);
|
||||
}
|
||||
unsigned new_idx = layout_variation_idx_map->get (varIdx);
|
||||
unsigned new_idx = hb_first (layout_variation_idx_delta_map->get (varIdx));
|
||||
out->varIdx = new_idx;
|
||||
return_trace (out);
|
||||
}
|
||||
|
@ -3287,7 +3288,8 @@ struct Device
|
|||
}
|
||||
}
|
||||
|
||||
Device* copy (hb_serialize_context_t *c, const hb_map_t *layout_variation_idx_map=nullptr) const
|
||||
Device* copy (hb_serialize_context_t *c,
|
||||
const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map=nullptr) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
switch (u.b.format) {
|
||||
|
@ -3299,7 +3301,7 @@ struct Device
|
|||
#endif
|
||||
#ifndef HB_NO_VAR
|
||||
case 0x8000:
|
||||
return_trace (reinterpret_cast<Device *> (u.variation.copy (c, layout_variation_idx_map)));
|
||||
return_trace (reinterpret_cast<Device *> (u.variation.copy (c, layout_variation_idx_delta_map)));
|
||||
#endif
|
||||
default:
|
||||
return_trace (nullptr);
|
||||
|
@ -3325,6 +3327,18 @@ struct Device
|
|||
}
|
||||
}
|
||||
|
||||
unsigned get_variation_index () const
|
||||
{
|
||||
switch (u.b.format) {
|
||||
#ifndef HB_NO_VAR
|
||||
case 0x8000:
|
||||
return u.variation.varIdx;
|
||||
#endif
|
||||
default:
|
||||
return HB_OT_LAYOUT_NO_VARIATIONS_INDEX;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
union {
|
||||
DeviceHeader b;
|
||||
|
|
|
@ -200,11 +200,30 @@ struct CaretValueFormat3
|
|||
bool subset (hb_subset_context_t *c) const
|
||||
{
|
||||
TRACE_SUBSET (this);
|
||||
auto *out = c->serializer->embed (this);
|
||||
auto *out = c->serializer->start_embed (*this);
|
||||
if (unlikely (!out)) return_trace (false);
|
||||
if (!c->serializer->embed (caretValueFormat)) return_trace (false);
|
||||
if (!c->serializer->embed (coordinate)) return_trace (false);
|
||||
|
||||
unsigned varidx = (this+deviceTable).get_variation_index ();
|
||||
if (c->plan->layout_variation_idx_delta_map->has (varidx))
|
||||
{
|
||||
int delta = hb_second (c->plan->layout_variation_idx_delta_map->get (varidx));
|
||||
if (delta != 0)
|
||||
{
|
||||
if (!c->serializer->check_assign (out->coordinate, coordinate + delta, HB_SERIALIZE_ERROR_INT_OVERFLOW))
|
||||
return_trace (false);
|
||||
}
|
||||
}
|
||||
|
||||
if (c->plan->all_axes_pinned)
|
||||
return_trace (c->serializer->check_assign (out->caretValueFormat, 1, HB_SERIALIZE_ERROR_INT_OVERFLOW));
|
||||
|
||||
if (!c->serializer->embed (deviceTable))
|
||||
return_trace (false);
|
||||
|
||||
return_trace (out->deviceTable.serialize_copy (c->serializer, deviceTable, this, c->serializer->to_bias (out),
|
||||
hb_serialize_context_t::Head, c->plan->layout_variation_idx_map));
|
||||
hb_serialize_context_t::Head, c->plan->layout_variation_idx_delta_map));
|
||||
}
|
||||
|
||||
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
||||
|
@ -586,7 +605,10 @@ struct GDEFVersion1_2
|
|||
bool subset_varstore = false;
|
||||
if (version.to_int () >= 0x00010003u)
|
||||
{
|
||||
subset_varstore = out->varStore.serialize_subset (c, varStore, this, c->plan->gdef_varstore_inner_maps.as_array ());
|
||||
if (c->plan->all_axes_pinned)
|
||||
out->varStore = 0;
|
||||
else
|
||||
subset_varstore = out->varStore.serialize_subset (c, varStore, this, c->plan->gdef_varstore_inner_maps.as_array ());
|
||||
}
|
||||
|
||||
if (subset_varstore)
|
||||
|
|
Loading…
Reference in New Issue