From 93d592e0e181f436ea47038fef419134007208aa Mon Sep 17 00:00:00 2001 From: Qunxin Liu Date: Wed, 5 Jun 2019 16:51:31 -0700 Subject: [PATCH] [subset] post table to use _subset2 --- src/hb-ot-post-table.hh | 31 +++++++++++++++---------------- src/hb-subset.cc | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 970bbe68a..9177a5393 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -73,26 +73,25 @@ struct post { static constexpr hb_tag_t tableTag = HB_OT_TAG_post; - bool subset (hb_subset_plan_t *plan) const + void serialize (hb_serialize_context_t *c) const { - unsigned int post_prime_length; - hb_blob_t *post_blob = hb_sanitize_context_t ().reference_table(plan->source); - hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, post::min_size); - post *post_prime = (post *) hb_blob_get_data_writable (post_prime_blob, &post_prime_length); - hb_blob_destroy (post_blob); - - if (unlikely (!post_prime || post_prime_length != post::min_size)) - { - hb_blob_destroy (post_prime_blob); - DEBUG_MSG(SUBSET, nullptr, "Invalid source post table with length %d.", post_prime_length); - return false; - } + post *post_prime = c->allocate_min (); + if (unlikely (!post_prime)) return; + memcpy (post_prime, this, post::min_size); post_prime->version.major = 3; // Version 3 does not have any glyph names. - bool result = plan->add_table (HB_OT_TAG_post, post_prime_blob); - hb_blob_destroy (post_prime_blob); + } - return result; + bool subset (hb_subset_context_t *c) const + { + TRACE_SUBSET (this); + post *post_prime = c->serializer->start_embed (); + if (unlikely (!post_prime)) return_trace (false); + + serialize (c->serializer); + if (c->serializer->in_error () || c->serializer->ran_out_of_room) return_trace (false); + + return_trace (true); } struct accelerator_t diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 233f3dc41..a6140718e 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -193,7 +193,7 @@ _subset_table (hb_subset_plan_t *plan, result = _subset (plan); break; case HB_OT_TAG_post: - result = _subset (plan); + result = _subset2 (plan); break; #ifndef HB_NO_SUBSET_CFF