mirror of
https://github.com/nicbarker/clay.git
synced 2026-08-03 13:49:08 +00:00
Merge 93e28a2454 into e6cc36941a
This commit is contained in:
commit
f352d954fd
1 changed files with 5 additions and 5 deletions
10
clay.h
10
clay.h
|
|
@ -2604,17 +2604,17 @@ void Clay__CalculateFinalLayout(float deltaTime, bool useStoredBoundingBoxes, bo
|
|||
}
|
||||
Clay__MeasuredWord *measuredWord = Clay__MeasuredWordArray_Get(&context->measuredWords, wordIndex);
|
||||
// Only word on the line is too large, just render it anyway
|
||||
if (lineLengthChars == 0 && lineWidth + measuredWord->width > containerElement->dimensions.width) {
|
||||
Clay__WrappedTextLineArray_Add(&context->wrappedTextLines, CLAY__INIT(Clay__WrappedTextLine) { { measuredWord->width, lineHeight }, { .length = measuredWord->length, .chars = &textElementData->text.chars[measuredWord->startOffset] } });
|
||||
if (lineLengthChars == 0 && lineWidth + measuredWord->width - containerElement->textConfig.letterSpacing > containerElement->dimensions.width) {
|
||||
Clay__WrappedTextLineArray_Add(&context->wrappedTextLines, CLAY__INIT(Clay__WrappedTextLine) { { measuredWord->width - containerElement->textConfig.letterSpacing, lineHeight }, { .length = measuredWord->length, .chars = &textElementData->text.chars[measuredWord->startOffset] } });
|
||||
textElementData->wrappedLines.length++;
|
||||
wordIndex = measuredWord->next;
|
||||
lineStartOffset = measuredWord->startOffset + measuredWord->length;
|
||||
}
|
||||
// measuredWord->length == 0 means a newline character
|
||||
else if (measuredWord->length == 0 || lineWidth + measuredWord->width > containerElement->dimensions.width) {
|
||||
else if (measuredWord->length == 0 || lineWidth + measuredWord->width - containerElement->textConfig.letterSpacing > containerElement->dimensions.width) {
|
||||
// Wrapped text lines list has overflowed, just render out the line
|
||||
bool finalCharIsSpace = textElementData->text.chars[CLAY__MAX(lineStartOffset + lineLengthChars - 1, 0)] == ' ';
|
||||
Clay__WrappedTextLineArray_Add(&context->wrappedTextLines, CLAY__INIT(Clay__WrappedTextLine) { { lineWidth + (finalCharIsSpace ? -spaceWidth : 0), lineHeight }, { .length = lineLengthChars + (finalCharIsSpace ? -1 : 0), .chars = &textElementData->text.chars[lineStartOffset] } });
|
||||
Clay__WrappedTextLineArray_Add(&context->wrappedTextLines, CLAY__INIT(Clay__WrappedTextLine) { { lineWidth + (finalCharIsSpace ? -spaceWidth : 0) - (lineLengthChars > 0 ? containerElement->textConfig.letterSpacing : 0), lineHeight }, { .length = lineLengthChars + (finalCharIsSpace ? -1 : 0), .chars = &textElementData->text.chars[lineStartOffset] } });
|
||||
textElementData->wrappedLines.length++;
|
||||
if (lineLengthChars == 0 || measuredWord->length == 0) {
|
||||
wordIndex = measuredWord->next;
|
||||
|
|
@ -2623,7 +2623,7 @@ void Clay__CalculateFinalLayout(float deltaTime, bool useStoredBoundingBoxes, bo
|
|||
lineLengthChars = 0;
|
||||
lineStartOffset = measuredWord->startOffset;
|
||||
} else {
|
||||
lineWidth += measuredWord->width + containerElement->textConfig.letterSpacing;
|
||||
lineWidth += measuredWord->width;
|
||||
lineLengthChars += measuredWord->length;
|
||||
wordIndex = measuredWord->next;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue