Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Track buttons/numbers don't have enough padding with double digit track numbers #9

Open
0xMOPI opened this issue May 31, 2022 · 3 comments

Comments

@0xMOPI
Copy link

0xMOPI commented May 31, 2022

The track numbers padding is insufficient when you have a double digit amount of subtitle tracks or audio tracks

image

@Zren
Copy link
Owner

Zren commented May 31, 2022

Ah thanks. I kinda knew the fit might be tight, but I never really tested a video with that many subs. Ended up downloading DBZA Ep 1 which has 25 different languages (--embed-sub --sub-lang all).

Current State:

Issue:

The OSC is drawn with LibASS, which has no TextMetrics so we can't calculate the width of the rendered text. We have to guess it.

Solutions:

@Zren
Copy link
Owner

Zren commented May 31, 2022

With:

    local trackButtonSize = tethys.trackButtonSize
    local trackIconWidth = trackButtonSize * (32/23.273)
    local trackDigitWidth = trackButtonSize * 0.4
    -- "ICON -/0"
    -- "ICON 1/1"
    -- "ICON 1/10"
    local numTrackDigits = 1
    if tracks_osc.audio ~= nil then
        numTrackDigits = math.floor(math.log(#tracks_osc.sub, 10)) + 1
    end
    local trackButtonWidth = trackIconWidth + trackDigitWidth * (1 + numTrackDigits + 1 + numTrackDigits)

With OSC scaled to 1080p, the buttons are:

  • Track 1/1 is a 143x47 button
  • Track 25/25 is a 180x47 button

The internal mpv osc units are:

[osc_tethys] trackButtonSize 32 
[osc_tethys] trackIconWidth 43.999484381042 
[osc_tethys] trackDigitWidth 12.8 
[osc_tethys] sub.numTrackDigits 2 
[osc_tethys] sub.trackButtonWidth 120.79948438104 
[osc_tethys] audio.numTrackDigits 1 
[osc_tethys] audio.trackButtonWidth 95.199484381042 

Ah, I need to add a few math.ceil().

@Zren
Copy link
Owner

Zren commented May 31, 2022

Hmm, it's already using osc_styles.smallButtonsLlabel.

local osc_styles = {
    smallButtonsLlabel = "{\\fscx105\\fscy105\\fn" .. mp.get_property("options/osd-font") .. "}",
}

    --cy_sub
    ne = new_element("cy_sub", "button")
    ne.enabled = (#tracks_osc.sub > 0)
    ne.content = function ()
        local sid = ""
        if not (get_track("sub") == 0) then
            sid = get_track("sub")
        end
        return ("\238\132\135" .. osc_styles.smallButtonsLlabel
            .. " " .. sid .. "/" .. #tracks_osc.sub)
    end

Seems that \\fscx105\\fscy105 is 105% text scale, making it slightly taller than the icon.

https://aegi.vmoe.info/docs/3.0/ASS_Tags/#index16h3

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants