Imported Upstream version 2.6.7
[platform/upstream/harfbuzz.git] / src / hb-aat-layout-kerx-table.hh
index be1b339..6ad32b3 100644 (file)
@@ -281,35 +281,28 @@ struct KerxSubTableFormat1
 
          hb_glyph_position_t &o = buffer->pos[idx];
 
-         /* Testing shows that CoreText only applies kern (cross-stream or not)
-          * if none has been applied by previous subtables.  That is, it does
-          * NOT seem to accumulate as otherwise implied by specs. */
-
-         /* The following flag is undocumented in the spec, but described
-          * in the 'kern' table example. */
-         if (v == -0x8000)
-         {
-           o.attach_type() = ATTACH_TYPE_NONE;
-           o.attach_chain() = 0;
-           o.x_offset = o.y_offset = 0;
-         }
-         else if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
+         if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
          {
            if (crossStream)
            {
-             if (buffer->pos[idx].attach_type() && !buffer->pos[idx].y_offset)
+             /* The following flag is undocumented in the spec, but described
+              * in the 'kern' table example. */
+             if (v == -0x8000)
              {
-               o.y_offset = c->font->em_scale_y (v);
+               o.attach_type() = ATTACH_TYPE_NONE;
+               o.attach_chain() = 0;
+               o.y_offset = 0;
+             }
+             else if (o.attach_type())
+             {
+               o.y_offset += c->font->em_scale_y (v);
                buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
              }
            }
            else if (buffer->info[idx].mask & kern_mask)
            {
-             if (!buffer->pos[idx].x_offset)
-             {
-               buffer->pos[idx].x_advance += c->font->em_scale_x (v);
-               buffer->pos[idx].x_offset += c->font->em_scale_x (v);
-             }
+             o.x_advance += c->font->em_scale_x (v);
+             o.x_offset += c->font->em_scale_x (v);
            }
          }
          else
@@ -317,19 +310,22 @@ struct KerxSubTableFormat1
            if (crossStream)
            {
              /* CoreText doesn't do crossStream kerning in vertical.  We do. */
-             if (buffer->pos[idx].attach_type() && !buffer->pos[idx].x_offset)
+             if (v == -0x8000)
+             {
+               o.attach_type() = ATTACH_TYPE_NONE;
+               o.attach_chain() = 0;
+               o.x_offset = 0;
+             }
+             else if (o.attach_type())
              {
-               o.x_offset = c->font->em_scale_x (v);
+               o.x_offset += c->font->em_scale_x (v);
                buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
              }
            }
            else if (buffer->info[idx].mask & kern_mask)
            {
-             if (!buffer->pos[idx].y_offset)
-             {
-               buffer->pos[idx].y_advance += c->font->em_scale_y (v);
-               buffer->pos[idx].y_offset += c->font->em_scale_y (v);
-             }
+             o.y_advance += c->font->em_scale_y (v);
+             o.y_offset += c->font->em_scale_y (v);
            }
          }
        }