[InfoMessage] stop force_one_line if font is too small (#13337)
Some checks are pending
macos / macOS 13 x86-64 🔨15.2 🎯10.15 (push) Waiting to run
macos / macOS 14 ARM64 🔨15.4 🎯11.0 (push) Waiting to run

This commit is contained in:
David
2025-03-03 21:30:03 +00:00
committed by GitHub
parent 316eb87116
commit 154ec621d3

View File

@@ -189,6 +189,10 @@ function InfoMessage:init()
-- Reduce font size if the text is too long
local cur_size = frame:getSize()
if self.force_one_line and not (self._initial_orig_font and self._initial_orig_size) then
self._initial_orig_font = text_widget.face.orig_font
self._initial_orig_size = text_widget.face.orig_size
end
if cur_size and cur_size.h > max_height then
local orig_font = text_widget.face.orig_font
local orig_size = text_widget.face.orig_size
@@ -204,6 +208,12 @@ function InfoMessage:init()
break
end
end
if self.force_one_line and orig_size < 16 then
-- Do not reduce the font size any longer, at around this point, our font is too small for the max_height check to be useful
-- anymore (when icon_height), at those sizes (or lower) two lines fit inside the max_height so, simply disable it.
self.face = Font:getFace(self._initial_orig_font, self._initial_orig_size)
self.force_one_line = false
end
-- re-init this widget
self:free()
self:init()