Skip to content

Commit

Permalink
console.lua: use the same blur amount as --osd-blur
Browse files Browse the repository at this point in the history
I have no idea why, but console's blur is smaller than in OSD messages
and stats (regardless of persistent_overlay). It's smaller regardless of
scale_with_window, or if using 0 PlayRes like stats with
persistent_overlay=yes.

With scale_with_window=yes, multiplying the blur by 2.5 seems to make it
the same. This is probably because 2.5 is 720 / 288, which are the base
height sizes scale from and the OSD's PlayResY. With
scale_with_window=no, we need to multiply by osd_h, which is always 720
with scale_with_window=yes.
  • Loading branch information
guidocella authored and Dudemanguy committed Jan 25, 2025
1 parent 51dc628 commit 04c328f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions player/lua/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -562,22 +562,29 @@ local function render()
return
end

local ass = assdraw.ass_new()

local osd_w, osd_h = get_scaled_osd_dimensions()

local x = get_margin_x()
local y = osd_h * (1 - global_margins.b) - get_margin_y()

local font = get_font()
-- Use the same blur value as the rest of the OSD. 288 is the OSD's
-- PlayResY.
local blur = mp.get_property_native('osd-blur') * osd_h / 288
local coordinate_top = math.floor(global_margins.t * osd_h + 0.5)
local clipping_coordinates = '0,' .. coordinate_top .. ',' ..
osd_w .. ',' .. osd_h
local ass = assdraw.ass_new()
local font = get_font()

local style = '{\\r' ..
(font and '\\fn' .. font or '') ..
'\\fs' .. opts.font_size ..
'\\bord' .. opts.border_size .. '\\fsp0' ..
'\\blur' .. blur ..
(selectable_items and '\\q2' or '\\q1') ..
'\\clip(' .. clipping_coordinates .. ')}'

-- Create the cursor glyph as an ASS drawing. ASS will draw the cursor
-- inline with the surrounding text, but it sets the advance to the width
-- of the drawing. So the cursor doesn't affect layout too much, make it as
Expand Down

0 comments on commit 04c328f

Please sign in to comment.