From d5decf9bf77db914b67ffc446379df621516e362 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Tue, 7 May 2019 15:47:38 -0700 Subject: [PATCH] [subset] Move hdmx to subset2. --- src/hb-ot-hdmx-table.hh | 36 ++++++------------------------------ src/hb-subset.cc | 2 +- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh index 847b326..abf4440 100644 --- a/src/hb-ot-hdmx-table.hh +++ b/src/hb-ot-hdmx-table.hh @@ -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 (); - 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 (); + 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 diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 800bd35..f4fc771 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -159,7 +159,7 @@ _subset_table (hb_subset_plan_t *plan, result = _subset (plan); break; case HB_OT_TAG_hdmx: - result = _subset (plan); + result = _subset2 (plan); break; case HB_OT_TAG_name: result = _subset2 (plan); -- 2.7.4