From 67a36a725e2a61a096ba0324f359d17f9b02d312 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod <behdad@behdad.org> Date: Thu, 26 Nov 2015 18:48:42 -0500 Subject: [PATCH] Fix vertical GPOS This was brorken earlier, though, it's really hard to notice it. Unlike the glyph_h_origin(), an unset glyph_v_origin() does NOT mean that the vertical origin is at 0,0. Related to https://github.com/behdad/harfbuzz/issues/187 --- src/hb-ot-shape.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 81ec94c88..bfbd53320 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -662,6 +662,7 @@ hb_ot_position_default (hb_ot_shape_context_t *c) { for (unsigned int i = 0; i < count; i++) pos[i].x_advance = c->font->get_glyph_h_advance (info[i].codepoint); + /* The nil glyph_h_origin() func returns 0, so no need to apply it. */ 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, @@ -671,12 +672,12 @@ hb_ot_position_default (hb_ot_shape_context_t *c) else { for (unsigned int i = 0; i < count; i++) + { pos[i].y_advance = c->font->get_glyph_v_advance (info[i].codepoint); - 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); + 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); @@ -726,6 +727,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) /* Change glyph origin to what GPOS expects (horizontal), apply GPOS, change it back. */ + /* The nil glyph_h_origin() func returns 0, so no need to apply it. */ 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, @@ -734,6 +736,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) c->plan->position (c->font, c->buffer); + /* The nil glyph_h_origin() func returns 0, so no need to apply it. */ 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,