From baecbb12fa68ddcf42e2529e288b69b8c084e04e Mon Sep 17 00:00:00 2001 From: llyyr Date: Sat, 14 Dec 2024 00:46:04 +0530 Subject: [PATCH] sub: add sub-scale-signs Allows --sub-scale to alow scale typesetting --- DOCS/interface-changes/sub-scale-signs.txt | 1 + DOCS/man/options.rst | 6 ++++++ options/options.c | 1 + options/options.h | 1 + sub/sd_ass.c | 8 +++++--- 5 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 DOCS/interface-changes/sub-scale-signs.txt diff --git a/DOCS/interface-changes/sub-scale-signs.txt b/DOCS/interface-changes/sub-scale-signs.txt new file mode 100644 index 0000000000..df8009a666 --- /dev/null +++ b/DOCS/interface-changes/sub-scale-signs.txt @@ -0,0 +1 @@ +add `--sub-scale-signs` to allow `--sub-scale` to also scale events detected to be signs by libass diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 3e26deca2a..4e932f1eff 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2447,6 +2447,12 @@ Subtitles This affects ASS subtitles as well, and may lead to incorrect subtitle rendering. Use with care, or use ``--sub-font-size`` instead. +``--sub-scale-signs=`` + When set to yes, also apply ``--sub-scale`` to typesetting (or "signs"). + When this is set to no, ``--sub-scale`` is only applied to dialogue. The + distinction between dialogue and typesetting is done on a best effort basis + and is not infallible (default: no). + ``--sub-scale-by-window=`` Whether to scale subtitles with the window size (default: yes). If this is disabled while ``--sub-scale-with-window`` is set to yes, changing the window diff --git a/options/options.c b/options/options.c index fd2088c1c3..3bb958c49a 100644 --- a/options/options.c +++ b/options/options.c @@ -298,6 +298,7 @@ const struct m_sub_options mp_subtitle_sub_opts = { {"sub-gray", OPT_BOOL(sub_gray)}, {"sub-ass", OPT_BOOL(ass_enabled), .flags = UPDATE_SUB_HARD}, {"sub-scale", OPT_FLOAT(sub_scale), M_RANGE(0, 100)}, + {"sub-scale-signs", OPT_BOOL(sub_scale_signs)}, {"sub-line-spacing", OPT_FLOAT(sub_line_spacing), M_RANGE(-1000, 1000)}, {"sub-ass-line-spacing", OPT_REPLACED("sub-line-spacing")}, {"sub-use-margins", OPT_BOOL(sub_use_margins)}, diff --git a/options/options.h b/options/options.h index 76c075aaa5..3f184c49cf 100644 --- a/options/options.h +++ b/options/options.h @@ -104,6 +104,7 @@ struct mp_subtitle_opts { bool ass_scale_with_window; struct osd_style_opts *sub_style; float sub_scale; + bool sub_scale_signs; float sub_gauss; bool sub_gray; bool ass_enabled; diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 4f9cd3eb48..2ba2af5312 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -559,13 +559,15 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim, set_force_flags |= ASS_OVERRIDE_BIT_FONT_NAME | ASS_OVERRIDE_BIT_FONT_SIZE_FIELDS | ASS_OVERRIDE_BIT_COLORS - | ASS_OVERRIDE_BIT_BORDER - | ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE; + | ASS_OVERRIDE_BIT_BORDER; + if (!opts->sub_scale_signs) + set_force_flags |= ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE; #if LIBASS_VERSION >= 0x01703020 set_force_flags |= ASS_OVERRIDE_BIT_BLUR; #endif } - if (shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE) + if (shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE && + !opts->sub_scale_signs) set_force_flags |= ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE; if (converted) set_force_flags |= ASS_OVERRIDE_BIT_ALIGNMENT; -- 2.54.0