[aat] Wire up table length to apply()

This commit is contained in:
Behdad Esfahbod 2018-01-15 15:37:55 -05:00
parent 679ae744d0
commit e6263c7142
3 changed files with 27 additions and 16 deletions

View File

@ -448,13 +448,13 @@ struct ChainSubtable
Insertion = 5 Insertion = 5
}; };
inline void apply (hb_apply_context_t *c) const inline void apply (hb_apply_context_t *c, const char *end) const
{ {
dispatch (c); dispatch (c, end);
} }
template <typename context_t> template <typename context_t>
inline typename context_t::return_t dispatch (context_t *c) const inline typename context_t::return_t dispatch (context_t *c, const char *end) const
{ {
unsigned int subtable_type = get_type (); unsigned int subtable_type = get_type ();
TRACE_DISPATCH (this, subtable_type); TRACE_DISPATCH (this, subtable_type);
@ -476,7 +476,7 @@ struct ChainSubtable
!c->check_range (this, length)) !c->check_range (this, length))
return_trace (false); return_trace (false);
return_trace (dispatch (c)); return_trace (dispatch (c, c->end));
} }
protected: protected:
@ -496,13 +496,13 @@ struct ChainSubtable
struct Chain struct Chain
{ {
inline void apply (hb_apply_context_t *c) const inline void apply (hb_apply_context_t *c, const char *end) const
{ {
const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount); const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount);
unsigned int count = subtableCount; unsigned int count = subtableCount;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
subtable->apply (c); subtable->apply (c, end);
subtable = &StructAfter<ChainSubtable> (*subtable); subtable = &StructAfter<ChainSubtable> (*subtable);
} }
} }
@ -555,13 +555,14 @@ struct morx
{ {
static const hb_tag_t tableTag = HB_AAT_TAG_MORX; static const hb_tag_t tableTag = HB_AAT_TAG_MORX;
inline void apply (hb_apply_context_t *c) const inline void apply (hb_apply_context_t *c, unsigned int length) const
{ {
const char *end = (const char *) this + length;
const Chain *chain = chains; const Chain *chain = chains;
unsigned int count = chainCount; unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
chain->apply (c); chain->apply (c, end);
chain = &StructAfter<Chain> (*chain); chain = &StructAfter<Chain> (*chain);
} }
} }

View File

@ -37,11 +37,20 @@
*/ */
static inline const AAT::morx& static inline const AAT::morx&
_get_morx (hb_face_t *face) _get_morx (hb_face_t *face, unsigned int *length = nullptr)
{ {
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(AAT::morx); if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
{
if (length)
*length = 0;
return OT::Null(AAT::morx);
}
hb_ot_layout_t * layout = hb_ot_layout_from_face (face); hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->morx.get ()); /* XXX this doesn't call set_num_glyphs on sanitizer. */ /* XXX this doesn't call set_num_glyphs on sanitizer. */
const AAT::morx& morx = *(layout->morx.get ());
if (length)
*length = hb_blob_get_length (layout->morx.blob);
return morx;
} }
static inline void static inline void
@ -61,6 +70,7 @@ _hb_aat_layout_create (hb_face_t *face)
void void
hb_aat_layout_substitute (OT::hb_apply_context_t *c) hb_aat_layout_substitute (OT::hb_apply_context_t *c)
{ {
const AAT::morx& morx = _get_morx (c->face); unsigned int length;
morx.apply (c); const AAT::morx& morx = _get_morx (c->face, &length);
morx.apply (c, length);
} }

View File

@ -1145,8 +1145,8 @@ struct hb_lazy_table_loader_t
inline void init (hb_face_t *face_) inline void init (hb_face_t *face_)
{ {
face = face_; face = face_;
instance = nullptr;
blob = nullptr; blob = nullptr;
instance = nullptr;
} }
inline void fini (void) inline void fini (void)
@ -1177,10 +1177,10 @@ struct hb_lazy_table_loader_t
return get(); return get();
} }
private:
hb_face_t *face; hb_face_t *face;
T *instance;
mutable hb_blob_t *blob; mutable hb_blob_t *blob;
private:
mutable T *instance;
}; };