[GPOS] Merge fixing of offsets for cursive and mark attachments
Part of fixing https://github.com/behdad/harfbuzz/issues/211
This commit is contained in:
parent
7d8d58ac81
commit
cbc3a76c5a
|
@ -56,8 +56,7 @@ enum hb_buffer_scratch_flags_t {
|
||||||
HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII = 0x00000001u,
|
HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII = 0x00000001u,
|
||||||
HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES = 0x00000002u,
|
HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES = 0x00000002u,
|
||||||
HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u,
|
HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u,
|
||||||
HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_CURSIVE = 0x00000008u,
|
HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u,
|
||||||
HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000010u,
|
|
||||||
/* Reserved for complex shapers' internal use. */
|
/* Reserved for complex shapers' internal use. */
|
||||||
HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u,
|
HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u,
|
||||||
HB_BUFFER_SCRATCH_FLAG_COMPLEX1 = 0x02000000u,
|
HB_BUFFER_SCRATCH_FLAG_COMPLEX1 = 0x02000000u,
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ struct CursivePosFormat1
|
||||||
|
|
||||||
pos[child].attach_type() = ATTACH_TYPE_CURSIVE;
|
pos[child].attach_type() = ATTACH_TYPE_CURSIVE;
|
||||||
pos[child].attach_chain() = (int) parent - (int) child;
|
pos[child].attach_chain() = (int) parent - (int) child;
|
||||||
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_CURSIVE;
|
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
|
||||||
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;
|
||||||
else
|
else
|
||||||
|
@ -1553,50 +1553,46 @@ reverse_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direc
|
||||||
pos[j].attach_type() = type;
|
pos[j].attach_type() = type;
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
fix_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction)
|
propagate_attachment_offsets (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction)
|
||||||
{
|
{
|
||||||
|
/* Adjusts offsets of attached glyphs (both cursive and mark) to accumulate
|
||||||
|
* offset of glyph they are attached to. */
|
||||||
int chain = pos[i].attach_chain(), type = pos[i].attach_type();
|
int chain = pos[i].attach_chain(), type = pos[i].attach_type();
|
||||||
if (likely (!chain || 0 == (type & ATTACH_TYPE_CURSIVE)))
|
if (likely (!chain))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
unsigned int j = (int) i + chain;
|
||||||
|
|
||||||
pos[i].attach_chain() = 0;
|
pos[i].attach_chain() = 0;
|
||||||
|
|
||||||
unsigned int j = (int) i + chain;
|
propagate_attachment_offsets (pos, j, direction);
|
||||||
|
|
||||||
fix_cursive_minor_offset (pos, j, direction);
|
assert (!!(type & ATTACH_TYPE_MARK) ^ !!(type & ATTACH_TYPE_CURSIVE));
|
||||||
|
|
||||||
if (HB_DIRECTION_IS_HORIZONTAL (direction))
|
if (type & ATTACH_TYPE_CURSIVE)
|
||||||
pos[i].y_offset += pos[j].y_offset;
|
{
|
||||||
else
|
if (HB_DIRECTION_IS_HORIZONTAL (direction))
|
||||||
|
pos[i].y_offset += pos[j].y_offset;
|
||||||
|
else
|
||||||
|
pos[i].x_offset += pos[j].x_offset;
|
||||||
|
}
|
||||||
|
else /*if (type & ATTACH_TYPE_MARK)*/
|
||||||
|
{
|
||||||
pos[i].x_offset += pos[j].x_offset;
|
pos[i].x_offset += pos[j].x_offset;
|
||||||
}
|
pos[i].y_offset += pos[j].y_offset;
|
||||||
|
|
||||||
static void
|
assert (j < i);
|
||||||
fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction)
|
if (HB_DIRECTION_IS_FORWARD (direction))
|
||||||
{
|
for (unsigned int k = j; k < i; k++) {
|
||||||
int chain = pos[i].attach_chain(), type = pos[i].attach_type();
|
pos[i].x_offset -= pos[k].x_advance;
|
||||||
if (likely (!chain || 0 == (type & ATTACH_TYPE_MARK)))
|
pos[i].y_offset -= pos[k].y_advance;
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
unsigned int j = (int) i + chain;
|
for (unsigned int k = j + 1; k < i + 1; k++) {
|
||||||
|
pos[i].x_offset += pos[k].x_advance;
|
||||||
fix_mark_attachment (pos, j, direction);
|
pos[i].y_offset += pos[k].y_advance;
|
||||||
|
}
|
||||||
|
}
|
||||||
pos[i].x_offset += pos[j].x_offset;
|
|
||||||
pos[i].y_offset += pos[j].y_offset;
|
|
||||||
|
|
||||||
assert (j < i);
|
|
||||||
if (HB_DIRECTION_IS_FORWARD (direction))
|
|
||||||
for (unsigned int k = j; k < i; k++) {
|
|
||||||
pos[i].x_offset -= pos[k].x_advance;
|
|
||||||
pos[i].y_offset -= pos[k].y_advance;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
for (unsigned int k = j + 1; k < i + 1; k++) {
|
|
||||||
pos[i].x_offset += pos[k].x_advance;
|
|
||||||
pos[i].y_offset += pos[k].y_advance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1622,15 +1618,10 @@ GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
|
||||||
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
|
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
|
||||||
hb_direction_t direction = buffer->props.direction;
|
hb_direction_t direction = buffer->props.direction;
|
||||||
|
|
||||||
/* Handle cursive connections */
|
|
||||||
if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_CURSIVE)
|
|
||||||
for (unsigned int i = 0; i < len; i++)
|
|
||||||
fix_cursive_minor_offset (pos, i, direction);
|
|
||||||
|
|
||||||
/* Handle attachments */
|
/* Handle attachments */
|
||||||
if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT)
|
if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT)
|
||||||
for (unsigned int i = 0; i < len; i++)
|
for (unsigned int i = 0; i < len; i++)
|
||||||
fix_mark_attachment (pos, i, direction);
|
propagate_attachment_offsets (pos, i, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue