From c18381119e8e2cd3b6a08f932093cb1b753161a3 Mon Sep 17 00:00:00 2001 From: Eoin O'Neill Date: Sat, 28 Mar 2020 17:20:07 -0700 Subject: [PATCH] Correction to RichTextLabel Tabulation Correct backtrack assignment to prevent excessive tabulation. Worth noting that tabulation is treated differently in RichTextLabel because of custom user-asignable tab variable which creates problems with dynamic fonts specifically. (cherry picked from commit 2000e110a9d38ebe889f9d4e6cfb106cbcc58bc8) --- scene/gui/rich_text_label.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 4f3a53fbc68..2c7d9bbbcce 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -576,13 +576,14 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } else { cw = drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent) + fx_offset, fx_char, c[i + 1], fx_color); } - } else if (previously_visible) { + } else if (previously_visible && c[i] != '\t') { backtrack += font->get_char_size(fx_char, c[i + 1]).x; } p_char_count++; if (c[i] == '\t') { cw = tab_size * font->get_char_size(' ').width; + backtrack = MAX(0, backtrack - cw); } ofs += cw;