(this+this_record.exitAnchor).get_anchor (c->layout, c->buffer->info[i].codepoint, &exit_x, &exit_y);
(this+next_record.entryAnchor).get_anchor (c->layout, c->buffer->info[j].codepoint, &entry_x, &entry_y);
- /* TODO vertical */
+ hb_direction_t direction = c->buffer->props.direction;
- /* Align the exit anchor of the left glyph with the entry anchor of the right glyph. */
- if (c->buffer->props.direction == HB_DIRECTION_RTL)
+ /* Align the exit anchor of the left/top glyph with the entry anchor of the right/bottom glyph
+ * by adjusting advance of the left/top glyph. */
+ if (HB_DIRECTION_IS_BACKWARD (direction))
{
- c->buffer->pos[j].x_advance = c->buffer->pos[j].x_offset + entry_x - exit_x;
+ if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+ c->buffer->pos[j].x_advance = c->buffer->pos[j].x_offset + entry_x - exit_x;
+ else
+ c->buffer->pos[j].y_advance = c->buffer->pos[j].y_offset + entry_y - exit_y;
}
else
{
- c->buffer->pos[i].x_advance = c->buffer->pos[i].x_offset + exit_x - entry_x;
+ if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+ c->buffer->pos[i].x_advance = c->buffer->pos[i].x_offset + exit_x - entry_x;
+ else
+ c->buffer->pos[i].y_advance = c->buffer->pos[i].y_offset + exit_y - entry_y;
}
if (c->lookup_flag & LookupFlag::RightToLeft)
{
c->buffer->pos[i].cursive_chain = j - i;
- c->buffer->pos[i].y_offset = entry_y - exit_y;
+ if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+ c->buffer->pos[i].y_offset = entry_y - exit_y;
+ else
+ c->buffer->pos[i].x_offset = entry_x - exit_x;
}
else
{
c->buffer->pos[j].cursive_chain = i - j;
- c->buffer->pos[j].y_offset = exit_y - entry_y;
+ if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+ c->buffer->pos[j].y_offset = exit_y - entry_y;
+ else
+ c->buffer->pos[j].x_offset = exit_x - entry_x;
}
c->buffer->i = j;
unsigned int i, j;
unsigned int len = hb_buffer_get_length (buffer);
hb_internal_glyph_position_t *pos = (hb_internal_glyph_position_t *) hb_buffer_get_glyph_positions (buffer);
+ hb_direction_t direction = buffer->props.direction;
/* TODO: Vertical */
- /* Handle cursive connections */
- /* First handle all chain-back connections */
- for (j = 0; j < len; j++) {
- if (pos[j].cursive_chain < 0)
- {
- pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
- pos[j].cursive_chain = 0;
+ /* Handle cursive connections:
+ * First handle all chain-back connections, then handle all chain-forward connections. */
+ if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+ {
+ for (j = 0; j < len; j++) {
+ if (pos[j].cursive_chain < 0)
+ pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
+ }
+ for (i = len; i > 0; i--) {
+ j = i - 1;
+ if (pos[j].cursive_chain > 0)
+ pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
}
}
- /* Then handle all chain-forward connections */
- for (i = len; i > 0; i--) {
- j = i - 1;
- if (pos[j].cursive_chain > 0)
- {
- pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
- pos[j].cursive_chain = 0;
+ else
+ {
+ for (j = 0; j < len; j++) {
+ if (pos[j].cursive_chain < 0)
+ pos[j].x_offset += pos[j + pos[j].cursive_chain].x_offset;
+ }
+ for (i = len; i > 0; i--) {
+ j = i - 1;
+ if (pos[j].cursive_chain > 0)
+ pos[j].x_offset += pos[j + pos[j].cursive_chain].x_offset;
}
}
pos[i].x_offset += pos[back].x_offset;
pos[i].y_offset += pos[back].y_offset;
- if (buffer->props.direction == HB_DIRECTION_RTL)
+ if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
for (j = back + 1; j < i + 1; j++) {
pos[i].x_offset += pos[j].x_advance;
pos[i].y_offset += pos[j].y_advance;