[GPOS] Rewrite cursive attachment slightly differently

In anticipation for upcoming fix for bug reported by
Khaled in thread "Issue with cursive attachment".
This commit is contained in:
Behdad Esfahbod 2015-08-25 18:55:34 +01:00
parent fdd1770e00
commit 58f2a73fb9
1 changed files with 24 additions and 12 deletions

View File

@ -960,20 +960,32 @@ struct CursivePosFormat1
} }
/* Cross-direction adjustment */ /* Cross-direction adjustment */
if (c->lookup_props & LookupFlag::RightToLeft) {
pos[i].cursive_chain() = j - i; /* We attach child to parent (think graph theory and rooted trees whereas
if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction))) * the root stays on baseline and each node aligns itself against its
pos[i].y_offset = entry_y - exit_y; * parent.
else *
pos[i].x_offset = entry_x - exit_x; * Optimize things for the case of RightToLeft, as that's most common in
} else { * Arabinc. */
pos[j].cursive_chain() = i - j; unsigned int child = i;
if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction))) unsigned int parent = j;
pos[j].y_offset = exit_y - entry_y; hb_position_t x_offset = entry_x - exit_x;
else hb_position_t y_offset = entry_y - exit_y;
pos[j].x_offset = exit_x - entry_x; if (!(c->lookup_props & LookupFlag::RightToLeft))
{
unsigned int k = child;
child = parent;
parent = k;
x_offset = -x_offset;
y_offset = -y_offset;
} }
pos[child].cursive_chain() = parent - child;
if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction)))
pos[child].y_offset = y_offset;
else
pos[child].x_offset = x_offset;
buffer->idx = j; buffer->idx = j;
return TRACE_RETURN (true); return TRACE_RETURN (true);
} }