Merge pull request #60233 from ZheisterCoding/leading-space-fix-3.x

Fixed leading spaces pushing text outside Label autowrap boundary problem
This commit is contained in:
Rémi Verschelde 2022-04-14 12:15:33 +02:00 committed by GitHub
commit 4e4f6311b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {