diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index a628b9323db..c8ae23c5a3a 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -381,7 +381,7 @@ float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Reftab_align(tab_stops); } else if (tab_size > 0) { // Align inline tabs. Vector tabs; - tabs.push_back(tab_size * p_base_font->get_char_size(' ', p_base_font_size).width); + tabs.push_back(MAX(1, tab_size * (p_base_font->get_char_size(' ', p_base_font_size).width + p_base_font->get_spacing(TextServer::SPACING_SPACE)))); l.text_buf->tab_align(tabs); } @@ -523,7 +523,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref l.text_buf->tab_align(tab_stops); } else if (tab_size > 0) { // Align inline tabs. Vector tabs; - tabs.push_back(tab_size * p_base_font->get_char_size(' ', p_base_font_size).width); + tabs.push_back(MAX(1, tab_size * (p_base_font->get_char_size(' ', p_base_font_size).width + p_base_font->get_spacing(TextServer::SPACING_SPACE)))); l.text_buf->tab_align(tabs); } @@ -1819,12 +1819,12 @@ float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const V font_size = font_size_it->font_size; } if (rtl) { - stop += tab_size * font->get_char_size(' ', font_size).width; + stop += MAX(1, tab_size * (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE))); if (stop > p_click.x) { break; } } else { - stop -= tab_size * font->get_char_size(' ', font_size).width; + stop -= MAX(1, tab_size * (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE))); if (stop < p_click.x) { break; } @@ -3271,7 +3271,7 @@ int RichTextLabel::_find_margin(Item *p_item, const Ref &p_base_font, int if (font_size_it && font_size_it->font_size > 0) { font_size = font_size_it->font_size; } - margin += tab_size * font->get_char_size(' ', font_size).width; + margin += MAX(1, tab_size * (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE))); } else if (item->type == ITEM_LIST) { Ref font = p_base_font; @@ -3290,7 +3290,7 @@ int RichTextLabel::_find_margin(Item *p_item, const Ref &p_base_font, int if (font_size_it && font_size_it->font_size > 0) { font_size = font_size_it->font_size; } - margin += tab_size * font->get_char_size(' ', font_size).width; + margin += MAX(1, tab_size * (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE))); } item = item->parent; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 13a32cc0222..c820623b4fa 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -348,7 +348,7 @@ void TextEdit::Text::invalidate_cache(int p_line, bool p_text_changed) { // Apply tab align. if (tab_size > 0) { Vector tabs; - tabs.push_back(font->get_char_size(' ', font_size).width * tab_size); + tabs.push_back(MAX(1, (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE)) * tab_size)); text_line.data_buf->tab_align(tabs); } @@ -394,7 +394,7 @@ void TextEdit::Text::invalidate_all_lines() { if (tab_size_dirty) { if (tab_size > 0) { Vector tabs; - tabs.push_back(font->get_char_size(' ', font_size).width * tab_size); + tabs.push_back(MAX(1, (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE)) * tab_size)); text[i].data_buf->tab_align(tabs); } } @@ -3350,7 +3350,7 @@ void TextEdit::_update_placeholder() { if (get_tab_size() > 0) { Vector tabs; - tabs.push_back(theme_cache.font->get_char_size(' ', theme_cache.font_size).width * get_tab_size()); + tabs.push_back(MAX(1, (theme_cache.font->get_char_size(' ', theme_cache.font_size).width + theme_cache.font->get_spacing(TextServer::SPACING_SPACE)) * get_tab_size())); placeholder_data_buf->tab_align(tabs); }