diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 7327cc5b22ba2f67bcaa2d0f666799caa307c61a..c9d5cfe954911f8cdf482dc8e2b74894353531f7 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -433,8 +433,7 @@ struct StateTable inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const { if (unlikely (glyph_id == DELETED_GLYPH)) return CLASS_DELETED_GLYPH; - const HBUINT16 *v = (this+classTable).get_value (glyph_id, num_glyphs); - return v ? (unsigned) *v : (unsigned) CLASS_OUT_OF_BOUNDS; + return (this+classTable).get_class (glyph_id, num_glyphs); } inline const Entry *get_entries () const @@ -446,7 +445,7 @@ struct StateTable { if (unlikely (klass >= nClasses)) return nullptr; - const HBUINT16 *states = (this+stateArrayTable).arrayZ; + const HBUSHORT *states = (this+stateArrayTable).arrayZ; const Entry *entries = (this+entryTable).arrayZ; unsigned int entry = states[state * nClasses + klass]; @@ -461,7 +460,7 @@ struct StateTable if (unlikely (!(c->check_struct (this) && classTable.sanitize (c, this)))) return_trace (false); - const HBUINT16 *states = (this+stateArrayTable).arrayZ; + const HBUSHORT *states = (this+stateArrayTable).arrayZ; const Entry *entries = (this+entryTable).arrayZ; unsigned int num_classes = nClasses; @@ -483,8 +482,8 @@ struct StateTable if ((c->max_ops -= num_states - state) < 0) return_trace (false); { /* Sweep new states. */ - const HBUINT16 *stop = &states[num_states * num_classes]; - for (const HBUINT16 *p = &states[state * num_classes]; p < stop; p++) + const HBUSHORT *stop = &states[num_states * num_classes]; + for (const HBUSHORT *p = &states[state * num_classes]; p < stop; p++) num_entries = MAX (num_entries, *p + 1); state = num_states; } diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 99627d3a1eb2c677d9225c6ab6aa2407cd51943e..e619d9e9207d73acce68a181a5b36e798fce424b 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -278,7 +278,7 @@ struct ContextualSubtable private: bool mark_set; unsigned int mark; - const UnsizedOffsetListOf, HBUINT32, false> &subs; + const UnsizedOffsetListOf, HBUINT, false> &subs; }; inline bool apply (hb_aat_apply_context_t *c) const diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 59157c2160e46c8dced9b1ef5a5629168907dcf2..2b4f578370a435826010fcfe6a4d906f1e3742f2 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -133,20 +133,20 @@ hb_aat_layout_find_feature_mapping (hb_tag_t tag) * mort/morx/kerx/trak */ -// static inline const AAT::mort& -// _get_mort (hb_face_t *face, hb_blob_t **blob = nullptr) -// { -// if (unlikely (!hb_ot_shaper_face_data_ensure (face))) -// { -// if (blob) -// *blob = hb_blob_get_empty (); -// return Null(AAT::mort); -// } -// const AAT::morx& mort = *(hb_ot_face_data (face)->mort.get ()); -// if (blob) -// *blob = hb_ot_face_data (face)->mort.get_blob (); -// return mort; -// } +static inline const AAT::mort& +_get_mort (hb_face_t *face, hb_blob_t **blob = nullptr) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) + { + if (blob) + *blob = hb_blob_get_empty (); + return Null(AAT::mort); + } + const AAT::mort& mort = *(hb_ot_face_data (face)->mort.get ()); + if (blob) + *blob = hb_ot_face_data (face)->mort.get_blob (); + return mort; +} static inline const AAT::morx& _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr) { @@ -214,7 +214,8 @@ hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper, hb_bool_t hb_aat_layout_has_substitution (hb_face_t *face) { - return _get_morx (face).has_data (); + return _get_morx (face).has_data () || + _get_mort (face).has_data (); } void @@ -223,10 +224,22 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan, hb_buffer_t *buffer) { hb_blob_t *blob; + const AAT::morx& morx = _get_morx (font->face, &blob); + if (morx.has_data ()) + { + AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); + morx.apply (&c); + return; + } - AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); - morx.apply (&c); + const AAT::mort& mort = _get_mort (font->face, &blob); + if (mort.has_data ()) + { + AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); + mort.apply (&c); + return; + } }