Minor refactoring
This commit is contained in:
parent
f94b0aa646
commit
650ac00da3
@ -1417,24 +1417,22 @@ struct PosLookup : Lookup
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool apply_string (hb_font_t *font,
|
||||
hb_buffer_t *buffer,
|
||||
hb_mask_t mask) const
|
||||
inline bool apply_string (hb_apply_context_t *c) const
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (unlikely (!buffer->len))
|
||||
if (unlikely (!c->buffer->len))
|
||||
return false;
|
||||
|
||||
hb_apply_context_t c (font, font->face, buffer, mask, *this);
|
||||
c->set_lookup (*this);
|
||||
|
||||
buffer->idx = 0;
|
||||
while (buffer->idx < buffer->len)
|
||||
c->buffer->idx = 0;
|
||||
while (c->buffer->idx < c->buffer->len)
|
||||
{
|
||||
if ((buffer->info[buffer->idx].mask & mask) && apply_once (&c))
|
||||
if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
|
||||
ret = true;
|
||||
else
|
||||
buffer->idx++;
|
||||
c->buffer->idx++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -1461,11 +1459,8 @@ struct GPOS : GSUBGPOS
|
||||
inline const PosLookup& get_lookup (unsigned int i) const
|
||||
{ return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }
|
||||
|
||||
inline bool position_lookup (hb_font_t *font,
|
||||
hb_buffer_t *buffer,
|
||||
unsigned int lookup_index,
|
||||
hb_mask_t mask) const
|
||||
{ return get_lookup (lookup_index).apply_string (font, buffer, mask); }
|
||||
inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index) const
|
||||
{ return get_lookup (lookup_index).apply_string (c); }
|
||||
|
||||
static inline void position_start (hb_buffer_t *buffer);
|
||||
static inline void position_finish (hb_buffer_t *buffer);
|
||||
@ -1584,7 +1579,9 @@ static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_i
|
||||
if (unlikely (c->context_length < 1))
|
||||
return false;
|
||||
|
||||
hb_apply_context_t new_c (*c, l);
|
||||
hb_apply_context_t new_c (*c);
|
||||
new_c.nesting_level_left--;
|
||||
new_c.set_lookup (l);
|
||||
return l.apply_once (&new_c);
|
||||
}
|
||||
|
||||
|
@ -1069,46 +1069,44 @@ struct SubstLookup : Lookup
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool apply_string (hb_face_t *face,
|
||||
hb_buffer_t *buffer,
|
||||
hb_mask_t mask) const
|
||||
inline bool apply_string (hb_apply_context_t *c) const
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (unlikely (!buffer->len))
|
||||
if (unlikely (!c->buffer->len))
|
||||
return false;
|
||||
|
||||
hb_apply_context_t c (NULL, face, buffer, mask, *this);
|
||||
c->set_lookup (*this);
|
||||
|
||||
if (likely (!is_reverse ()))
|
||||
{
|
||||
/* in/out forward substitution */
|
||||
buffer->clear_output ();
|
||||
buffer->idx = 0;
|
||||
while (buffer->idx < buffer->len)
|
||||
c->buffer->clear_output ();
|
||||
c->buffer->idx = 0;
|
||||
while (c->buffer->idx < c->buffer->len)
|
||||
{
|
||||
if ((buffer->info[buffer->idx].mask & mask) && apply_once (&c))
|
||||
if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
|
||||
ret = true;
|
||||
else
|
||||
buffer->next_glyph ();
|
||||
c->buffer->next_glyph ();
|
||||
|
||||
}
|
||||
if (ret)
|
||||
buffer->swap_buffers ();
|
||||
c->buffer->swap_buffers ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* in-place backward substitution */
|
||||
buffer->idx = buffer->len - 1;
|
||||
c->buffer->idx = c->buffer->len - 1;
|
||||
do
|
||||
{
|
||||
if ((buffer->info[buffer->idx].mask & mask) && apply_once (&c))
|
||||
if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
|
||||
ret = true;
|
||||
else
|
||||
buffer->idx--;
|
||||
c->buffer->idx--;
|
||||
|
||||
}
|
||||
while ((int) buffer->idx >= 0);
|
||||
while ((int) c->buffer->idx >= 0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -1135,11 +1133,8 @@ struct GSUB : GSUBGPOS
|
||||
inline const SubstLookup& get_lookup (unsigned int i) const
|
||||
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
|
||||
|
||||
inline bool substitute_lookup (hb_face_t *face,
|
||||
hb_buffer_t *buffer,
|
||||
unsigned int lookup_index,
|
||||
hb_mask_t mask) const
|
||||
{ return get_lookup (lookup_index).apply_string (face, buffer, mask); }
|
||||
inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index) const
|
||||
{ return get_lookup (lookup_index).apply_string (c); }
|
||||
|
||||
static inline void substitute_start (hb_buffer_t *buffer);
|
||||
static inline void substitute_finish (hb_buffer_t *buffer);
|
||||
@ -1238,7 +1233,9 @@ static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup
|
||||
if (unlikely (c->context_length < 1))
|
||||
return false;
|
||||
|
||||
hb_apply_context_t new_c (*c, l);
|
||||
hb_apply_context_t new_c (*c);
|
||||
new_c.nesting_level_left--;
|
||||
new_c.set_lookup (l);
|
||||
return l.apply_once (&new_c);
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,6 @@ struct hb_apply_context_t
|
||||
hb_face_t *face_,
|
||||
hb_buffer_t *buffer_,
|
||||
hb_mask_t lookup_mask_,
|
||||
const Lookup &l,
|
||||
unsigned int context_length_ = NO_CONTEXT,
|
||||
unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
|
||||
font (font_), face (face_), buffer (buffer_),
|
||||
@ -111,12 +110,9 @@ struct hb_apply_context_t
|
||||
lookup_mask (lookup_mask_),
|
||||
context_length (context_length_),
|
||||
nesting_level_left (nesting_level_left_),
|
||||
lookup_props (l.get_props ()),
|
||||
property (0), debug_depth (0) {}
|
||||
lookup_props (0), property (0), debug_depth (0) {}
|
||||
|
||||
hb_apply_context_t (const hb_apply_context_t &c, const Lookup &l) {
|
||||
*this = c;
|
||||
nesting_level_left--;
|
||||
void set_lookup (const Lookup &l) {
|
||||
lookup_props = l.get_props ();
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,8 @@ hb_ot_layout_substitute_lookup (hb_face_t *face,
|
||||
unsigned int lookup_index,
|
||||
hb_mask_t mask)
|
||||
{
|
||||
return _get_gsub (face).substitute_lookup (face, buffer, lookup_index, mask);
|
||||
hb_apply_context_t c (NULL, face, buffer, mask);
|
||||
return _get_gsub (face).substitute_lookup (&c, lookup_index);
|
||||
}
|
||||
|
||||
void
|
||||
@ -500,7 +501,8 @@ hb_ot_layout_position_lookup (hb_font_t *font,
|
||||
unsigned int lookup_index,
|
||||
hb_mask_t mask)
|
||||
{
|
||||
return _get_gpos (font->face).position_lookup (font, buffer, lookup_index, mask);
|
||||
hb_apply_context_t c (font, font->face, buffer, mask);
|
||||
return _get_gpos (font->face).position_lookup (&c, lookup_index);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user