diff options
author | Grigori Goronzy <greg@blackbox> | 2009-07-12 22:58:23 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-07-12 22:58:23 +0200 |
commit | 8d6e8231f4a33cb98a4927d8dc80bc9698cf36f2 (patch) | |
tree | a76c147370f31ce40d2b76b5d369f53006a4bd76 /libass | |
parent | 71fc0fbbf34110050bda200d25eb230b8b044324 (diff) | |
download | libass-8d6e8231f4a33cb98a4927d8dc80bc9698cf36f2.tar.bz2 libass-8d6e8231f4a33cb98a4927d8dc80bc9698cf36f2.tar.xz |
Proper support for empty lines
Calculate the line height of empty lines the VSFilter way in
measure_text; curiously, VSFilter sets the height of an empty line
to half the height of the line before.
Remove the hack that created empty lines by inserting spaces--it was
wrong anyway.
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass_render.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index 25be110e..ae65119a 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -2079,15 +2079,22 @@ static void measure_text(ass_renderer_t *render_priv) int cur_line = 0; double max_asc = 0., max_desc = 0.; int i; + int empty_line = 1; text_info->height = 0.; for (i = 0; i < text_info->length + 1; ++i) { if ((i == text_info->length) || text_info->glyphs[i].linebreak) { + if (empty_line && cur_line > 0) { + max_asc = text_info->lines[cur_line - 1].asc / 2.0; + max_desc = text_info->lines[cur_line - 1].desc / 2.0; + } text_info->lines[cur_line].asc = max_asc; text_info->lines[cur_line].desc = max_desc; text_info->height += max_asc + max_desc; cur_line++; max_asc = max_desc = 0.; - } + empty_line = 1; + } else + empty_line = 0; if (i < text_info->length) { glyph_info_t *cur = text_info->glyphs + i; if (d6_to_double(cur->asc) > max_asc) @@ -2518,14 +2525,6 @@ ass_render_event(ass_renderer_t *render_priv, ass_event_t *event, if (code == 0) break; - // Insert space between two forced breaks to create empty lines - // FIXME: should probably be done in wrap_lines_smart, - // this is a hack - if (previous == '\n' && code == '\n') { - code = ' '; - p -= 2; - } - if (text_info->length >= text_info->max_glyphs) { // Raise maximum number of glyphs text_info->max_glyphs *= 2; |