[Fixed] Infinite loop in gfx.drawTextInRect

I'm using SDK 1.10.0 on macOS 12.3.1 (M1 CPU)

There were similar topics here Infinite loop in `drawTextInRect` with narrow widths - #3 by dwineman and graphics.drawTextInRect infinite loop when width is less than single char font width
but my case is a bit different (and it's not fixed in 1.10.0)

import "CoreLibs/graphics"
import "CoreLibs/timer"

local gfx <const> = playdate.graphics

local x <const> = 50
local y <const> = 40
local width <const> = 120
local height <const> = 22

function playdate.update()
	gfx.drawRect(x, y, width, height)
	gfx.drawTextInRect('Thisisalongtextthatdontfitthebox', x, y + 2, width, height - 2, nil, '...')
	gfx.sprite.update()
	playdate.timer.updateTimers()
end

Code above stucks in one of the while loops (graphics.lua line 412). It doesn't occur when a white character is in the middle of the long text.
In the Pocket Planner, people can enter their text. So I have limited control over what's displayed, so I hope you can fix this.

1 Like

Yes, it definitely shouldn't be doing that. Thanks for the report!

1 Like

I'm experiencing the same issue even with whitespace in my string. It appears to happen if the first word in the string is too long for the rect.
(I ran into it when screwing up my text processing and putting a long string into a rect that was sized for only 1-2 digits.)

This issue is fixed in SDK 1.12.0