Menu widget: adapt font size of shrunken items (#8340)

reviewable/pr8312/r14
hius07 2 years ago committed by GitHub
parent 4ffabcf087
commit 7036500f5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -342,7 +342,7 @@ function MenuItem:init()
elseif self.multilines_show_more_text then
-- Multi-lines, with font size decrease if needed to show more of the text.
-- It would be costly/slow with use_xtext if we were to try all
-- font sizes from self.font_size to min_font_size (12).
-- font sizes from self.font_size to min_font_size.
-- So, we try to optimize the search of the best font size.
logger.dbg("multilines_show_more_text menu item font sizing start")
local function make_item_name(font_size)
@ -361,7 +361,9 @@ function MenuItem:init()
-- return true if we fit
return item_name:getSize().h <= max_item_height
end
local min_font_size = 12
-- To keep item readable, do not decrease font size by more than 8 points
-- relative to the specified font size, being not smaller than 12 absolute points.
local min_font_size = math.max(12, self.font_size - 8)
-- First, try with specified font size: short text might fit
if not make_item_name(self.font_size) then
-- It doesn't, try with min font size: very long text might not fit

Loading…
Cancel
Save