Using default font:
local w1, h1 = gfx.getTextSizeForMaxWidth("xxxxxxx", 100)
local w2, h2 = gfx.getTextSizeForMaxWidth("xxxxxxx", 10)
h2 should be
20, because the string cannot wrap.
getTextSizeForMaxWidth both word break by default so this is probably not a bug.
Also, I do not think the
getTextSizeForMaxWidth makes any sense to limit in the Y direction, since this function is useful for shrinking text in the X direction, while growing the Y direction. If you wish the string to truncate on a single line, then just use
font:getHeight and set that as the height in your
drawTextInRect. Having control over word break behavior would be nice though.
I haven't observed this word break in practice. the word is clipped, but the clipped letters do not wrap to the next line, and even at super narrow sizes like above, it does not continue to wrap to more than the height of 2 lines.
quick demo to see what I mean:
gfx.drawTextInRect("xxxxxxx", 0, 50, 100, 50)
gfx.drawTextInRect("xxxxxxx", 0, 100, 20, 50)
You'll see that the text in the second location is clipped, but not wrapped.
Weird, I think I managed to cause it to wrap earlier.. But now I am not sure how I did it. Pretty sure it was just this:
local gfx <const> = playdate.graphics
local w, h = gfx.getTextSizeForMaxWidth("xxxxxxx", 10)
gfx.drawTextInRect("xxxxxxx", 0, 0, w, h)
If that is the behavior, I would agree it is a bug.. I just wish I knew how I managed to get this to wrap earlier. it was clear as day down the side of my simulator!