diff options
author | Grigori Goronzy <greg@blackbox> | 2011-07-09 22:04:01 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2011-07-09 22:06:19 +0200 |
commit | cd29011665608d11788000e7269ce886892cf4cd (patch) | |
tree | 4de952c311d4c7debe194b586df2dc9dafb4b4ab /libass/ass_render.c | |
parent | 2e65ef93b51ce2577d19b93009c04fbc80df1ed3 (diff) | |
download | libass-cd29011665608d11788000e7269ce886892cf4cd.tar.bz2 libass-cd29011665608d11788000e7269ce886892cf4cd.tar.xz |
Redesign horizontal alignment calculations for bidi
The line alignment code determined the first and last glyph in a
line and calculated the distance from that. This is rather arcane
and doesn't easily work with bidi. Redesign the algorithm to simply
add together all individual character widths instead.
Diffstat (limited to 'libass/ass_render.c')
-rw-r--r-- | libass/ass_render.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index ec1f839..8c80210 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -1914,25 +1914,10 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, // align text last_break = -1; - for (i = 1; i < text_info->length + 1; ++i) { // (text_info->length + 1) is the end of the last line + double width = 0; + for (i = 0; i <= text_info->length; ++i) { // (text_info->length + 1) is the end of the last line if ((i == text_info->length) || glyphs[i].linebreak) { - double width, shift = 0; - GlyphInfo *first_glyph = - glyphs + last_break + 1; - GlyphInfo *last_glyph = glyphs + i - 1; - - while (first_glyph < last_glyph && first_glyph->skip) - first_glyph++; - - while ((last_glyph > first_glyph) - && ((last_glyph->symbol == '\n') - || (last_glyph->symbol == 0) - || (last_glyph->skip))) - last_glyph--; - - width = d6_to_double( - last_glyph->pos.x + last_glyph->advance.x - - first_glyph->pos.x); + double shift = 0; if (halign == HALIGN_LEFT) { // left aligned, no action shift = 0; } else if (halign == HALIGN_RIGHT) { // right aligned @@ -1944,7 +1929,11 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, glyphs[j].pos.x += double_to_d6(shift); } last_break = i - 1; + width = 0; } + if (i < text_info->length && !glyphs[i].skip && + glyphs[i].symbol != '\n' && glyphs[i].symbol != 0) + width += d6_to_double(glyphs[i].advance.x); } } else { // render_priv->state.evt_type == EVENT_HSCROLL measure_text(render_priv); |