]> granicus.if.org Git - libass/commitdiff
Allow using shadow offset to adjust size of text background
authorRicardo Constantino <wiiaboo@gmail.com>
Wed, 26 Apr 2017 22:11:47 +0000 (23:11 +0100)
committerGrigori Goronzy <greg@chown.ath.cx>
Thu, 1 Jun 2017 13:03:38 +0000 (15:03 +0200)
Text background refers to the libass-only BorderStyle 4, which is
similar to 3, but isn't affected by outline/border size and doesn't
render shadow, so shadow offset can be used.

You can override the horizontal and vertical box size separately
with override tags, just like you can override the color with
shadow color.

Closes #270

libass/ass_render.c

index 046ab57e819eed19775614f3767f58325c83c597..93fc6e297e25127fabb2894301b7c5704409a9fb 100644 (file)
@@ -2402,10 +2402,14 @@ static void render_and_combine_glyphs(ASS_Renderer *render_priv,
 
 static void add_background(ASS_Renderer *render_priv, EventImages *event_images)
 {
-    int left    = event_images->left;
-    int top     = event_images->top;
-    int right   = event_images->left + event_images->width;
-    int bottom  = event_images->top  + event_images->height;
+    double size_x = render_priv->state.shadow_x > 0 ?
+                    render_priv->state.shadow_x * render_priv->border_scale : 0;
+    double size_y = render_priv->state.shadow_y > 0 ?
+                    render_priv->state.shadow_y * render_priv->border_scale : 0;
+    int left    = event_images->left - size_x;
+    int top     = event_images->top  - size_y;
+    int right   = event_images->left + event_images->width  + size_x;
+    int bottom  = event_images->top  + event_images->height + size_y;
     left        = FFMINMAX(left,   0, render_priv->width);
     top         = FFMINMAX(top,    0, render_priv->height);
     right       = FFMINMAX(right,  0, render_priv->width);