From 24bff1571420d08bfbcc8754af3d3ea0c0bed4b2 Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Fri, 16 Oct 2020 22:50:41 +0300 Subject: Support line breaks with Banner effect Make Banner default to \q2, but allow explicit line breaks and \q overrides. Justify the lines according to \a etc., and wrap lines as usual if \q is overridden, but make sure to keep the left/right edge of the whole event flush with the edge of the screen at the event's start time as required by Banner. This is what VSFilter does. --- libass/ass_render.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'libass/ass_render.c') diff --git a/libass/ass_render.c b/libass/ass_render.c index fe499f1..2cec0e4 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -2130,8 +2130,10 @@ static void align_lines(ASS_Renderer *render_priv, double max_text_width) int justify = render_priv->state.justify; double max_width = 0; - if (render_priv->state.evt_type == EVENT_HSCROLL) - return; + if (render_priv->state.evt_type == EVENT_HSCROLL) { + justify = halign; + halign = HALIGN_LEFT; + } 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) { @@ -2639,16 +2641,7 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, x2scr_left(render_priv, MarginL); // wrap lines - if (render_priv->state.evt_type != EVENT_HSCROLL) { - // rearrange text in several lines - wrap_lines_smart(render_priv, max_text_width); - } else { - // no breaking or wrapping, everything in a single line - text_info->lines[0].offset = 0; - text_info->lines[0].len = text_info->length; - text_info->n_lines = 1; - measure_text(render_priv); - } + wrap_lines_smart(render_priv, max_text_width); reorder_text(render_priv); -- cgit v1.2.3