From: wm4 Date: Sat, 29 Sep 2012 19:27:55 +0000 (+0200) Subject: Fix resetting border style with \rSTYLE X-Git-Tag: 0.10.1~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d2b7f238ec20a88d7ced4a513c6262a0b39d9ff;p=libass Fix resetting border style with \rSTYLE 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. --- diff --git a/libass/ass_parse.c b/libass/ass_parse.c index 7f1c8f0..da75d29 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -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.; diff --git a/libass/ass_render.c b/libass/ass_render.c index 98064e3..02bd111 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -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; diff --git a/libass/ass_render.h b/libass/ass_render.h index 2ee7f1e..ad72a74 100644 --- a/libass/ass_render.h +++ b/libass/ass_render.h @@ -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