summaryrefslogtreecommitdiffstats
path: root/libass/ass_render.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2011-07-10 00:38:12 +0200
committerGrigori Goronzy <greg@blackbox>2011-07-10 00:42:57 +0200
commit1500ce05a00a5d4a73728137cdf2d0a1ffa278d1 (patch)
tree4de2fb68123f8cf6fc7208d85115aca8c75de581 /libass/ass_render.c
parentcd29011665608d11788000e7269ce886892cf4cd (diff)
downloadlibass-1500ce05a00a5d4a73728137cdf2d0a1ffa278d1.tar.bz2
libass-1500ce05a00a5d4a73728137cdf2d0a1ffa278d1.tar.xz
Reorder positions for "Banner" effect text
Events that use the "Banner" effect have different wrapping/breaking handling (none at all, to be exact) and need special treatment to make reordering work.
Diffstat (limited to 'libass/ass_render.c')
-rw-r--r--libass/ass_render.c68
1 files changed, 36 insertions, 32 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index 8c80210..c0f7c87 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -1877,42 +1877,48 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event,
MarginV =
(event->MarginV) ? event->MarginV : render_priv->state.style->MarginV;
- if (render_priv->state.evt_type != EVENT_HSCROLL) {
- double max_text_width;
-
- // calculate max length of a line
- max_text_width =
- x2scr(render_priv,
- render_priv->track->PlayResX - MarginR) -
- x2scr(render_priv, MarginL);
+ // calculate max length of a line
+ double max_text_width =
+ x2scr(render_priv, render_priv->track->PlayResX - MarginR) -
+ x2scr(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);
+ }
- // Reorder text into visual order
- ass_shaper_reorder(text_info, ctypes, emblevels, cmap);
-
- // Reposition according to the map
- pen.x = 0;
- pen.y = 0;
- int lineno = 1;
- for (i = 0; i < text_info->length; i++) {
- GlyphInfo *info = glyphs + cmap[i];
- if (glyphs[i].linebreak) {
- pen.x = 0;
- pen.y += double_to_d6(text_info->lines[lineno-1].desc);
- pen.y += double_to_d6(text_info->lines[lineno].asc);
- pen.y += double_to_d6(render_priv->settings.line_spacing);
- lineno++;
- }
- if (info->skip) continue;
- info->pos.x = pen.x;
- info->pos.y = pen.y;
- pen.x += info->advance.x;
- pen.y += info->advance.y;
+ // Reorder text into visual order
+ ass_shaper_reorder(text_info, ctypes, emblevels, cmap);
+
+ // Reposition according to the map
+ pen.x = 0;
+ pen.y = 0;
+ int lineno = 1;
+ for (i = 0; i < text_info->length; i++) {
+ GlyphInfo *info = glyphs + cmap[i];
+ if (glyphs[i].linebreak) {
+ pen.x = 0;
+ pen.y += double_to_d6(text_info->lines[lineno-1].desc);
+ pen.y += double_to_d6(text_info->lines[lineno].asc);
+ pen.y += double_to_d6(render_priv->settings.line_spacing);
+ lineno++;
}
+ if (info->skip) continue;
+ info->pos.x = pen.x;
+ info->pos.y = pen.y;
+ pen.x += info->advance.x;
+ pen.y += info->advance.y;
+ }
- // align text
+ // align lines
+ if (render_priv->state.evt_type != EVENT_HSCROLL) {
last_break = -1;
double width = 0;
for (i = 0; i <= text_info->length; ++i) { // (text_info->length + 1) is the end of the last line
@@ -1935,8 +1941,6 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event,
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);
}
// determing text bounding box