nicbarker / clay

High performance UI layout library in C.
https://nicbarker.com/clay
zlib License
1.29k stars 31 forks source link

[Bug] Fix of broken text NEWLINES wrap mode #36

Closed SogoCZE closed 1 month ago

SogoCZE commented 1 month ago

Wrap mode NEWLINES was skipped all the time because of this if condition:

// Short circuit all wrap calculations if wrap mode is none
if (textConfig->wrapMode == CLAY_TEXT_WRAP_NONE || (containerElement->dimensions.width == textElementData->preferredDimensions.width)) {

The second part of the if was always true for text with wrapping mode NEWLINES. I added another condition that skips this width check in the case of NEWLINES.

Automatic word wrapping (works fine): image

Manual line breaks (\n) before the fix: image

Manual line breaks (\n) after the fix: image