xerpi / sftdlib

Simple and Fast Text Drawing library for the Nintendo 3DS
MIT License
30 stars 6 forks source link

X position Defaults to zero when text ends in ellipsis (...) #13

Open SonyUSA opened 8 years ago

SonyUSA commented 8 years ago
    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

SkaarjK commented 8 years ago

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.