[subset] Move hdmx to subset2.

This commit is contained in:
Garret Rieger 2019-05-07 15:47:38 -07:00 committed by Behdad Esfahbod
parent 27b2093009
commit d5decf9bf7
2 changed files with 8 additions and 32 deletions

View File

@ -157,40 +157,16 @@ struct hdmx
return_trace (true);
}
static size_t get_subsetted_size (const hdmx *source_hdmx, hb_subset_plan_t *plan)
{
return min_size + source_hdmx->numRecords * DeviceRecord::get_size (plan->num_output_glyphs ());
}
bool subset (hb_subset_plan_t *plan) const
bool subset (hb_subset_context_t *c) const
{
size_t dest_size = get_subsetted_size (this, plan);
hdmx *dest = (hdmx *) malloc (dest_size);
if (unlikely (!dest))
{
DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %lu for hdmx subset output.", (unsigned long) dest_size);
return false;
}
TRACE_SUBSET (this);
hb_serialize_context_t c (dest, dest_size);
hdmx *hdmx_prime = c.start_serialize<hdmx> ();
if (!hdmx_prime || !hdmx_prime->serialize (&c, this, plan))
{
free (dest);
DEBUG_MSG(SUBSET, nullptr, "Failed to serialize write new hdmx.");
return false;
}
c.end_serialize ();
hdmx *hdmx_prime = c->serializer->start_embed <hdmx> ();
if (unlikely (!hdmx_prime)) return_trace (false);
hb_blob_t *hdmx_prime_blob = hb_blob_create ((const char *) dest,
dest_size,
HB_MEMORY_MODE_READONLY,
dest,
free);
bool result = plan->add_table (HB_OT_TAG_hdmx, hdmx_prime_blob);
hb_blob_destroy (hdmx_prime_blob);
return result;
hdmx_prime->serialize (c->serializer, this, c->plan);
return_trace (true);
}
bool sanitize (hb_sanitize_context_t *c) const

View File

@ -159,7 +159,7 @@ _subset_table (hb_subset_plan_t *plan,
result = _subset<const OT::glyf> (plan);
break;
case HB_OT_TAG_hdmx:
result = _subset<const OT::hdmx> (plan);
result = _subset2<const OT::hdmx> (plan);
break;
case HB_OT_TAG_name:
result = _subset2<const OT::name> (plan);