Merge pull request #109031 from bruvzg/tab_spacing

Include `SPACING_SPACE` in tab stops calculation.
This commit is contained in:
Thaddeus Crews 2025-09-19 09:17:00 -05:00
commit 2c1ad5b07a
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
2 changed files with 9 additions and 9 deletions

View file

@ -381,7 +381,7 @@ float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font
l.text_buf->tab_align(tab_stops); l.text_buf->tab_align(tab_stops);
} else if (tab_size > 0) { // Align inline tabs. } else if (tab_size > 0) { // Align inline tabs.
Vector<float> tabs; Vector<float> 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); l.text_buf->tab_align(tabs);
} }
@ -527,7 +527,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
l.text_buf->tab_align(tab_stops); l.text_buf->tab_align(tab_stops);
} else if (tab_size > 0) { // Align inline tabs. } else if (tab_size > 0) { // Align inline tabs.
Vector<float> tabs; Vector<float> 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); l.text_buf->tab_align(tabs);
} }
@ -1837,12 +1837,12 @@ float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const V
font_size = font_size_it->font_size; font_size = font_size_it->font_size;
} }
if (rtl) { 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) { if (stop > p_click.x) {
break; break;
} }
} else { } 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) { if (stop < p_click.x) {
break; break;
} }
@ -3297,7 +3297,7 @@ int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font, int
if (font_size_it && font_size_it->font_size > 0) { if (font_size_it && font_size_it->font_size > 0) {
font_size = font_size_it->font_size; 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) { } else if (item->type == ITEM_LIST) {
Ref<Font> font = p_base_font; Ref<Font> font = p_base_font;
@ -3316,7 +3316,7 @@ int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font, int
if (font_size_it && font_size_it->font_size > 0) { if (font_size_it && font_size_it->font_size > 0) {
font_size = font_size_it->font_size; 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; item = item->parent;

View file

@ -348,7 +348,7 @@ void TextEdit::Text::invalidate_cache(int p_line, bool p_text_changed) {
// Apply tab align. // Apply tab align.
if (tab_size > 0) { if (tab_size > 0) {
Vector<float> tabs; Vector<float> 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); text_line.data_buf->tab_align(tabs);
} }
@ -394,7 +394,7 @@ void TextEdit::Text::invalidate_all_lines() {
if (tab_size_dirty) { if (tab_size_dirty) {
if (tab_size > 0) { if (tab_size > 0) {
Vector<float> tabs; Vector<float> 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); text[i].data_buf->tab_align(tabs);
} }
} }
@ -3366,7 +3366,7 @@ void TextEdit::_update_placeholder() {
if (get_tab_size() > 0) { if (get_tab_size() > 0) {
Vector<float> tabs; Vector<float> 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); placeholder_data_buf->tab_align(tabs);
} }