[instancer] support BASE table

pull/4699/head
Qunxin Liu 10 months ago committed by Behdad Esfahbod
parent 4d2380f56d
commit c5a85a73fa
  1. 64
      src/hb-ot-layout-base-table.hh
  2. 2
      src/hb-subset-plan-member-list.hh
  3. 10
      src/hb-subset-plan.cc

@ -125,6 +125,20 @@ struct BaseCoordFormat3
auto *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
if (!c->plan->pinned_at_default)
{
unsigned var_idx = (this+deviceTable).get_variation_index ();
if (var_idx != HB_OT_LAYOUT_NO_VARIATIONS_INDEX)
{
hb_pair_t<unsigned, int> *v;
if (!c->plan->base_variation_idx_map.has (var_idx, &v))
return_trace (false);
if (unlikely (!c->serializer->check_assign (out->coordinate, coordinate + hb_second (*v),
HB_SERIALIZE_ERROR_INT_OVERFLOW)))
return_trace (false);
}
}
return_trace (out->deviceTable.serialize_copy (c->serializer, deviceTable,
this, 0,
hb_serialize_context_t::Head,
@ -706,6 +720,46 @@ struct BASE
(this+vAxis).collect_variation_indices (plan, varidx_set);
}
bool subset_varstore (hb_subset_context_t *c,
BASE *out /* OUT */) const
{
TRACE_SUBSET (this);
if (!c->serializer->allocate_size<Offset32To<ItemVariationStore>> (Offset32To<ItemVariationStore>::static_size))
return_trace (false);
if (!c->plan->normalized_coords)
return_trace (out->varStore.serialize_subset (c, varStore, this, c->plan->base_varstore_inner_maps.as_array ()));
if (c->plan->all_axes_pinned)
return_trace (true);
item_variations_t item_vars;
if (!item_vars.instantiate (this+varStore, c->plan, true, true,
c->plan->base_varstore_inner_maps.as_array ()))
return_trace (false);
if (!out->varStore.serialize_serialize (c->serializer,
item_vars.has_long_word (),
c->plan->axis_tags,
item_vars.get_region_list (),
item_vars.get_vardata_encodings ()))
return_trace (false);
const hb_map_t &varidx_map = item_vars.get_varidx_map ();
/* base_variation_idx_map in the plan is old_varidx->(varidx, delta)
* mapping, new varidx is generated for subsetting, we need to remap this
* after instancing */
for (auto _ : c->plan->base_variation_idx_map.iter_ref ())
{
uint32_t varidx = _.second.first;
uint32_t *new_varidx;
if (varidx_map.has (varidx, &new_varidx))
_.second.first = *new_varidx;
else
_.second.first = HB_OT_LAYOUT_NO_VARIATIONS_INDEX;
}
return_trace (true);
}
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
@ -713,19 +767,15 @@ struct BASE
if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
out->version = version;
if (has_var_store () && !subset_varstore (c, out))
return_trace (false);
if (hAxis && !out->hAxis.serialize_subset (c, hAxis, this))
return_trace (false);
if (vAxis && !out->vAxis.serialize_subset (c, vAxis, this))
return_trace (false);
if (has_var_store ())
{
if (!c->serializer->allocate_size<Offset32To<ItemVariationStore>> (Offset32To<ItemVariationStore>::static_size))
return_trace (false);
return_trace (out->varStore.serialize_subset (c, varStore, this, c->plan->base_varstore_inner_maps.as_array ()));
}
return_trace (true);
}

@ -146,7 +146,7 @@ HB_SUBSET_PLAN_MEMBER (mutable hb_hashmap_t E(<hb_codepoint_t, contour_point_vec
HB_SUBSET_PLAN_MEMBER (hb_set_t, composite_new_gids)
//Old BASE item variation index -> (New varidx, 0) mapping
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<unsigned, hb_pair_t E(<unsigned, int>)>), base_variation_idx_map)
HB_SUBSET_PLAN_MEMBER (mutable hb_hashmap_t E(<unsigned, hb_pair_t E(<unsigned, int>)>), base_variation_idx_map)
//BASE table varstore retained varidx mapping
HB_SUBSET_PLAN_MEMBER (hb_vector_t<hb_inc_bimap_t>, base_varstore_inner_maps)

@ -489,13 +489,15 @@ _collect_base_variation_indices (hb_subset_plan_t* plan)
hb_set_t varidx_set;
base->collect_variation_indices (plan, varidx_set);
unsigned subtable_count = base->get_var_store ().get_sub_table_count ();
const OT::ItemVariationStore &var_store = base->get_var_store ();
base.destroy ();
unsigned subtable_count = var_store.get_sub_table_count ();
/* TODO: support instancing for BASE table */
_remap_variation_indices (base->get_var_store (), varidx_set,
_remap_variation_indices (var_store, varidx_set,
plan->normalized_coords,
false, false, plan->base_variation_idx_map);
!plan->pinned_at_default,
plan->all_axes_pinned,
plan->base_variation_idx_map);
_generate_varstore_inner_maps (varidx_set, subtable_count, plan->base_varstore_inner_maps);
}

Loading…
Cancel
Save