From 5bc28b5f688ee90d103d052e98bc15d6e0e7e0b1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 4 Nov 2015 21:53:16 -0800 Subject: [PATCH] Optimize positioning for when h_origin is nil --- src/hb-ot-shape.cc | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 455ebabba..e0331cd65 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -654,22 +654,22 @@ hb_ot_position_default (hb_ot_shape_context_t *c) if (HB_DIRECTION_IS_HORIZONTAL (direction)) { for (unsigned int i = 0; i < count; i++) - { pos[i].x_advance = c->font->get_glyph_h_advance (info[i].codepoint); - c->font->subtract_glyph_h_origin (info[i].codepoint, - &pos[i].x_offset, - &pos[i].y_offset); - } + if (c->font->has_glyph_h_origin_func ()) + for (unsigned int i = 0; i < count; i++) + c->font->subtract_glyph_h_origin (info[i].codepoint, + &pos[i].x_offset, + &pos[i].y_offset); } else { for (unsigned int i = 0; i < count; i++) - { pos[i].y_advance = c->font->get_glyph_v_advance (info[i].codepoint); - c->font->subtract_glyph_v_origin (info[i].codepoint, - &pos[i].x_offset, - &pos[i].y_offset); - } + if (c->font->has_glyph_v_origin_func ()) + for (unsigned int i = 0; i < count; i++) + c->font->subtract_glyph_v_origin (info[i].codepoint, + &pos[i].x_offset, + &pos[i].y_offset); } if (c->buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK) _hb_ot_shape_fallback_spaces (c->plan, c->font, c->buffer); @@ -719,17 +719,19 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) /* Change glyph origin to what GPOS expects (horizontal), apply GPOS, change it back. */ - for (unsigned int i = 0; i < count; i++) - c->font->add_glyph_h_origin (info[i].codepoint, - &pos[i].x_offset, - &pos[i].y_offset); + if (c->font->has_glyph_h_origin_func ()) + for (unsigned int i = 0; i < count; i++) + c->font->add_glyph_h_origin (info[i].codepoint, + &pos[i].x_offset, + &pos[i].y_offset); c->plan->position (c->font, c->buffer); - for (unsigned int i = 0; i < count; i++) - c->font->subtract_glyph_h_origin (info[i].codepoint, - &pos[i].x_offset, - &pos[i].y_offset); + if (c->font->has_glyph_h_origin_func ()) + for (unsigned int i = 0; i < count; i++) + c->font->subtract_glyph_h_origin (info[i].codepoint, + &pos[i].x_offset, + &pos[i].y_offset); ret = true; }