Skip to content

Commit

Permalink
Allow using shadow offset to adjust size of text background
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wiiaboo authored and grigorig committed Jun 1, 2017
1 parent fa01950 commit a7807b0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libass/ass_render.c
Expand Up @@ -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);
Expand Down

0 comments on commit a7807b0

Please sign in to comment.