diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 8d8d68b19..2878c6f50 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -302,39 +302,6 @@ struct hb_ot_face_cbdt_accelerator_t } }; -struct hb_ot_face_post_accelerator_t -{ - hb_blob_t *post_blob; - OT::post::accelerator_t accel; - - inline void init (hb_face_t *face) - { - hb_blob_t *blob = this->post_blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_post)); - accel.init (OT::Sanitizer::lock_instance (blob), hb_blob_get_length (blob)); - } - - inline void fini (void) - { - accel.fini (); - hb_blob_destroy (this->post_blob); - } - - inline bool get_glyph_name (hb_codepoint_t glyph, - char *name, unsigned int size) const - { - return this->accel.get_glyph_name (glyph, name, size); - } - - inline bool get_glyph_from_name (const char *name, int len, - hb_codepoint_t *glyph) const - { - if (unlikely (!len)) - return false; - - return this->accel.get_glyph_from_name (name, len, glyph); - } -}; - typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph); @@ -470,7 +437,7 @@ struct hb_ot_font_t hb_ot_face_metrics_accelerator_t v_metrics; OT::hb_lazy_loader_t glyf; OT::hb_lazy_loader_t cbdt; - OT::hb_lazy_loader_t post; + OT::hb_lazy_loader_t post; OT::hb_lazy_loader_t kern; }; diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 01d626bf1..0c1aaed9d 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -84,8 +84,12 @@ struct post struct accelerator_t { - inline void init (const post *table, unsigned int post_len) + inline void init (hb_face_t *face) { + blob = Sanitizer::sanitize (face->reference_table (HB_OT_TAG_post)); + const post *table = Sanitizer::lock_instance (blob); + unsigned int table_length = hb_blob_get_length (blob); + version = table->version.to_int (); index_to_offset.init (); if (version != 0x00020000) @@ -96,7 +100,7 @@ struct post glyphNameIndex = &v2.glyphNameIndex; pool = &StructAfter (v2.glyphNameIndex); - const uint8_t *end = (uint8_t *) table + post_len; + const uint8_t *end = (uint8_t *) table + table_length; for (const uint8_t *data = pool; data < end && data + *data <= end; data += 1 + *data) { uint32_t *offset = index_to_offset.push (); @@ -227,6 +231,7 @@ struct post return hb_string_t ((const char *) data, name_length); } + hb_blob_t *blob; uint32_t version; const ArrayOf *glyphNameIndex; hb_prealloced_array_t index_to_offset;