summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-08-12 03:43:46 +0200
committerGrigori Goronzy <greg@blackbox>2009-08-12 03:43:46 +0200
commit405e8b48f538aceb42bbab8104d10b7a778b26e9 (patch)
tree7ef79d1516a3b5bfa980fd58e26962ea0c98a0b6
parent1934927c0532c9493e6985a632d66ce4a945930b (diff)
downloadlibass-405e8b48f538aceb42bbab8104d10b7a778b26e9.tar.bz2
libass-405e8b48f538aceb42bbab8104d10b7a778b26e9.tar.xz
Support \q override tag
Parse \q override tag and set a new state variable to its value. The line wrapping code still needs improvements; wrap style 0/3 are not entirely correctly implemented and style 1 is not implemented.
-rw-r--r--libass/ass_render.c12
-rw-r--r--libass/ass_render.h2
2 files changed, 11 insertions, 3 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index 51ba9f8..73481b1 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -1574,6 +1574,11 @@ static char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
if (val)
render_priv->state.drawing->scale = val;
render_priv->state.drawing_mode = !!val;
+ } else if (mystrcmp(&p, "q")) {
+ int val;
+ if (!mystrtoi(&p, &val))
+ val = render_priv->track->WrapStyle;
+ render_priv->state.wrap_style = val;
}
return p;
@@ -1619,7 +1624,7 @@ static unsigned get_next_char(ASS_Renderer *render_priv, char **str)
if (*p == '\\') {
if ((*(p + 1) == 'N')
|| ((*(p + 1) == 'n')
- && (render_priv->track->WrapStyle == 2))) {
+ && (render_priv->state.wrap_style == 2))) {
p += 2;
*str = p;
return '\n';
@@ -1745,6 +1750,7 @@ static void reset_render_context(ASS_Renderer *render_priv)
render_priv->state.frx = render_priv->state.fry = 0.;
render_priv->state.frz = M_PI * render_priv->state.style->Angle / 180.;
render_priv->state.fax = render_priv->state.fay = 0.;
+ render_priv->state.wrap_style = render_priv->track->WrapStyle;
// FIXME: does not reset unsupported attributes.
}
@@ -2187,6 +2193,8 @@ static void measure_text(ASS_Renderer *render_priv)
* 2. Try moving words from the end of a line to the beginning of the next one while it reduces
* the difference in lengths between this two lines.
* The result may not be optimal, but usually is good enough.
+ *
+ * FIXME: implement style 0 and 3 correctly, add support for style 1
*/
static void
wrap_lines_smart(ASS_Renderer *render_priv, double max_text_width)
@@ -2221,7 +2229,7 @@ wrap_lines_smart(ASS_Renderer *render_priv, double max_text_width)
}
if ((len >= max_text_width)
- && (render_priv->track->WrapStyle != 2)) {
+ && (render_priv->state.wrap_style != 2)) {
break_type = 1;
break_at = last_space;
if (break_at == -1)
diff --git a/libass/ass_render.h b/libass/ass_render.h
index 182989e..6e16db9 100644
--- a/libass/ass_render.h
+++ b/libass/ass_render.h
@@ -193,7 +193,7 @@ typedef struct {
unsigned bold;
unsigned italic;
int treat_family_as_pattern;
-
+ int wrap_style;
} RenderContext;
typedef struct {