[optical-bounds] Optimize

This commit is contained in:
Behdad Esfahbod 2022-08-31 09:18:18 -06:00
parent 5d6f1a88e4
commit 4bf9621113
3 changed files with 23 additions and 13 deletions

View File

@ -81,13 +81,20 @@ struct SinglePosFormat1
}
bool
position_single (hb_ot_apply_context_t *c,
hb_codepoint_t gid,
hb_glyph_position_t &pos) const
position_single (hb_font_t *font,
hb_direction_t direction,
hb_codepoint_t gid,
hb_glyph_position_t &pos) const
{
unsigned int index = (this+coverage).get_coverage (gid);
if (likely (index == NOT_COVERED)) return false;
valueFormat.apply_value (c, this, values, pos);
/* This is ugly... */
hb_buffer_t buffer;
buffer.props.direction = direction;
OT::hb_ot_apply_context_t c (1, font, &buffer);
valueFormat.apply_value (&c, this, values, pos);
return true;
}

View File

@ -93,14 +93,21 @@ struct SinglePosFormat2
}
bool
position_single (hb_ot_apply_context_t *c,
hb_codepoint_t gid,
hb_glyph_position_t &pos) const
position_single (hb_font_t *font,
hb_direction_t direction,
hb_codepoint_t gid,
hb_glyph_position_t &pos) const
{
unsigned int index = (this+coverage).get_coverage (gid);
if (likely (index == NOT_COVERED)) return false;
if (unlikely (index >= valueCount)) return false;
valueFormat.apply_value (c, this,
/* This is ugly... */
hb_buffer_t buffer;
buffer.props.direction = direction;
OT::hb_ot_apply_context_t c (1, font, &buffer);
valueFormat.apply_value (&c, this,
&values[index * valueFormat.get_len ()],
pos);
return true;

View File

@ -1735,14 +1735,10 @@ hb_ot_layout_get_optical_bound (hb_font_t *font,
hb_direction_t direction,
hb_codepoint_t glyph)
{
/* This is ugly... */
hb_buffer_t buffer;
buffer.props.direction = direction;
OT::hb_ot_apply_context_t c_apply (1, font, &buffer);
const OT::PosLookup &lookup = font->face->table.GPOS->table->get_lookup (lookup_index);
hb_glyph_position_t pos = {0};
hb_position_single_dispatch_t c;
lookup.dispatch (&c, &c_apply, glyph, pos);
lookup.dispatch (&c, font, direction, glyph, pos);
hb_position_t ret = 0;
switch (direction)
{