From e3dc241c2fea53dc315eb514c65732a9ee5381ab Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 8 Nov 2021 01:14:49 +0000 Subject: [PATCH] Correctly handle ZWSP in WordWrapString --- Source/engine/render/text_render.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/engine/render/text_render.cpp b/Source/engine/render/text_render.cpp index a6bf03432..1061f220b 100644 --- a/Source/engine/render/text_render.cpp +++ b/Source/engine/render/text_render.cpp @@ -288,13 +288,15 @@ std::string WordWrapString(string_view text, size_t width, GameFontTables size, continue; } - uint8_t frame = codepoint & 0xFF; - uint32_t unicodeRow = codepoint >> 8; - if (unicodeRow != currentUnicodeRow || kerning == nullptr) { - kerning = LoadFontKerning(size, unicodeRow); - currentUnicodeRow = unicodeRow; + if (codepoint != ZWSP) { + uint8_t frame = codepoint & 0xFF; + uint32_t unicodeRow = codepoint >> 8; + if (unicodeRow != currentUnicodeRow || kerning == nullptr) { + kerning = LoadFontKerning(size, unicodeRow); + currentUnicodeRow = unicodeRow; + } + lineWidth += (*kerning)[frame] + spacing; } - lineWidth += (*kerning)[frame] + spacing; const bool isWhitespace = IsWhitespace(codepoint); if (isWhitespace || IsBreakAllowed(codepoint, nextCodepoint)) {