diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh index a506c2940..deedd3808 100644 --- a/src/hb-ot-hdmx-table.hh +++ b/src/hb-ot-hdmx-table.hh @@ -53,6 +53,15 @@ 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); @@ -65,16 +74,14 @@ struct DeviceRecord { TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min ((*this)))) return_trace (false); + if (unlikely (!c->allocate_size (subset_view.get_size()))) + return_trace (false); + this->pixel_size.set (subset_view.source_device_record->pixel_size); this->max_width.set (subset_view.source_device_record->max_width); for (unsigned int i = 0; i < subset_view.len(); i++) - { - HBUINT8 *width = c->extend (this->widths[i]); - if (unlikely (!width)) return_trace (false); - width->set (subset_view[i]); - } + widths[i].set (subset_view[i]); return_trace (true); }