[GPOS] Fix cursive connection with mix of RTL and non-RTL lookups
See thread "Issue with cursive attachment" started by Khaled. Turned out fixing this wasn't as bad as I had assumed. I like the new code better; we now have a theoretical model of cursive connections that is easier to reason about.
This commit is contained in:
parent
7368da6724
commit
6578575cc8
|
@ -883,6 +883,9 @@ struct EntryExitRecord
|
||||||
DEFINE_SIZE_STATIC (4);
|
DEFINE_SIZE_STATIC (4);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
reverse_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction, unsigned int new_parent);
|
||||||
|
|
||||||
struct CursivePosFormat1
|
struct CursivePosFormat1
|
||||||
{
|
{
|
||||||
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
||||||
|
@ -980,6 +983,13 @@ struct CursivePosFormat1
|
||||||
y_offset = -y_offset;
|
y_offset = -y_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If child was already connected to someone else, walk through its old
|
||||||
|
* chain and reverse the link direction, such that the whole tree of its
|
||||||
|
* previous connection now attaches to new parent. Watch out for case
|
||||||
|
* where new parent is on the path from old chain...
|
||||||
|
*/
|
||||||
|
reverse_cursive_minor_offset (pos, child, c->direction, parent);
|
||||||
|
|
||||||
pos[child].cursive_chain() = parent - child;
|
pos[child].cursive_chain() = parent - child;
|
||||||
if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction)))
|
if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction)))
|
||||||
pos[child].y_offset = y_offset;
|
pos[child].y_offset = y_offset;
|
||||||
|
@ -1494,6 +1504,30 @@ struct GPOS : GSUBGPOS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
reverse_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction, unsigned int new_parent)
|
||||||
|
{
|
||||||
|
unsigned int j = pos[i].cursive_chain();
|
||||||
|
if (likely (!j))
|
||||||
|
return;
|
||||||
|
|
||||||
|
j += i;
|
||||||
|
|
||||||
|
pos[i].cursive_chain() = 0;
|
||||||
|
|
||||||
|
/* Stop if we see new parent in the chain. */
|
||||||
|
if (j == new_parent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
reverse_cursive_minor_offset (pos, j, direction, new_parent);
|
||||||
|
|
||||||
|
if (HB_DIRECTION_IS_HORIZONTAL (direction))
|
||||||
|
pos[j].y_offset = -pos[i].y_offset;
|
||||||
|
else
|
||||||
|
pos[j].x_offset = -pos[i].x_offset;
|
||||||
|
|
||||||
|
pos[j].cursive_chain() = i - j;
|
||||||
|
}
|
||||||
static void
|
static void
|
||||||
fix_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction)
|
fix_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue