lovr icon indicating copy to clipboard operation
lovr copied to clipboard

Word Wrapping Improvements

Open mcclure opened this issue 2 years ago • 3 comments

Awhile ago we had this bug, but then it got fixed.

But it is back. See the test program (or just look at the screenshots) in this PR. The test program draws a box around the wrap area of a string (the bottom line is fixed at six lines). As you can see text regularly exceeds the right line by exactly one word.

The test program assumes the patch in #484 but you can quickly make the test program work in vanilla lovr by commenting out the second and third print() calls.

mcclure avatar Sep 12 '21 17:09 mcclure

These are different issues. In #230, new words were starting past the wrap limit if there was a space straddling the wrap limit, which was not intended behavior. In the #484 screenshot, after a word goes past the wrap limit, the next word is wrapped onto the next line, which is the current intended behavior. (In addition, it looks like "downstairs" and "live" end right up against the wrap limit which would have triggered #230, so it looks like that's still fixed).

bjornbytes avatar Sep 16 '21 08:09 bjornbytes

Word wrapping probably works this way because it was simpler to implement -- you can start pasting vertices into a buffer immediately, and when you hit a space decide if you want to wrap.

While porting Font to Vulkan I'll see how easy it is to improve on this -- would need to first measure a word, then decide where to put it based on how long it is, then paste the vertices.

bjornbytes avatar Sep 16 '21 20:09 bjornbytes

This is improved on the dev branch (text is guaranteed to not go past the wrap limit).

bjornbytes avatar Aug 04 '22 21:08 bjornbytes