diff --git a/internal/ui/context.go b/internal/ui/context.go index 9f1ed2439..214b9b633 100644 --- a/internal/ui/context.go +++ b/internal/ui/context.go @@ -283,7 +283,16 @@ func (c *context) layoutGame(outsideWidth, outsideHeight float64, deviceScaleFac c.outsideWidth = outsideWidth c.outsideHeight = outsideHeight - ow, oh := c.game.Layout(int(outsideWidth), int(outsideHeight)) + // Adjust the outside size to integer values. + // Even if the original value is less than 1, the value must be a positive integer (#2340). + iow, ioh := int(outsideWidth), int(outsideHeight) + if iow == 0 { + iow = 1 + } + if ioh == 0 { + ioh = 1 + } + ow, oh := c.game.Layout(iow, ioh) if ow <= 0 || oh <= 0 { panic("ui: Layout must return positive numbers") }