sftdlib icon indicating copy to clipboard operation
sftdlib copied to clipboard

Font wrap has unintended behaviour

Open videah opened this issue 9 years ago • 6 comments

sftd_draw_text_wrap doesn't seem to take x coord into account if it is wrapping, it is always 0

videah avatar Oct 02 '15 18:10 videah

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?

xerpi avatar Oct 03 '15 10:10 xerpi

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

uschmann avatar Oct 03 '15 11:10 uschmann

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.

videah avatar Oct 03 '15 13:10 videah

I guess I'll have to rewrite the wrap function, and I'll add a text_clip function too.

xerpi avatar Oct 04 '15 15:10 xerpi

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.

videah avatar Oct 13 '15 01:10 videah

Cool, thanks for discovering where the problem is! I'll try to fix it asap.

xerpi avatar Oct 13 '15 07:10 xerpi