[OTLayout] Add start/end to apply_string()

No functional change.
This commit is contained in:
Behdad Esfahbod 2013-04-21 16:03:27 -04:00
parent 1b972d893a
commit 68db8c49d8
6 changed files with 37 additions and 16 deletions

View File

@ -1461,19 +1461,24 @@ struct PosLookup : Lookup
static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index); static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const inline bool apply_string (hb_apply_context_t *c,
unsigned int start,
unsigned int end,
const hb_set_digest_t *digest) const
{ {
bool ret = false; bool ret = false;
if (unlikely (!c->buffer->len || !c->lookup_mask)) end = MIN (end, c->buffer->len);
if (unlikely (start >= end || !c->lookup_mask))
return false; return false;
c->set_recurse_func (apply_recurse_func); c->set_recurse_func (apply_recurse_func);
c->set_lookup (*this); c->set_lookup (*this);
c->buffer->idx = 0; c->buffer->idx = start;
while (c->buffer->idx < c->buffer->len) while (c->buffer->idx < end)
{ {
if (digest->may_have (c->buffer->cur().codepoint) && if (digest->may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) && (c->buffer->cur().mask & c->lookup_mask) &&

View File

@ -1247,11 +1247,15 @@ struct SubstLookup : Lookup
} }
static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index); static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const inline bool apply_string (hb_apply_context_t *c,
unsigned int start,
unsigned int end,
const hb_set_digest_t *digest) const
{ {
bool ret = false; bool ret = false;
end = MIN (end, c->buffer->len);
if (unlikely (!c->buffer->len || !c->lookup_mask)) if (unlikely (start >= end || !c->lookup_mask))
return false; return false;
c->set_recurse_func (apply_recurse_func); c->set_recurse_func (apply_recurse_func);
@ -1261,9 +1265,10 @@ struct SubstLookup : Lookup
{ {
/* in/out forward substitution */ /* in/out forward substitution */
c->buffer->clear_output (); c->buffer->clear_output ();
c->buffer->idx = 0;
while (c->buffer->idx < c->buffer->len) c->buffer->idx = start;
while (c->buffer->idx < end)
{ {
if (digest->may_have (c->buffer->cur().codepoint) && if (digest->may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) && (c->buffer->cur().mask & c->lookup_mask) &&
@ -1272,14 +1277,15 @@ struct SubstLookup : Lookup
else else
c->buffer->next_glyph (); c->buffer->next_glyph ();
} }
if (ret) if (ret)
c->buffer->swap_buffers (); c->buffer->swap_buffers ();
} }
else else
{ {
/* in-place backward substitution */ /* in-place backward substitution */
c->buffer->remove_output (); c->buffer->remove_output ();
c->buffer->idx = c->buffer->len - 1; c->buffer->idx = end - 1;
do do
{ {
if (digest->may_have (c->buffer->cur().codepoint) && if (digest->may_have (c->buffer->cur().codepoint) &&
@ -1288,9 +1294,8 @@ struct SubstLookup : Lookup
ret = true; ret = true;
else else
c->buffer->idx--; c->buffer->idx--;
} }
while ((int) c->buffer->idx >= 0); while ((int) c->buffer->idx >= (int) start);
} }
return ret; return ret;

View File

@ -223,6 +223,8 @@ HB_INTERNAL hb_bool_t
hb_ot_layout_substitute_lookup (hb_font_t *font, hb_ot_layout_substitute_lookup (hb_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
unsigned int start,
unsigned int end,
hb_mask_t mask, hb_mask_t mask,
hb_bool_t auto_zwj); hb_bool_t auto_zwj);
@ -246,6 +248,8 @@ HB_INTERNAL hb_bool_t
hb_ot_layout_position_lookup (hb_font_t *font, hb_ot_layout_position_lookup (hb_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
unsigned int start,
unsigned int end,
hb_mask_t mask, hb_mask_t mask,
hb_bool_t auto_zwj); hb_bool_t auto_zwj);

View File

@ -724,6 +724,8 @@ hb_bool_t
hb_ot_layout_substitute_lookup (hb_font_t *font, hb_ot_layout_substitute_lookup (hb_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
unsigned int start,
unsigned int end,
hb_mask_t mask, hb_mask_t mask,
hb_bool_t auto_zwj) hb_bool_t auto_zwj)
{ {
@ -733,7 +735,7 @@ hb_ot_layout_substitute_lookup (hb_font_t *font,
const OT::SubstLookup& l = hb_ot_layout_from_face (font->face)->gsub->get_lookup (lookup_index); const OT::SubstLookup& l = hb_ot_layout_from_face (font->face)->gsub->get_lookup (lookup_index);
return l.apply_string (&c, &hb_ot_layout_from_face (font->face)->gsub_digests[lookup_index]); return l.apply_string (&c, start, end, &hb_ot_layout_from_face (font->face)->gsub_digests[lookup_index]);
} }
void void
@ -775,6 +777,8 @@ hb_bool_t
hb_ot_layout_position_lookup (hb_font_t *font, hb_ot_layout_position_lookup (hb_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
unsigned int start,
unsigned int end,
hb_mask_t mask, hb_mask_t mask,
hb_bool_t auto_zwj) hb_bool_t auto_zwj)
{ {
@ -784,7 +788,7 @@ hb_ot_layout_position_lookup (hb_font_t *font,
const OT::PosLookup& l = hb_ot_layout_from_face (font->face)->gpos->get_lookup (lookup_index); const OT::PosLookup& l = hb_ot_layout_from_face (font->face)->gpos->get_lookup (lookup_index);
return l.apply_string (&c, &hb_ot_layout_from_face (font->face)->gpos_digests[lookup_index]); return l.apply_string (&c, start, end, &hb_ot_layout_from_face (font->face)->gpos_digests[lookup_index]);
} }
void void

View File

@ -116,12 +116,14 @@ inline void hb_ot_map_t::apply (unsigned int table_index,
{ {
case 0: case 0:
hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index, hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index,
0, (unsigned int) -1,
lookups[table_index][i].mask, lookups[table_index][i].mask,
lookups[table_index][i].auto_zwj); lookups[table_index][i].auto_zwj);
break; break;
case 1: case 1:
hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index,
0, (unsigned int) -1,
lookups[table_index][i].mask, lookups[table_index][i].mask,
lookups[table_index][i].auto_zwj); lookups[table_index][i].auto_zwj);
break; break;

View File

@ -245,9 +245,10 @@ arabic_fallback_plan_shape (arabic_fallback_plan_t *fallback_plan,
hb_buffer_t *buffer) hb_buffer_t *buffer)
{ {
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++) for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
if (fallback_plan->lookup_array[i]) { if (fallback_plan->lookup_array[i])
{
OT::hb_apply_context_t c (0, font, buffer, fallback_plan->mask_array[i], true/*auto_zwj*/); OT::hb_apply_context_t c (0, font, buffer, fallback_plan->mask_array[i], true/*auto_zwj*/);
fallback_plan->lookup_array[i]->apply_string (&c, &fallback_plan->digest_array[i]); fallback_plan->lookup_array[i]->apply_string (&c, 0, (unsigned int) -1, &fallback_plan->digest_array[i]);
} }
} }