diff --git a/src/hb-aat-layout-common-private.hh b/src/hb-aat-layout-common-private.hh index c93661c34..b1165e9bf 100644 --- a/src/hb-aat-layout-common-private.hh +++ b/src/hb-aat-layout-common-private.hh @@ -691,6 +691,29 @@ struct StateTableDriver }; + +struct hb_aat_apply_context_t : + hb_dispatch_context_t +{ + inline const char *get_name (void) { return "APPLY"; } + template + inline return_t dispatch (const T &obj) { return obj.apply (this); } + static return_t default_return_value (void) { return false; } + bool stop_sublookup_iteration (return_t r) const { return r; } + + hb_font_t *font; + hb_face_t *face; + hb_buffer_t *buffer; + const char *end; + + hb_aat_apply_context_t (hb_font_t *font_, + hb_buffer_t *buffer_, + const char *end_) : + font (font_), face (font->face), buffer (buffer_), + end (end_) {} +}; + + } /* namespace AAT */ diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 419185c5a..5b3402be5 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -148,7 +148,7 @@ struct RearrangementSubtable unsigned int last_zero_before_start; }; - inline bool apply (hb_ot_apply_context_t *c) const + inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -245,7 +245,7 @@ struct ContextualSubtable const UnsizedOffsetListOf, HBUINT32> &subs; }; - inline bool apply (hb_ot_apply_context_t *c) const + inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -326,7 +326,7 @@ struct LigatureSubtable private: }; - inline bool apply (hb_ot_apply_context_t *c) const + inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -360,7 +360,7 @@ struct LigatureSubtable struct NoncontextualSubtable { - inline bool apply (hb_ot_apply_context_t *c) const + inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -396,7 +396,7 @@ struct NoncontextualSubtable struct InsertionSubtable { - inline bool apply (hb_ot_apply_context_t *c) const + inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); /* TODO */ @@ -448,13 +448,13 @@ struct ChainSubtable Insertion = 5 }; - inline void apply (hb_ot_apply_context_t *c, const char *end) const + inline void apply (hb_aat_apply_context_t *c) const { - dispatch (c, end); + dispatch (c); } template - inline typename context_t::return_t dispatch (context_t *c, const char *end) const + inline typename context_t::return_t dispatch (context_t *c) const { unsigned int subtable_type = get_type (); TRACE_DISPATCH (this, subtable_type); @@ -476,7 +476,7 @@ struct ChainSubtable !c->check_range (this, length)) return_trace (false); - return_trace (dispatch (c, c->end)); + return_trace (dispatch (c)); } protected: @@ -496,13 +496,13 @@ struct ChainSubtable struct Chain { - inline void apply (hb_ot_apply_context_t *c, const char *end) const + inline void apply (hb_aat_apply_context_t *c) const { const ChainSubtable *subtable = &StructAtOffset (featureZ, featureZ[0].static_size * featureCount); unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { - subtable->apply (c, end); + subtable->apply (c); subtable = &StructAfter (*subtable); } } @@ -555,14 +555,13 @@ struct morx { static const hb_tag_t tableTag = HB_AAT_TAG_MORX; - inline void apply (hb_ot_apply_context_t *c, unsigned int length) const + inline void apply (hb_aat_apply_context_t *c) const { - const char *end = (const char *) this + length; const Chain *chain = chains; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { - chain->apply (c, end); + chain->apply (c); chain = &StructAfter (*chain); } } diff --git a/src/hb-aat-layout-private.hh b/src/hb-aat-layout-private.hh index ebddf3b40..c1c607a2f 100644 --- a/src/hb-aat-layout-private.hh +++ b/src/hb-aat-layout-private.hh @@ -35,6 +35,6 @@ HB_INTERNAL void -hb_aat_layout_substitute (OT::hb_ot_apply_context_t *c); +hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer); #endif /* HB_AAT_LAYOUT_PRIVATE_HH */ diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 94e1442d6..465aec642 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -68,9 +68,11 @@ _hb_aat_layout_create (hb_face_t *face) } void -hb_aat_layout_substitute (OT::hb_ot_apply_context_t *c) +hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer) { unsigned int length; - const AAT::morx& morx = _get_morx (c->face, &length); - morx.apply (c, length); + const AAT::morx& morx = _get_morx (font->face, &length); + + AAT::hb_aat_apply_context_t c (font, buffer, (const char *) &morx + length); + morx.apply (&c); } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 3076586d7..fc5dd1084 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -619,8 +619,7 @@ hb_ot_substitute_complex (hb_ot_shape_context_t *c) c->plan->substitute (c->font, buffer); /* XXX Call morx instead. */ - //OT::hb_ot_apply_context_t ac (0, c->font, c->buffer); - //hb_aat_layout_substitute (&ac); + //hb_aat_layout_substitute (c->font, c->buffer); } static inline void