@@ -404,18 +404,22 @@ float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font
404404 table->columns [i].width = 0 ;
405405 }
406406
407+ const int available_width = p_width - theme_cache.table_h_separation * (col_count - 1 );
408+ int base_column_width = available_width / col_count;
409+
407410 for (Item *E : table->subitems ) {
408411 ERR_CONTINUE (E->type != ITEM_FRAME); // Children should all be frames.
409412 ItemFrame *frame = static_cast <ItemFrame *>(E);
413+
410414 float prev_h = 0 ;
411415 for (int i = 0 ; i < (int )frame->lines .size (); i++) {
412416 MutexLock sub_lock (frame->lines [i].text_buf ->get_mutex ());
413- int w = _find_margin (frame->lines [i].from , p_base_font, p_base_font_size) + 1 ;
417+ int w = base_column_width - frame->padding .position .x - frame->padding .size .x ;
418+ w = MAX (w, _find_margin (frame->lines [i].from , p_base_font, p_base_font_size) + 1 );
414419 prev_h = _resize_line (frame, i, p_base_font, p_base_font_size, w, prev_h);
415420 }
416421 }
417422
418- const int available_width = p_width - theme_cache.table_h_separation * (col_count - 1 );
419423 _set_table_size (table, available_width);
420424
421425 int row_idx = (table->align_to_row < 0 ) ? table->rows_baseline .size () - 1 : table->align_to_row ;
@@ -619,7 +623,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
619623 }
620624 // Compute minimum width for each cell.
621625 const int available_width = p_width - theme_cache.table_h_separation * (col_count - 1 );
622-
626+ int base_column_width = available_width / col_count;
623627 int idx = 0 ;
624628 for (Item *E : table->subitems ) {
625629 ERR_CONTINUE (E->type != ITEM_FRAME); // Children should all be frames.
@@ -643,6 +647,17 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
643647 }
644648 idx++;
645649 }
650+ for (Item *E : table->subitems ) {
651+ ERR_CONTINUE (E->type != ITEM_FRAME); // Children should all be frames.
652+ ItemFrame *frame = static_cast <ItemFrame *>(E);
653+
654+ float prev_h = 0 ;
655+ for (int i = 0 ; i < (int )frame->lines .size (); i++) {
656+ int w = base_column_width - frame->padding .position .x - frame->padding .size .x ;
657+ w = MAX (w, _find_margin (frame->lines [i].from , p_base_font, p_base_font_size) + 1 );
658+ prev_h = _resize_line (frame, i, p_base_font, p_base_font_size, w, prev_h);
659+ }
660+ }
646661
647662 _set_table_size (table, available_width);
648663
0 commit comments