From 58b8271bf45f8cb6472fe836bc8ea7b08cc1f48b Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 26 Jul 2022 12:56:16 +0200 Subject: [PATCH] Ported: Fixed #59985 leading spaces autowrap boundary problem Bug problem: No condition for when the first character of the label is a space character Fix: Added an IF condition for when the first character is a space character The autowrap boundary treat this space character as another dummy word in the WordCache linked list and proceed to function normally, by detecting when line width is 0 - ZheisterCoding https://github.com/godotengine/godot/commit/c0513268bd1a852b7dd8566b6c999033a2eaac32 --- scene/gui/label.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 192161499..99afb74b7 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -452,7 +452,13 @@ void Label::regenerate_word_cache() { } if (i < xl_text.length() && xl_text[i] == ' ') { - if (line_width > 0 || last == nullptr || last->char_pos != WordCache::CHAR_WRAPLINE) { + if (line_width == 0) { + if (current_word_size == 0) { + word_pos = i; + } + current_word_size += space_width; + line_width += space_width; + } else if (line_width > 0 || last == nullptr || last->char_pos != WordCache::CHAR_WRAPLINE) { space_count++; line_width += space_width; } else {