Fix vertical GPOS
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 26 Nov 2015 23:48:42 +0000 (18:48 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 26 Nov 2015 23:49:54 +0000 (18:49 -0500)
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

index 81ec94c..bfbd533 100644 (file)
@@ -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,