[kern] Switch to dispatch

This commit is contained in:
Behdad Esfahbod 2018-11-07 16:03:09 -05:00
parent bc06e2805a
commit 9af983af24
3 changed files with 22 additions and 19 deletions

View File

@ -881,10 +881,11 @@ struct KerxTable
return v;
}
inline void apply (AAT::hb_aat_apply_context_t *c) const
inline bool apply (AAT::hb_aat_apply_context_t *c) const
{
typedef typename T::SubTable SubTable;
bool ret = false;
bool seenCrossStream = false;
c->set_lookup_index (0);
const SubTable *st = &thiz()->firstSubTable;
@ -927,7 +928,7 @@ struct KerxTable
c->sanitizer.set_object (*st);
st->dispatch (c);
ret |= st->dispatch (c);
if (reverse)
c->buffer->reverse ();
@ -938,6 +939,8 @@ struct KerxTable
st = &StructAfter<SubTable> (*st);
c->set_lookup_index (c->lookup_index + 1);
}
return ret;
}
inline bool sanitize (hb_sanitize_context_t *c) const

View File

@ -272,10 +272,11 @@ struct kern
static const hb_tag_t tableTag = HB_OT_TAG_kern;
inline bool has_data (void) const { return u.version32; }
inline unsigned int get_type (void) const { return u.major; }
inline bool has_cross_stream (void) const
{
switch (u.major) {
switch (get_type ()) {
case 0: return u.ot.has_cross_stream ();
case 1: return u.aat.has_cross_stream ();
default:return false;
@ -284,20 +285,25 @@ struct kern
inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
switch (u.major) {
switch (get_type ()) {
case 0: return u.ot.get_h_kerning (left, right);
case 1: return u.aat.get_h_kerning (left, right);
default:return 0;
}
}
inline void apply (AAT::hb_aat_apply_context_t *c) const
inline bool apply (AAT::hb_aat_apply_context_t *c) const
{ return dispatch (c); }
template <typename context_t>
inline typename context_t::return_t dispatch (context_t *c) const
{
/* TODO Switch to dispatch(). */
switch (u.major) {
case 0: u.ot.apply (c); return;
case 1: u.aat.apply (c); return;
default: return;
unsigned int subtable_type = get_type ();
TRACE_DISPATCH (this, subtable_type);
switch (subtable_type) {
case 0: return_trace (c->dispatch (u.ot));
case 1: return_trace (c->dispatch (u.aat));
default: return_trace (c->default_return_value ());
}
}
@ -305,11 +311,7 @@ struct kern
{
TRACE_SANITIZE (this);
if (!u.version32.sanitize (c)) return_trace (false);
switch (u.major) {
case 0: return_trace (u.ot.sanitize (c));
case 1: return_trace (u.aat.sanitize (c));
default:return_trace (true);
}
return_trace (dispatch (c));
}
protected:

View File

@ -1275,10 +1275,8 @@ apply_backward (OT::hb_ot_apply_context_t *c,
if (accel.may_have (buffer->cur().codepoint) &&
(buffer->cur().mask & c->lookup_mask) &&
c->check_glyph_property (&buffer->cur(), c->lookup_props))
{
if (accel.apply (c))
ret = true;
}
ret |= accel.apply (c);
/* The reverse lookup doesn't "advance" cursor (for good reason). */
buffer->idx--;