Fix a discrepancy between lovrRasterizerMeasure and lovrFontRender wrapping

This commit is contained in:
Patrik Sjöberg 2022-03-11 20:41:04 +01:00 committed by Bjorn
parent b22dbd8f0c
commit 2c55d05be6
1 changed files with 5 additions and 3 deletions

View File

@ -197,13 +197,15 @@ void lovrRasterizerMeasure(Rasterizer* rasterizer, const char* str, size_t lengt
*glyphCount = 0;
while ((bytes = utf8_decode(str, end, &codepoint)) > 0) {
if (codepoint == '\n' || (wrap && x > wrap && codepoint == ' ')) {
if (codepoint == '\n' || (wrap && x > wrap && (codepoint == ' ' || previous == ' '))) {
*width = MAX(*width, x);
(*lineCount)++;
x = 0.f;
previous = '\0';
str += bytes;
continue;
if (codepoint == ' ' || codepoint == '\n') {
str += bytes;
continue;
}
}
// Tabs