Skip to content

Commit

Permalink
Fix RichTextLabel bottom margin for text clipping
Browse files Browse the repository at this point in the history
  • Loading branch information
DictyosteliumDiscoideum authored and bruvzg committed Aug 28, 2024
1 parent 40b378e commit 1f75151
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,16 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
}

int line_count = 0;
// Bottom margin for text clipping.
float v_limit = theme_cache.normal_style->get_margin(SIDE_BOTTOM);
Size2 ctrl_size = get_size();
// Draw text.
for (int line = 0; line < l.text_buf->get_line_count(); line++) {
if (line > 0) {
off.y += theme_cache.line_separation;
}

if (p_ofs.y + off.y >= ctrl_size.height) {
if (p_ofs.y + off.y >= ctrl_size.height - v_limit) {
break;
}

Expand Down Expand Up @@ -1890,10 +1892,12 @@ void RichTextLabel::_notification(int p_what) {
visible_paragraph_count = 0;
visible_line_count = 0;

// Bottom margin for text clipping.
float v_limit = theme_cache.normal_style->get_margin(SIDE_BOTTOM);
// New cache draw.
Point2 ofs = text_rect.get_position() + Vector2(0, main->lines[from_line].offset.y - vofs);
int processed_glyphs = 0;
while (ofs.y < size.height && from_line < to_line) {
while (ofs.y < size.height - v_limit && from_line < to_line) {
MutexLock lock(main->lines[from_line].text_buf->get_mutex());

visible_paragraph_count++;
Expand Down

0 comments on commit 1f75151

Please sign in to comment.