go-text / typesetting

High quality text shaping in pure Go.
Other
88 stars 11 forks source link

shaping: fix empty string wrapping with width zero #98

Closed whereswaldon closed 11 months ago

whereswaldon commented 11 months ago

This commit ensures that we properly handle wrapping the empty string even when we have zero width to work with. It's common for application code to shape+wrap an empty string to get line metrics, and sometimes they may do that with zero width because the empty string needs no width. However, a faulty comparison in our logic for handling the empty string would fail because 0 is not less than 0. I've added tests triggering the problem and fixed the comparison logic.