Two functions calculates text-layout/shaping and returns its width.
-
playdate->graphics->getTextWidth
-
playdate->graphics->drawText
And they return different results. Why? I suppose that it's a bug.
Os: macOS 14.x on M1.
SDK: reproducible with 2.7.2-2.7.3-beta.2 and maybe earlier
Steps to reproduce
Pre: do not set font, tracking and any other options, just "clean 'n' cold setup".
-
get current text-tracking via
playdate->graphics->getTextTracking
(it's zero) -
call
playdate->graphics->getTextWidth(NULL, {STR}, {STRLEN}, kUTF8Encoding, 0 /* tracking from prev step */ )
, where{STR}
,{STRLEN}
is:
-
"你好"
,2
-
"Dobrý den"
,9
-
"Hello \xf0\x90\x80World"
,14
- call
playdate->graphics->drawText({STR}, {STRLEN}, kUTF8Encoding, 0, 0)
and compare results with prev step
Inconsistent results:
-
32 != 21
for"你好"
inkUTF8Encoding
-
83 != 3
for"Dobrý den"
inkUTF8Encoding
-
37 != 32
for"Hello \xf0\x90\x80World"
inkUTF8Encoding
I know that
"Hello \xf0\x90\x80World"
is not valid UTF8, but that is not cancels the calculation method inconsistency and this bug.