Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix RichTextLabel tab_size 0 causing 1px indent on lists and indents

sydist5624c4409b31
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 3eae28b7501..b5acb731a0e 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -3638,7 +3638,9 @@ int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font, int
if (font_size_it && font_size_it->font_size > 0) {
font_size = font_size_it->font_size;
}
- margin += MAX(1, tab_size * (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE)));
+ if (tab_size > 0) {
+ 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> font = p_base_font;
@@ -3657,7 +3659,9 @@ int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font, int
if (font_size_it && font_size_it->font_size > 0) {
font_size = font_size_it->font_size;
}
- margin += MAX(1, tab_size * (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE)));
+ if (tab_size > 0) {
+ margin += MAX(1, tab_size * (font->get_char_size(' ', font_size).width + font->get_spacing(TextServer::SPACING_SPACE)));
+ }
}
item = item->parent;