diff options
author | Oleg Oshmyan <chortos@inbox.lv> | 2020-10-16 22:50:41 +0300 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2020-10-18 05:03:17 +0300 |
commit | 24bff1571420d08bfbcc8754af3d3ea0c0bed4b2 (patch) | |
tree | 50b150e5413aaf770e1ffa7b270a1f85a830bdb8 | |
parent | b27b97ae52a0af7f4a0f32b32c280d8cc1dae12c (diff) | |
download | libass-24bff1571420d08bfbcc8754af3d3ea0c0bed4b2.tar.bz2 libass-24bff1571420d08bfbcc8754af3d3ea0c0bed4b2.tar.xz |
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.
-rw-r--r-- | libass/ass_parse.c | 1 | ||||
-rw-r--r-- | libass/ass_render.c | 17 |
2 files changed, 6 insertions, 12 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c index 56a02be..8347cf2 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -908,6 +908,7 @@ void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event) render_priv->state.scroll_shift = (render_priv->time - render_priv->state.event->Start) / delay; render_priv->state.evt_type = EVENT_HSCROLL; + render_priv->state.wrap_style = 2; return; } 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); |