From 015399f6967c683eb27265f81c4e93a61bc1b389 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 5 Jun 2014 00:25:24 +0200 Subject: sub: add --ass-style-override=force option (The old "force" choice of that option is renamed to "force-default".) This allows overriding native ASS script subtitle styles with the style provided by the --sub-text-* options (like --sub-text-font etc.). This is disabled by default, and needs to be explicitly enabled with the --ass-style-override=force option and input property. This uses in fact exactly the same options (--sub-text-*) and semantics as the ones used to configure unstyled text subtitles. It's recommended to combine this with this in the mpv config file: ass-force-style="ScaledBorderAndShadow=1" # work around dumb libass behavior Also, adding a key binding to toggle this behavior should be added, because overriding can easily break: L cycle ass-style-override This would cycle override behavior on Shift+L and allows quickly disabling/enabling style overrides. Note: ASS should be considered a vector format rather than a subtitle format. There is no easy or reliable way to determine whether the style of a given subtitle event can be changed without destroying visuals or not. This patch relies on a simple heuristic, which often works and often breaks. --- sub/ass_mp.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sub') diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 9ff8b03ede..d417912826 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -139,6 +139,7 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, float set_line_spacing = 0; float set_font_scale = 1; int set_hinting = 0; + int set_force_override = 0; if (opts->ass_style_override) { set_use_margins = opts->ass_use_margins; #if LIBASS_VERSION >= 0x01010000 @@ -147,6 +148,7 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, set_line_spacing = opts->ass_line_spacing; set_font_scale = opts->sub_scale; set_hinting = opts->ass_hinting; + set_force_override = opts->ass_style_override == 3; } ass_set_use_margins(priv, set_use_margins); @@ -155,6 +157,13 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, #endif #if LIBASS_VERSION >= 0x01000000 ass_set_shaper(priv, opts->ass_shaper); +#endif +#if LIBASS_VERSION >= 0x01103000 + ass_set_selective_style_override_enabled(priv, set_force_override); + ASS_Style style = {0}; + mp_ass_set_style(&style, 288, opts->sub_text_style); + ass_set_selective_style_override(priv, &style); + free(style.FontName); #endif ass_set_font_scale(priv, set_font_scale); ass_set_hinting(priv, set_hinting); -- cgit v1.2.3