diff --git a/DOCS/man/stats.rst b/DOCS/man/stats.rst index 7ddf851567..58cae9a0b1 100644 --- a/DOCS/man/stats.rst +++ b/DOCS/man/stats.rst @@ -120,7 +120,7 @@ Configurable Options Clear data buffers used for drawing graphs when toggling. ``font`` - Default: sans-serif + Default: same as ``osd-font`` Font name. Should support as many font weights as possible for optimal visual experience. @@ -137,9 +137,9 @@ Configurable Options Font size used to render text. ``font_color`` - Default: FFFFFF + Default: same as ``osd-color`` - Font color. + Color of the text. ``border_size`` Default: 0.8 @@ -147,14 +147,31 @@ Configurable Options Size of border drawn around the font. ``border_color`` - Default: 262626 + Default: same as ``osd-border-color`` - Color of drawn border. + Color of the text border. + +``shadow_x_offset`` + Default: 0 + + The horizontal distance from the text to position the shadow at. + +``shadow_y_offset`` + Default: 0 + + The vertical distance from the text to position the shadow at. + +``shadow_color`` + Default: same as ``osd-shadow-color`` + + Color of the text shadow. ``alpha`` Default: 11 - Transparency for drawn text. + Transparency of text when ``font_color`` is specified, of text borders when + ``border_color`` is specified, and of text shadows when ``shadow_color`` is + specified. ``plot_bg_border_color`` Default: 0000FF diff --git a/player/lua/stats.lua b/player/lua/stats.lua index 3d093c7e2e..d07e4dc123 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -47,15 +47,15 @@ local o = { plot_color = "FFFFFF", -- Text style - font = "sans-serif", + font = "", font_mono = "monospace", -- monospaced digits are sufficient font_size = 8, - font_color = "FFFFFF", + font_color = "", border_size = 0.8, - border_color = "262626", + border_color = "", shadow_x_offset = 0.0, shadow_y_offset = 0.0, - shadow_color = "000000", + shadow_color = "", alpha = "11", -- Custom header for ASS tags to style the text output. @@ -158,13 +158,26 @@ local function text_style() if o.custom_header and o.custom_header ~= "" then return o.custom_header else - local has_shadow = mp.get_property('osd-back-color'):sub(2, 3) == '00' - return format("{\\r\\an7\\fs%d\\fn%s\\bord%f\\3c&H%s&" .. - "\\1c&H%s&\\1a&H%s&\\3a&H%s&" .. - (has_shadow and "\\4a&H%s&\\xshad%f\\yshad%f\\4c&H%s&}" or "}"), - o.font_size, o.font, o.border_size, - o.border_color, o.font_color, o.alpha, o.alpha, o.alpha, - o.shadow_x_offset, o.shadow_y_offset, o.shadow_color) + local style = "{\\r\\an7\\fs" .. o.font_size .. "\\bord" .. o.border_size + + if o.font ~= "" then + style = style .. "\\fn" .. o.font + end + + if o.font_color ~= "" then + style = style .. "\\1c&H" .. o.font_color .. "&\\1a&H" .. o.alpha .. "&" + end + + if o.border_color ~= "" then + style = style .. "\\3c&H" .. o.border_color .. "&\\3a&H" .. o.alpha .. "&" + end + + if o.shadow_color ~= "" then + style = style .. "\\4c&H" .. o.shadow_color .. "&\\4a&H" .. o.alpha .. "&" + end + + return style .. "\\xshad" .. o.shadow_x_offset .. + "\\yshad" .. o.shadow_y_offset .. "}" end end