diff --git a/frontend/ui/widget/textwidget.lua b/frontend/ui/widget/textwidget.lua index 000a1ce7a..fd460553d 100644 --- a/frontend/ui/widget/textwidget.lua +++ b/frontend/ui/widget/textwidget.lua @@ -41,9 +41,9 @@ function TextWidget:updateSize() if not tsize then self._length = 0 else - self._length = tsize.x + self._length = math.ceil(tsize.x) end - self._height = self.face.size * 1.5 + self._height = math.ceil(self.face.size * 1.5) end function TextWidget:getSize() diff --git a/plugins/coverbrowser.koplugin/listmenu.lua b/plugins/coverbrowser.koplugin/listmenu.lua index a75b4491b..d02204f99 100644 --- a/plugins/coverbrowser.koplugin/listmenu.lua +++ b/plugins/coverbrowser.koplugin/listmenu.lua @@ -23,6 +23,7 @@ local VerticalGroup = require("ui/widget/verticalgroup") local VerticalSpan = require("ui/widget/verticalspan") local WidgetContainer = require("ui/widget/container/widgetcontainer") local lfs = require("libs/libkoreader-lfs") +local logger = require("logger") local util = require("util") local _ = require("gettext") local Screen = Device.screen @@ -541,10 +542,13 @@ function ListMenuItem:update() end function ListMenuItem:paintTo(bb, x, y) - -- We may get non-integer x or y (see mosaicmenu.lua) - -- Make them integer: - x = math.floor(x) - y = math.floor(y) + -- We used to get non-integer x or y that would cause some mess with image + -- inside FrameContainer were image would be drawn on top of the top border... + -- Fixed by having TextWidget:updateSize() math.ceil()'ing its length and height + -- But let us know if that happens again + if x ~= math.floor(x) or y ~= math.floor(y) then + logger.err("ListMenuItem:paintTo() got non-integer x/y :", x, y) + end -- Original painting InputContainer.paintTo(self, bb, x, y) diff --git a/plugins/coverbrowser.koplugin/mosaicmenu.lua b/plugins/coverbrowser.koplugin/mosaicmenu.lua index 602a25e20..efc89e1dc 100644 --- a/plugins/coverbrowser.koplugin/mosaicmenu.lua +++ b/plugins/coverbrowser.koplugin/mosaicmenu.lua @@ -21,6 +21,7 @@ local VerticalGroup = require("ui/widget/verticalgroup") local VerticalSpan = require("ui/widget/verticalspan") local WidgetContainer = require("ui/widget/container/widgetcontainer") local lfs = require("libs/libkoreader-lfs") +local logger = require("logger") local _ = require("gettext") local Screen = Device.screen local getMenuText = require("util").getMenuText @@ -543,15 +544,13 @@ function MosaicMenuItem:update() end function MosaicMenuItem:paintTo(bb, x, y) - -- We may get non-integer x or y that would cause some mess with image + -- We used to get non-integer x or y that would cause some mess with image -- inside FrameContainer were image would be drawn on top of the top border... - -- XXX We can stop having non-integer x/y by patching textwidget.lua - -- TextWidget:updateSize(): - -- self._length = math.ceil(tsize.x) - -- self._height = math.ceil(self.face.size * 1.5) - -- In the meantime, make them integer: - x = math.floor(x) - y = math.floor(y) + -- Fixed by having TextWidget:updateSize() math.ceil()'ing its length and height + -- But let us know if that happens again + if x ~= math.floor(x) or y ~= math.floor(y) then + logger.err("MosaicMenuItem:paintTo() got non-integer x/y :", x, y) + end -- Original painting InputContainer.paintTo(self, bb, x, y)