Closed JBetz closed 1 month ago
Can you provide the font file you're using here?
Yup, here it is, zipped to make GitHub happy: default.zip
I've noticed that the same thing happens when I call TTF_RenderText_Blended_Wrapped
with wrapLength set to 0, so it doesn't seem to be an issue with the new text engine.
(Unless of course the old API now uses the text engine internally...
I'm not able to repro here. I'm running showfont.exe -textengine renderer default.ttf 18 foo
and it shows up just fine. Can you attach a debugger while it's hung and break to get a stack trace?
Here's what I got, though it's missing some source info for SDL_ttf
. I can try to build it with debug symbols if that's needed.
Yeah, symbols would be helpful. :)
Okay, here's the full stack trace and relevant source in SLD_ttf:
Can you step through and see why we're never leaving that loop?
It looks like left
never gets updated and stays at length 3
, but needs to be 0
to break out of the do-while loop.
As for places it could be updated, spot
is equal to text
so we don't hit this block: https://github.com/libsdl-org/SDL_ttf/blob/3adac8ac7ca3be6a5f73a23d930c9f7449f99189/src/SDL_ttf.c#L3403-L3414
Nor this one, since max_count
is always 0
, and itself is the count
return value of TTF_MeasureString
: https://github.com/libsdl-org/SDL_ttf/blob/3adac8ac7ca3be6a5f73a23d930c9f7449f99189/src/SDL_ttf.c#L3441-L3469
Why is max_count 0 if wrapLength is 0?
The measure_width
argument passed to TTF_MeasureString
is always 0
since it's always equal to wrapLength
, which AFAICT means that count
will always return 0
:
Here is a simpler reproduction of the issue:
TTF_Text text = TTF_CreateText(text_engine, font, "hello", 0); TTF_DrawRendererText(text, 0, 0);
TTF_DrawRendererText will hang trying to layout the Text object. Single line text layout is broken. I noticed that the test programs and (maybe the tests?) don't do single line text rendering, The fix should include ensuring this code path is tested.
A work around is:
TTF_CreateText_Wrapped(text_engine, font, "hello", 0, INT_MAX)
Fixed, thanks!
Some Smalltalk code to reproduce, using only direct API calls so should be easy to translate: