Add hb_ot_layout_position_finish()
We expect buffer to be setup with default positions before GPOS.
This commit is contained in:
parent
edb54e9aec
commit
9db8ad7531
|
@ -51,11 +51,7 @@ typedef struct _hb_internal_glyph_position_t {
|
|||
hb_position_t y_advance;
|
||||
hb_position_t x_offset;
|
||||
hb_position_t y_offset;
|
||||
uint32_t new_advance :1; /* if set, the advance width values are
|
||||
absolute, i.e., they won't be
|
||||
added to the original glyph's value
|
||||
but rather replace them */
|
||||
uint32_t back : 15; /* number of glyphs to go back
|
||||
uint32_t back : 16; /* number of glyphs to go back
|
||||
for drawing current glyph */
|
||||
int32_t cursive_chain : 16; /* character to which this connects,
|
||||
may be positive or negative; used
|
||||
|
|
|
@ -56,16 +56,7 @@ typedef struct _hb_glyph_position_t {
|
|||
hb_position_t y_advance;
|
||||
hb_position_t x_offset;
|
||||
hb_position_t y_offset;
|
||||
/* XXX these should all be replaced by "uint32_t internal" */
|
||||
uint32_t new_advance :1; /* if set, the advance width values are
|
||||
absolute, i.e., they won't be
|
||||
added to the original glyph's value
|
||||
but rather replace them */
|
||||
uint32_t back : 15; /* number of glyphs to go back
|
||||
for drawing current glyph */
|
||||
int32_t cursive_chain : 16; /* character to which this connects,
|
||||
may be positive or negative; used
|
||||
only internally */
|
||||
uint32_t internal;
|
||||
} hb_glyph_position_t;
|
||||
|
||||
|
||||
|
|
|
@ -840,13 +840,13 @@ struct CursivePosFormat1
|
|||
|
||||
if (buffer->direction == HB_DIRECTION_RTL)
|
||||
{
|
||||
/* advance is absolute, not relative */
|
||||
POSITION (buffer->in_pos)->x_advance = entry_x - gpi->anchor_x;
|
||||
POSITION (buffer->in_pos)->new_advance = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* advance is absolute, not relative */
|
||||
POSITION (last_pos)->x_advance = gpi->anchor_x - entry_x;
|
||||
POSITION (last_pos)->new_advance = true;
|
||||
}
|
||||
|
||||
if (lookup_flag & LookupFlag::RightToLeft)
|
||||
|
|
|
@ -564,3 +564,55 @@ hb_ot_layout_position_lookup (hb_face_t *face,
|
|||
context.face = face;
|
||||
return _get_gpos (face).position_lookup (&context, buffer, lookup_index, mask);
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
void
|
||||
hb_ot_layout_position_finish (hb_face_t *face,
|
||||
hb_font_t *font,
|
||||
hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int i, j;
|
||||
unsigned int len = hb_buffer_get_length (buffer);
|
||||
hb_internal_glyph_position_t *positions = (hb_internal_glyph_position_t *) hb_buffer_get_glyph_positions (buffer);
|
||||
|
||||
/* TODO: Vertical */
|
||||
|
||||
/* Handle cursive connections */
|
||||
/* First handle all left-to-right connections */
|
||||
for (j = 0; j < len; j++) {
|
||||
if (positions[j].cursive_chain > 0) {
|
||||
printf ("0000000000000\n");
|
||||
positions[j].y_offset += positions[j - positions[j].cursive_chain].y_offset;
|
||||
positions[j].cursive_chain = 0;
|
||||
}
|
||||
}
|
||||
/* Then handle all right-to-left connections */
|
||||
for (i = len; i > 0; i--) {
|
||||
j = i - 1;
|
||||
if (positions[j].cursive_chain < 0) {
|
||||
positions[j].y_offset += positions[j - positions[j].cursive_chain].y_offset;
|
||||
positions[j].cursive_chain = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle attachments */
|
||||
for (i = 0; i < len; i++)
|
||||
if (positions[i].back)
|
||||
{
|
||||
unsigned int back = i - positions[i].back;
|
||||
positions[i].back = 0;
|
||||
positions[i].x_offset += positions[back].x_offset;
|
||||
positions[i].y_offset += positions[back].y_offset;
|
||||
|
||||
if (buffer->direction == HB_DIRECTION_RTL)
|
||||
for (j = back + 1; j < i + 1; j++) {
|
||||
positions[i].x_offset += positions[j].x_advance;
|
||||
positions[i].y_offset += positions[j].y_advance;
|
||||
}
|
||||
else
|
||||
for (j = back; j < i; j++) {
|
||||
positions[i].x_offset -= positions[j].x_advance;
|
||||
positions[i].y_offset -= positions[j].y_advance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,6 +204,12 @@ hb_ot_layout_position_lookup (hb_face_t *face,
|
|||
unsigned int lookup_index,
|
||||
hb_mask_t mask);
|
||||
|
||||
/* Should be called after all the position_lookup's are done */
|
||||
void
|
||||
hb_ot_layout_position_finish (hb_face_t *face,
|
||||
hb_font_t *font,
|
||||
hb_buffer_t *buffer);
|
||||
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in New Issue