The code below will cause an infinite loop in drawTruncatedWord
within drawTextInRect
since the while loop will never be satisfied.
Note: this only occurs when drawing multiple words in a string, a single word string does not loop.
import 'CoreLibs/graphics'
function playdate.update()
playdate.graphics.drawTextInRect('Test Test', 0, 0, 1, 20)
end
A suggested fix for this would be to bail even sooner, by updating the code that checks width/height to also make sure a single character can fit in the width. This would be more efficient than letting the whole function carry on for single word strings as well as fix the bug for multi word strings.
local singleCharWidth = (singleFont and singleFont:getTextWidth("a") or g.getTextSize("a"))
if ((width < 0 or height < 0) or (singleCharWidth < width)) then
return 0, 0, false
end