sftdlib
sftdlib copied to clipboard
Font wrap has unintended behaviour
sftd_draw_text_wrap
doesn't seem to take x coord into account if it is wrapping, it is always 0
Which kind of wrapping do you expect? I think sftd_draw_text_wrap doesn't do what you are expecting nor what I want it to do. I think the I'll have to change the funcion. My idea of texture wrap is to pass a rectangle (x,y, w, h) and draw text only inside this rectangle. Is this what you want?
I think it should behave like in an HTML Paragraph. It makes a linebreak based in the length of each word. So actually you define the width of the Text and it makes sure that the Text will not exceed the given width. All Text wozld still be drawn in the screen.
What you described sounds like hiding the overflowing Text comepletely
It works how I'm expecting it ... When it works. I'm finding it very hard to reproduce, but at times the texts starting point is 0 on the x coord, rather than what it's set at.
So for example:
sftd_draw_text_wrap(font, 10, 40, RGBA8(255, 255, 255, 255), 50, 100, "New line after every 100px.");
This should start drawing at 50, then after 100 pixels wrap the text. But on random occasions, when the text wraps, the text starts drawing at 0 rather than 50.
I guess I'll have to rewrite the wrap function, and I'll add a text_clip function too.
I found the source of the problem. The amount of pixels for the text to wrap is relative to the screen, rather than the texts position. A quick fix to this is to just add the x coordinate to the limit, but I imagine you would want to fix that in the lib.
Cool, thanks for discovering where the problem is! I'll try to fix it asap.