Fix text wrapping regression

This commit is contained in:
Wojtek Figat
2023-04-29 13:05:06 +02:00
parent 3136079ca3
commit b89d32ce2b

View File

@@ -201,25 +201,29 @@ void Font::ProcessText(const StringView& text, Array<FontLineCache>& outputLines
moveLine = true; moveLine = true;
if (lastWhitespaceIndex != INVALID_INDEX) if (lastWhitespaceIndex != INVALID_INDEX)
{ {
// Back
cursorX = lastWhitespaceX; cursorX = lastWhitespaceX;
tmpLine.LastCharIndex = lastWhitespaceIndex - 1; tmpLine.LastCharIndex = lastWhitespaceIndex - 1;
currentIndex = lastWhitespaceIndex + 1; nextCharIndex = currentIndex = lastWhitespaceIndex + 1;
nextCharIndex = currentIndex;
} }
else if (lastUpperIndex != INVALID_INDEX) else if (lastUpperIndex != INVALID_INDEX)
{ {
// Skip moving twice for the same character
if (outputLines.HasItems() && outputLines.Last().LastCharIndex == lastUpperIndex - 1)
{
currentIndex = nextCharIndex;
lastMoveLine = moveLine;
continue;
}
cursorX = lastUpperX; cursorX = lastUpperX;
tmpLine.LastCharIndex = lastUpperIndex - 1; tmpLine.LastCharIndex = lastUpperIndex - 1;
currentIndex = lastUpperIndex + 1; nextCharIndex = currentIndex = lastUpperIndex;
nextCharIndex = currentIndex;
} }
else if (lastUnderscoreIndex != INVALID_INDEX) else if (lastUnderscoreIndex != INVALID_INDEX)
{ {
cursorX = lastUnderscoreX; cursorX = lastUnderscoreX;
tmpLine.LastCharIndex = lastUnderscoreIndex; tmpLine.LastCharIndex = lastUnderscoreIndex - 2;
currentIndex = lastUnderscoreIndex + 1; nextCharIndex = currentIndex = lastUnderscoreIndex + 1;
nextCharIndex = currentIndex;
} }
else else
{ {