[layout] Add apply_forward / apply_backward
This commit is contained in:
parent
1d4a328472
commit
e2f50f2a7e
|
@ -829,6 +829,50 @@ struct GPOSProxy
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename Obj>
|
||||||
|
static inline bool
|
||||||
|
apply_forward (OT::hb_apply_context_t *c,
|
||||||
|
const Obj &obj,
|
||||||
|
const hb_ot_layout_lookup_accelerator_t &accel)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
hb_buffer_t *buffer = c->buffer;
|
||||||
|
while (buffer->idx < buffer->len)
|
||||||
|
{
|
||||||
|
if (accel.may_have (buffer->cur().codepoint) &&
|
||||||
|
(buffer->cur().mask & c->lookup_mask) &&
|
||||||
|
c->check_glyph_property (&c->buffer->cur(), c->lookup_props) &&
|
||||||
|
obj.apply (c))
|
||||||
|
ret = true;
|
||||||
|
else
|
||||||
|
buffer->next_glyph ();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Obj>
|
||||||
|
static inline bool
|
||||||
|
apply_backward (OT::hb_apply_context_t *c,
|
||||||
|
const Obj &obj,
|
||||||
|
const hb_ot_layout_lookup_accelerator_t &accel)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
hb_buffer_t *buffer = c->buffer;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (accel.may_have (buffer->cur().codepoint) &&
|
||||||
|
(buffer->cur().mask & c->lookup_mask) &&
|
||||||
|
c->check_glyph_property (&c->buffer->cur(), c->lookup_props) &&
|
||||||
|
obj.apply (c))
|
||||||
|
ret = true;
|
||||||
|
/* The reverse lookup doesn't "advance" cursor (for good reason). */
|
||||||
|
buffer->idx--;
|
||||||
|
|
||||||
|
}
|
||||||
|
while ((int) buffer->idx >= 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Proxy>
|
template <typename Proxy>
|
||||||
static inline void
|
static inline void
|
||||||
apply_string (OT::hb_apply_context_t *c,
|
apply_string (OT::hb_apply_context_t *c,
|
||||||
|
@ -849,18 +893,7 @@ apply_string (OT::hb_apply_context_t *c,
|
||||||
buffer->clear_output ();
|
buffer->clear_output ();
|
||||||
buffer->idx = 0;
|
buffer->idx = 0;
|
||||||
|
|
||||||
bool ret = false;
|
if (apply_forward (c, lookup, accel))
|
||||||
while (buffer->idx < buffer->len)
|
|
||||||
{
|
|
||||||
if (accel.may_have (buffer->cur().codepoint) &&
|
|
||||||
(buffer->cur().mask & c->lookup_mask) &&
|
|
||||||
c->check_glyph_property (&c->buffer->cur(), c->lookup_props) &&
|
|
||||||
lookup.apply (c))
|
|
||||||
ret = true;
|
|
||||||
else
|
|
||||||
buffer->next_glyph ();
|
|
||||||
}
|
|
||||||
if (ret)
|
|
||||||
{
|
{
|
||||||
if (!Proxy::inplace)
|
if (!Proxy::inplace)
|
||||||
buffer->swap_buffers ();
|
buffer->swap_buffers ();
|
||||||
|
@ -874,18 +907,8 @@ apply_string (OT::hb_apply_context_t *c,
|
||||||
if (Proxy::table_index == 0)
|
if (Proxy::table_index == 0)
|
||||||
buffer->remove_output ();
|
buffer->remove_output ();
|
||||||
buffer->idx = buffer->len - 1;
|
buffer->idx = buffer->len - 1;
|
||||||
do
|
|
||||||
{
|
|
||||||
if (accel.may_have (buffer->cur().codepoint) &&
|
|
||||||
(buffer->cur().mask & c->lookup_mask) &&
|
|
||||||
c->check_glyph_property (&c->buffer->cur(), c->lookup_props) &&
|
|
||||||
lookup.apply (c))
|
|
||||||
/* nothing */;
|
|
||||||
/* The reverse lookup doesn't "advance" cursor (for good reason). */
|
|
||||||
buffer->idx--;
|
|
||||||
|
|
||||||
}
|
apply_backward (c, lookup, accel);
|
||||||
while ((int) buffer->idx >= 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue