[subset] maxp table to use _subset2

This commit is contained in:
Qunxin Liu 2019-06-04 10:30:53 -07:00 committed by Garret Rieger
parent d5e5f37832
commit db938479d7
2 changed files with 25 additions and 29 deletions

View File

@ -94,39 +94,35 @@ struct maxp
return_trace (likely (version.major == 0 && version.minor == 0x5000u));
}
bool subset (hb_subset_plan_t *plan) const
bool subset (hb_subset_context_t *c) const
{
hb_blob_t *maxp_blob = hb_sanitize_context_t().reference_table<maxp> (plan->source);
hb_blob_t *maxp_prime_blob = hb_blob_copy_writable_or_fail (maxp_blob);
hb_blob_destroy (maxp_blob);
TRACE_SUBSET (this);
maxp *maxp_prime = c->serializer->embed (this);
if (unlikely (!maxp_prime)) return_trace (false);
if (unlikely (!maxp_prime_blob)) {
return false;
}
maxp *maxp_prime = (maxp *) hb_blob_get_data (maxp_prime_blob, nullptr);
maxp_prime->set_num_glyphs (plan->num_output_glyphs ());
if (plan->drop_hints)
drop_hint_fields (plan, maxp_prime);
bool result = plan->add_table (HB_OT_TAG_maxp, maxp_prime_blob);
hb_blob_destroy (maxp_prime_blob);
return result;
}
static void drop_hint_fields (hb_subset_plan_t *plan HB_UNUSED, maxp *maxp_prime)
{
maxp_prime->numGlyphs = c->plan->num_output_glyphs ();
if (maxp_prime->version.major == 1)
{
maxpV1Tail &v1 = StructAfter<maxpV1Tail> (*maxp_prime);
v1.maxZones = 1;
v1.maxTwilightPoints = 0;
v1.maxStorage = 0;
v1.maxFunctionDefs = 0;
v1.maxInstructionDefs = 0;
v1.maxStackElements = 0;
v1.maxSizeOfInstructions = 0;
const maxpV1Tail *src_v1 = &StructAfter<maxpV1Tail> (*this);
maxpV1Tail *dest_v1 = c->serializer->embed<maxpV1Tail> (src_v1);
if (unlikely (!dest_v1)) return_trace (false);
if (c->plan->drop_hints)
drop_hint_fields (dest_v1);
}
return_trace (true);
}
static void drop_hint_fields (maxpV1Tail* dest_v1)
{
dest_v1->maxZones = 1;
dest_v1->maxTwilightPoints = 0;
dest_v1->maxStorage = 0;
dest_v1->maxFunctionDefs = 0;
dest_v1->maxInstructionDefs = 0;
dest_v1->maxStackElements = 0;
dest_v1->maxSizeOfInstructions = 0;
}
protected:

View File

@ -181,7 +181,7 @@ _subset_table (hb_subset_plan_t *plan,
result = _subset2<const OT::vmtx> (plan);
break;
case HB_OT_TAG_maxp:
result = _subset<const OT::maxp> (plan);
result = _subset2<const OT::maxp> (plan);
break;
case HB_OT_TAG_loca:
DEBUG_MSG(SUBSET, nullptr, "skip loca handled by glyf");