From: Behdad Esfahbod Date: Thu, 5 Nov 2015 05:53:16 +0000 (-0800) Subject: Optimize positioning for when h_origin is nil X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bc28b5f688ee90d103d052e98bc15d6e0e7e0b1;p=platform%2Fupstream%2FlibHarfBuzzSharp.git Optimize positioning for when h_origin is nil --- diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 455ebab..e0331cd 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; }