]> granicus.if.org Git - libass/commitdiff
Fix resetting border style with \rSTYLE
authorwm4 <wm4@nowhere>
Sat, 29 Sep 2012 19:27:55 +0000 (21:27 +0200)
committerwm4 <wm4@nowhere>
Sat, 29 Sep 2012 19:27:55 +0000 (21:27 +0200)
With \rSTYLE, it is possible to change the border style within the same
subtitle event. You can do this by setting a different BorderStyle value
in the newly requested style. VSFilter handles this as expected, while
libass uses a single border style for the whole subtitle event.

This fixes libass issue #56.

libass/ass_parse.c
libass/ass_render.c
libass/ass_render.h

index 7f1c8f037023b73f7b78cc4d79b6ebe16ce9812f..da75d29d8a11c938d5fa330ceee9f2be9467f594 100644 (file)
@@ -114,8 +114,8 @@ void update_font(ASS_Renderer *render_priv)
 void calc_border(ASS_Renderer *priv, double border_x, double border_y)
 {
     if (border_x < 0 && border_y < 0) {
-        if (priv->state.style->BorderStyle == 1 ||
-            priv->state.style->BorderStyle == 3)
+        if (priv->state.border_style == 1 ||
+            priv->state.border_style == 3)
             border_x = border_y = priv->state.style->Outline;
         else
             border_x = border_y = 1.;
index 98064e323799a5d397f83122d55e96e30eccf335..02bd11165d8f59df1a8a00c23270e31c1237dda4 100644 (file)
@@ -862,6 +862,7 @@ void reset_render_context(ASS_Renderer *render_priv, ASS_Style *style)
     render_priv->state.italic = style->Italic;
     update_font(render_priv);
 
+    render_priv->state.border_style = style->BorderStyle;
     calc_border(render_priv, style->Outline, style->Outline);
     change_border(render_priv, render_priv->state.border_x, render_priv->state.border_y);
     render_priv->state.scale_x = style->ScaleX;
@@ -1038,7 +1039,7 @@ fill_glyph_hash(ASS_Renderer *priv, OutlineHashKey *outline_key,
         key->scale_y = double_to_d16(info->scale_y);
         key->outline.x = double_to_d16(info->border_x);
         key->outline.y = double_to_d16(info->border_y);
-        key->border_style = priv->state.style->BorderStyle;
+        key->border_style = info->border_style;
         key->hash = info->drawing->hash;
         key->text = info->drawing->text;
         key->pbo = info->drawing->pbo;
@@ -1057,7 +1058,7 @@ fill_glyph_hash(ASS_Renderer *priv, OutlineHashKey *outline_key,
         key->outline.x = double_to_d16(info->border_x);
         key->outline.y = double_to_d16(info->border_y);
         key->flags = info->flags;
-        key->border_style = priv->state.style->BorderStyle;
+        key->border_style = info->border_style;
     }
 }
 
@@ -1125,7 +1126,7 @@ get_outline_glyph(ASS_Renderer *priv, GlyphInfo *info)
 
         FT_Outline_Get_CBox(v.outline, &v.bbox_scaled);
 
-        if (priv->state.style->BorderStyle == 3 &&
+        if (info->border_style == 3 &&
                 (info->border_x > 0 || info->border_y > 0)) {
             FT_Vector advance;
 
@@ -1311,7 +1312,7 @@ get_bitmap_glyph(ASS_Renderer *render_priv, GlyphInfo *info)
                 &hash_val.bm_s, info->be,
                 info->blur * render_priv->border_scale,
                 key->shadow_offset,
-                render_priv->state.style->BorderStyle);
+                info->border_style);
         if (error)
             info->symbol = 0;
 
@@ -1773,6 +1774,7 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event,
         glyphs[text_info->length].shadow_y = render_priv->state.shadow_y;
         glyphs[text_info->length].scale_x= render_priv->state.scale_x;
         glyphs[text_info->length].scale_y = render_priv->state.scale_y;
+        glyphs[text_info->length].border_style = render_priv->state.border_style;
         glyphs[text_info->length].border_x= render_priv->state.border_x;
         glyphs[text_info->length].border_y = render_priv->state.border_y;
         glyphs[text_info->length].hspacing = render_priv->state.hspacing;
index 2ee7f1ec0516e791d1ca5652f55b07e649e5b794..ad72a740094bf5cf27f5ce1f0559ca02a99122d5 100644 (file)
@@ -133,6 +133,7 @@ typedef struct glyph_info {
     double frx, fry, frz;       // rotation
     double fax, fay;            // text shearing
     double scale_x, scale_y;
+    int border_style;
     double border_x, border_y;
     double hspacing;
     unsigned italic;
@@ -190,6 +191,7 @@ typedef struct {
     char have_origin;           // origin is explicitly defined; if 0, get_base_point() is used
     double scale_x, scale_y;
     double hspacing;            // distance between letters, in pixels
+    int border_style;
     double border_x;            // outline width
     double border_y;
     uint32_t c[4];              // colors(Primary, Secondary, so on) in RGBA