[Graphite] Fix graphite2 backend with RTL text

Patch from Martin Hosken.
This commit is contained in:
Behdad Esfahbod 2012-08-06 19:35:04 -07:00
parent e4992e13e1
commit 2fef993460
1 changed files with 17 additions and 14 deletions

View File

@ -295,27 +295,30 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
buffer->replace_glyphs (clusters[i].num_chars, clusters[i].num_glyphs, gids + clusters[i].base_glyph);
buffer->swap_buffers ();
if (HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
curradvx = gr_seg_advance_X(seg);
hb_glyph_position_t *pPos;
for (pPos = hb_buffer_get_glyph_positions (buffer, NULL), is = gr_seg_first_slot (seg);
is; pPos++, is = gr_slot_next_in_segment (is))
{
pPos->x_offset = gr_slot_origin_X(is) - curradvx;
pPos->y_offset = gr_slot_origin_Y(is) - curradvy;
pPos->x_advance = gr_slot_advance_X(is, grface, grfont);
pPos->y_advance = gr_slot_advance_Y(is, grface, grfont);
// if (pPos->x_advance < 0 && gr_slot_attached_to(is))
// pPos->x_advance = 0;
curradvx += pPos->x_advance;
pPos->x_offset = gr_slot_origin_X (is) - curradvx;
pPos->y_offset = gr_slot_origin_Y (is) - curradvy;
pPos->x_advance = gr_slot_advance_X (is, grface, grfont);
pPos->y_advance = gr_slot_advance_Y (is, grface, grfont);
if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
curradvx -= pPos->x_advance;
pPos->x_offset = gr_slot_origin_X (is) - curradvx;
if (!HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
curradvx += pPos->x_advance;
pPos->y_offset = gr_slot_origin_Y (is) - curradvy;
curradvy += pPos->y_advance;
}
pPos[-1].x_advance += gr_seg_advance_X(seg) - curradvx;
if (!HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
pPos[-1].x_advance += gr_seg_advance_X(seg) - curradvx;
/* TODO(behdad):
* This shaper is badly broken with RTL text. It returns glyphs
* in the logical order!
*/
// if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
// hb_buffer_reverse (buffer);
if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
hb_buffer_reverse_clusters (buffer);
success = 1;