From 9831d3ada6e9fbf3ae4894d7abacdfdb44730ef4 Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Thu, 26 Jan 2017 23:03:16 +0000 Subject: osc: box: clip with ellipsis after too much stretching --- player/lua/osc.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'player/lua') diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 13ce3ff418..bc4226abba 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -658,8 +658,15 @@ function render_elements(master_ass) end local maxchars = element.layout.button.maxchars - if not (maxchars == nil) and (#buttontext > maxchars) then + if (#buttontext > maxchars+20) then + while (#buttontext > maxchars+20) do + buttontext = buttontext:gsub(".[\128-\191]*$", "") + end + buttontext = buttontext .. "..." + end + local _, nchars2 = buttontext:gsub(".[\128-\191]*", "") + local stretch = (maxchars/#buttontext)*100 buttontext = string.format("{\\fscx%f}", (maxchars/#buttontext)*100) .. buttontext end @@ -944,7 +951,7 @@ layouts["box"] = function () lo = add_layout("title") lo.geometry = {x = posX, y = titlerowY, an = 8, w = 496, h = 12} lo.style = osc_styles.vidtitle - lo.button.maxchars = 90 + lo.button.maxchars = 80 lo = add_layout("pl_prev") lo.geometry = -- cgit v1.2.3