Supposedly implement vertical support in GPOS

Not tested at all.
This commit is contained in:
Behdad Esfahbod 2010-10-27 14:09:27 -04:00
parent 9624de5b49
commit 13528d0c78
2 changed files with 44 additions and 22 deletions

View File

@ -855,27 +855,40 @@ struct CursivePosFormat1
(this+this_record.exitAnchor).get_anchor (c->layout, c->buffer->info[i].codepoint, &exit_x, &exit_y); (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); (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. */ /* Align the exit anchor of the left/top glyph with the entry anchor of the right/bottom glyph
if (c->buffer->props.direction == HB_DIRECTION_RTL) * by adjusting advance of the left/top glyph. */
if (HB_DIRECTION_IS_BACKWARD (direction))
{ {
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
c->buffer->pos[j].x_advance = c->buffer->pos[j].x_offset + entry_x - exit_x; 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 else
{ {
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
c->buffer->pos[i].x_advance = c->buffer->pos[i].x_offset + exit_x - entry_x; 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) if (c->lookup_flag & LookupFlag::RightToLeft)
{ {
c->buffer->pos[i].cursive_chain = j - i; c->buffer->pos[i].cursive_chain = j - i;
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
c->buffer->pos[i].y_offset = entry_y - exit_y; c->buffer->pos[i].y_offset = entry_y - exit_y;
else
c->buffer->pos[i].x_offset = entry_x - exit_x;
} }
else else
{ {
c->buffer->pos[j].cursive_chain = i - j; c->buffer->pos[j].cursive_chain = i - j;
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
c->buffer->pos[j].y_offset = exit_y - entry_y; 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; c->buffer->i = j;

View File

@ -607,25 +607,34 @@ hb_ot_layout_position_finish (hb_font_t *font HB_UNUSED,
unsigned int i, j; unsigned int i, j;
unsigned int len = hb_buffer_get_length (buffer); 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_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 */ /* TODO: Vertical */
/* Handle cursive connections */ /* Handle cursive connections:
/* First handle all chain-back 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++) { for (j = 0; j < len; j++) {
if (pos[j].cursive_chain < 0) if (pos[j].cursive_chain < 0)
{
pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset; pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
pos[j].cursive_chain = 0;
} }
}
/* Then handle all chain-forward connections */
for (i = len; i > 0; i--) { for (i = len; i > 0; i--) {
j = i - 1; j = i - 1;
if (pos[j].cursive_chain > 0) if (pos[j].cursive_chain > 0)
{
pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset; 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;
} }
} }
@ -639,7 +648,7 @@ hb_ot_layout_position_finish (hb_font_t *font HB_UNUSED,
pos[i].x_offset += pos[back].x_offset; pos[i].x_offset += pos[back].x_offset;
pos[i].y_offset += pos[back].y_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++) { for (j = back + 1; j < i + 1; j++) {
pos[i].x_offset += pos[j].x_advance; pos[i].x_offset += pos[j].x_advance;
pos[i].y_offset += pos[j].y_advance; pos[i].y_offset += pos[j].y_advance;