From 5473ebfb84c7b6059ac16e04676b363acc51aa00 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 24 Feb 2016 19:32:43 +0900 Subject: [PATCH] [ot-font] Remove level of indirection in get_glyph_variant --- src/hb-ot-cmap-table.hh | 14 ++------------ src/hb-ot-font.cc | 13 +++++++++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index c9161f0ef..886d348e1 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -388,7 +388,7 @@ struct CmapSubtableFormat14 } protected: - USHORT format; /* Format number is set to 0. */ + USHORT format; /* Format number is set to 14. */ ULONG lengthZ; /* Byte length of this subtable. */ SortedArrayOf record; /* Variation selector records; sorted @@ -416,16 +416,6 @@ struct CmapSubtable } } - inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) const - { - switch (u.format) { - case 14: return u.format14.get_glyph_variant(codepoint, variation_selector, glyph); - default: return GLYPH_VARIANT_NOT_FOUND; - } - } - inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -442,7 +432,7 @@ struct CmapSubtable } } - protected: + public: union { USHORT format; /* Format identifier */ CmapSubtableFormat0 format0; diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index bba613271..fe6f80633 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -204,7 +204,7 @@ struct hb_ot_face_glyf_accelerator_t struct hb_ot_face_cmap_accelerator_t { const OT::CmapSubtable *table; - const OT::CmapSubtable *uvs_table; + const OT::CmapSubtableFormat14 *uvs_table; hb_blob_t *blob; inline void init (hb_face_t *face) @@ -212,7 +212,7 @@ struct hb_ot_face_cmap_accelerator_t this->blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_cmap)); const OT::cmap *cmap = OT::Sanitizer::lock_instance (this->blob); const OT::CmapSubtable *subtable = NULL; - const OT::CmapSubtable *subtable_uvs = NULL; + const OT::CmapSubtableFormat14 *subtable_uvs = NULL; /* 32-bit subtables. */ if (!subtable) subtable = cmap->find_subtable (3, 10); @@ -229,9 +229,14 @@ struct hb_ot_face_cmap_accelerator_t if (!subtable) subtable = &OT::Null(OT::CmapSubtable); /* UVS subtable. */ - if (!subtable_uvs) subtable_uvs = cmap->find_subtable (0, 5); + if (!subtable_uvs) + { + const OT::CmapSubtable *st = cmap->find_subtable (0, 5); + if (st && st->u.format == 14) + subtable_uvs = &st->u.format14; + } /* Meh. */ - if (!subtable_uvs) subtable_uvs = &OT::Null(OT::CmapSubtable); + if (!subtable_uvs) subtable_uvs = &OT::Null(OT::CmapSubtableFormat14); this->table = subtable; this->uvs_table = subtable_uvs;