sftdlib
sftdlib copied to clipboard
X position Defaults to zero when text ends in ellipsis (...)
const char *someText = "Font drawing on the top screen! Text wraps after 300 pixels... Lorem ipsum dolor sit amet, consetetur sadipscing elit.";
...
sftd_calc_bounding_box(&textWidth, &textHeight, font, 20, 300, someText);
sftd_draw_text_wrap(font, 10, 40, RGBA8(255, 255, 255, 255), 20, 300, someText);
`
Works fine, but if you end *someText = "Like this...";
X pos get's ignored and always reverts to zero
I encountered this same issue. I was able to get it working by changing line 575 of sftd.c from:
pen_x += (advance_x >> 16) * draw_scale;
to:
pen_x += (int)((advance_x >> 16) * draw_scale) % (sf2d_get_current_screen() == GFX_TOP ? 400 : 320);
I'm totally unsure if this is a proper fix, overcomplicated, or if it's needed elsewhere. It fixes the problem @SonyUSA has and the one I was having without messing up anything else, as far as I can tell.