[otlayout] Simplify ligate_input()
Shouldn't change behavior at all, but is faster / more robust.
This commit is contained in:
parent
6b2abdcd20
commit
e714fe6d6a
|
@ -663,28 +663,26 @@ struct Ligature
|
||||||
unsigned int count = component.len;
|
unsigned int count = component.len;
|
||||||
if (unlikely (count < 1)) return TRACE_RETURN (false);
|
if (unlikely (count < 1)) return TRACE_RETURN (false);
|
||||||
|
|
||||||
unsigned int end_offset = 0;
|
|
||||||
bool is_mark_ligature = false;
|
bool is_mark_ligature = false;
|
||||||
unsigned int total_component_count = 0;
|
unsigned int total_component_count = 0;
|
||||||
|
|
||||||
|
unsigned int match_length = 0;
|
||||||
|
unsigned int match_positions[MAX_CONTEXT_LENGTH];
|
||||||
|
|
||||||
if (likely (!match_input (c, count,
|
if (likely (!match_input (c, count,
|
||||||
&component[1],
|
&component[1],
|
||||||
match_glyph,
|
match_glyph,
|
||||||
NULL,
|
NULL,
|
||||||
&end_offset,
|
&match_length,
|
||||||
NULL,
|
match_positions,
|
||||||
&is_mark_ligature,
|
&is_mark_ligature,
|
||||||
&total_component_count)))
|
&total_component_count)))
|
||||||
return TRACE_RETURN (false);
|
return TRACE_RETURN (false);
|
||||||
|
|
||||||
/* Deal, we are forming the ligature. */
|
|
||||||
c->buffer->merge_clusters (c->buffer->idx, c->buffer->idx + end_offset);
|
|
||||||
|
|
||||||
ligate_input (c,
|
ligate_input (c,
|
||||||
count,
|
count,
|
||||||
&component[1],
|
match_positions,
|
||||||
match_glyph,
|
match_length,
|
||||||
NULL,
|
|
||||||
ligGlyph,
|
ligGlyph,
|
||||||
is_mark_ligature,
|
is_mark_ligature,
|
||||||
total_component_count);
|
total_component_count);
|
||||||
|
|
|
@ -832,17 +832,16 @@ static inline bool match_input (hb_apply_context_t *c,
|
||||||
return TRACE_RETURN (true);
|
return TRACE_RETURN (true);
|
||||||
}
|
}
|
||||||
static inline void ligate_input (hb_apply_context_t *c,
|
static inline void ligate_input (hb_apply_context_t *c,
|
||||||
unsigned int count, /* Including the first glyph (not matched) */
|
unsigned int count, /* Including the first glyph */
|
||||||
const USHORT input[], /* Array of input values--start with second glyph */
|
unsigned int match_positions[MAX_CONTEXT_LENGTH], /* Including the first glyph */
|
||||||
match_func_t match_func,
|
unsigned int match_length,
|
||||||
const void *match_data,
|
|
||||||
hb_codepoint_t lig_glyph,
|
hb_codepoint_t lig_glyph,
|
||||||
bool is_mark_ligature,
|
bool is_mark_ligature,
|
||||||
unsigned int total_component_count)
|
unsigned int total_component_count)
|
||||||
{
|
{
|
||||||
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1);
|
TRACE_APPLY (NULL);
|
||||||
skippy_iter.set_match_func (match_func, match_data, input);
|
|
||||||
if (skippy_iter.has_no_chance ()) return;
|
c->buffer->merge_clusters (c->buffer->idx, c->buffer->idx + match_length);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* - If it *is* a mark ligature, we don't allocate a new ligature id, and leave
|
* - If it *is* a mark ligature, we don't allocate a new ligature id, and leave
|
||||||
|
@ -888,9 +887,7 @@ static inline void ligate_input (hb_apply_context_t *c,
|
||||||
|
|
||||||
for (unsigned int i = 1; i < count; i++)
|
for (unsigned int i = 1; i < count; i++)
|
||||||
{
|
{
|
||||||
if (!skippy_iter.next ()) return;
|
while (c->buffer->idx < match_positions[i])
|
||||||
|
|
||||||
while (c->buffer->idx < skippy_iter.idx)
|
|
||||||
{
|
{
|
||||||
if (!is_mark_ligature) {
|
if (!is_mark_ligature) {
|
||||||
unsigned int new_lig_comp = components_so_far - last_num_components +
|
unsigned int new_lig_comp = components_so_far - last_num_components +
|
||||||
|
|
Loading…
Reference in New Issue