From 84b68e58862647b4ede414b2e608c47d390fd60a Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 21 Feb 2018 15:43:47 -0800 Subject: [PATCH] [subset] In hdmx serialize set the correct value of sizeDeviceRecord. --- src/hb-ot-hdmx-table.hh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh index deedd38..5f0d197 100644 --- a/src/hb-ot-hdmx-table.hh +++ b/src/hb-ot-hdmx-table.hh @@ -53,15 +53,6 @@ struct DeviceRecord return this->subset_plan->gids_to_retain_sorted.len; } - inline unsigned int get_size () const - { - unsigned int raw_size = min_size + len () * HBUINT8::static_size; - if (raw_size % 4) - /* Align to 32 bits */ - return raw_size + (4 - (raw_size % 4)); - return raw_size; - } - inline const HBUINT8& operator [] (unsigned int i) const { if (unlikely (i >= len())) return Null(HBUINT8); @@ -70,11 +61,20 @@ struct DeviceRecord } }; + static inline unsigned int get_size (unsigned int count) + { + unsigned int raw_size = min_size + count * HBUINT8::static_size; + if (raw_size % 4) + /* Align to 32 bits */ + return raw_size + (4 - (raw_size % 4)); + return raw_size; + } + inline bool serialize (hb_serialize_context_t *c, const SubsetView &subset_view) { TRACE_SERIALIZE (this); - if (unlikely (!c->allocate_size (subset_view.get_size()))) + if (unlikely (!c->allocate_size (get_size (subset_view.len())))) return_trace (false); this->pixel_size.set (subset_view.source_device_record->pixel_size); @@ -93,8 +93,6 @@ struct DeviceRecord DEFINE_SIZE_MIN (2); }; - - struct hdmx { @@ -117,7 +115,7 @@ struct hdmx this->version.set (source_hdmx->version); this->num_records.set (source_hdmx->num_records); - this->size_device_record.set (source_hdmx->size_device_record); + this->size_device_record.set (DeviceRecord::get_size (plan->gids_to_retain_sorted.len)); for (unsigned int i = 0; i < source_hdmx->num_records; i++) { @@ -130,6 +128,11 @@ struct hdmx return_trace (true); } + static inline unsigned int get_subsetted_size (hb_subset_plan_t *plan) + { + return min_size + DeviceRecord::get_size (plan->gids_to_retain_sorted.len); + } + inline bool subset (hb_subset_plan_t *plan) const { // TODO(grieger) -- 2.7.4