[kern] Adjust some more

Getting closer.  So many open questions still...
This commit is contained in:
Behdad Esfahbod 2018-11-06 21:04:40 -05:00
parent 4d003b8503
commit 564e8ac046
1 changed files with 22 additions and 14 deletions

View File

@ -266,13 +266,9 @@ struct KernSubTableFormat1
} }
hb_mask_t kern_mask = c->plan->kern_mask; hb_mask_t kern_mask = c->plan->kern_mask;
for (unsigned int i = 0; i < depth; i++) while (depth--)
{ {
/* Apparently, when spec says "Each pops one glyph from the kerning stack unsigned int idx = stack[depth];
* and applies the kerning value to it.", it doesn't mean it in that order.
* The deepest item in the stack corresponds to the first item in the action
* list. Discovered by testing. */
unsigned int idx = stack[i];
int v = *actions++; int v = *actions++;
/* The following two flags are undocumented in the spec, but described /* The following two flags are undocumented in the spec, but described
@ -291,32 +287,44 @@ struct KernSubTableFormat1
{ {
if (crossStream) if (crossStream)
{ {
/* XXX Why negative, not positive?!?! */ if (!buffer->pos[idx].y_offset)
crossOffset -= v;
buffer->pos[idx].y_offset += c->font->em_scale_y (crossOffset); buffer->pos[idx].y_offset += c->font->em_scale_y (crossOffset);
/* XXX Why negative, not positive?!?! */
v = -v;
crossOffset += v;
} }
else else
{
if (!buffer->pos[idx].x_offset)
{ {
buffer->pos[idx].x_advance += c->font->em_scale_x (v); buffer->pos[idx].x_advance += c->font->em_scale_x (v);
if (last)
buffer->pos[idx].x_offset += c->font->em_scale_x (v); buffer->pos[idx].x_offset += c->font->em_scale_x (v);
} }
} }
}
else else
{ {
if (crossStream) if (crossStream)
{ {
/* CoreText doesn't do crossStream kerning in vertical. */
#if 0
if (!buffer->pos[idx].x_offset)
buffer->pos[idx].x_offset = c->font->em_scale_x (crossOffset);
#endif
/* XXX Why negative, not positive?!?! */
v = -v;
crossOffset += v; crossOffset += v;
buffer->pos[idx].x_offset += c->font->em_scale_x (crossOffset);
} }
else else
{
if (!buffer->pos[idx].y_offset)
{ {
buffer->pos[idx].y_advance += c->font->em_scale_y (v); buffer->pos[idx].y_advance += c->font->em_scale_y (v);
if (last)
buffer->pos[idx].y_offset += c->font->em_scale_y (v); buffer->pos[idx].y_offset += c->font->em_scale_y (v);
} }
} }
} }
}
if (last) if (last)
break; break;
} }