VirtualKeyboard: scale icons to fit font height (#4069)

The 4 keys that use images could be too big or too small
depending on screen size and DPI. They are now scaled in
all cases to fit font height.
This commit is contained in:
poire-z
2018-07-11 17:24:37 +02:00
committed by GitHub
parent 7eb2a32c5e
commit 665cb37308

View File

@@ -60,8 +60,14 @@ function VirtualKey:init()
local label_widget
if self.icon then
-- Scale icon to fit other characters height
-- (use *1.5 as our icons have a bit of white padding)
local icon_height = math.ceil(self.face.size * 1.5)
label_widget = ImageWidget:new{
file = self.icon,
scale_factor = 0, -- keep icon aspect ratio
height = icon_height,
width = icon_height * 100, -- to fit height when ensuring a/r
}
else
label_widget = TextWidget:new{