Skip to content

Commit

Permalink
various: make --osd/sub-scale-by-window options only scale upwards
Browse files Browse the repository at this point in the history
These options keep text readable whether you use a small screen near you
or a faraway large screen, but they make it unreadable in small windows,
so change them to only scale upwards, i.e. when the window height is >
720.
  • Loading branch information
guidocella committed Oct 12, 2024
1 parent 57d94ff commit 3814b15
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
14 changes: 7 additions & 7 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2425,9 +2425,9 @@ Subtitles
rendering. Use with care, or use ``--sub-font-size`` instead.

``--sub-scale-by-window=<yes|no>``
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
size won't change the subtitle font size.
Whether to scale subtitles with the window height when it is taller than 720
pixels (default: yes). If this is disabled while ``--sub-scale-with-window``
is set to yes, changing the window size won't change the subtitle font size.

Affects plain text subtitles only (or ASS if ``--sub-ass-override`` is set
high enough).
Expand Down Expand Up @@ -4585,10 +4585,10 @@ OSD
OSD font size multiplier, multiplied with ``--osd-font-size`` value.

``--osd-scale-by-window=<yes|no>``
Whether to scale the OSD with the window size (default: yes). If this is
disabled, ``--osd-font-size`` and other OSD options that use scaled pixels
are always in actual pixels. The effect is that changing the window size
won't change the OSD font size.
Whether to scale the OSD with the window height when it is taller than 720
pixels (default: yes). If this is disabled, ``--osd-font-size`` and other
OSD options that use scaled pixels are always in actual pixels. The effect
is that changing the window size won't change the OSD font size.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Configurable Options
``vidscale``
Default: auto

Scale the OSC with the video.
Scale the OSC with the window height when it is taller than 720 pixels.
``no`` tries to keep the OSC size constant as much as the window size allows.
``auto`` scales the OSC with the OSD, which is scaled with the window or kept at a
constant size, depending on the ``--osd-scale-by-window`` option.
Expand Down
3 changes: 2 additions & 1 deletion DOCS/man/stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ Configurable Options
``vidscale``
Default: auto

Scale the text and graphs with the video.
Scale the text and graphs with the window height when it is taller than 720
pixels.
``no`` tries to keep the sizes constant.
``auto`` scales the text and graphs with the OSD, which is scaled with the
window or kept at a constant size, depending on the ``--osd-scale-by-window`` option.
Expand Down
4 changes: 3 additions & 1 deletion player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,9 @@ local function osc_init()
end

local scale_with_video
if user_opts.vidscale == "auto" then
if display_h <= 720 then
scale_with_video = false
elseif user_opts.vidscale == "auto" then
scale_with_video = mp.get_property_native("osd-scale-by-window")
else
scale_with_video = user_opts.vidscale == "yes"
Expand Down
4 changes: 3 additions & 1 deletion player/lua/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,9 @@ end

local function update_scale(osd_height)
local scale_with_video
if o.vidscale == "auto" then
if osd_height <= 720 then
scale_with_video = false
elseif o.vidscale == "auto" then
scale_with_video = mp.get_property_native("osd-scale-by-window")
else
scale_with_video = o.vidscale == "yes"
Expand Down
2 changes: 1 addition & 1 deletion sub/osd_libass.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static ASS_Style *prepare_osd_ass(struct osd_state *osd, struct osd_object *obj)

double playresy = obj->ass.track->PlayResY;
// Compensate for libass and mp_ass_set_style scaling the font etc.
if (!opts->osd_scale_by_window)
if (!opts->osd_scale_by_window || obj->vo_res.h < 720)
playresy *= 720.0 / obj->vo_res.h;

ASS_Style *style = get_style(&obj->ass, "OSD");
Expand Down
2 changes: 1 addition & 1 deletion sub/sd_ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
if (converted || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_FORCE) {
set_scale_with_window = opts->sub_scale_with_window;
set_use_margins = opts->sub_use_margins;
set_scale_by_window = opts->sub_scale_by_window;
set_scale_by_window = opts->sub_scale_by_window && dim->h > 720;
total_override = true;
} else {
set_scale_with_window = opts->ass_scale_with_window;
Expand Down

0 comments on commit 3814b15

Please sign in to comment.