Skip to content

Commit

Permalink
fix get_visible_lint_count in RichTextLabel
Browse files Browse the repository at this point in the history
  • Loading branch information
voylin committed Jan 9, 2025
1 parent 4cf0231 commit 3e333df
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 @@ -820,6 +820,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
}

int line_count = 0;
bool has_visible_chars = false;
// Bottom margin for text clipping.
float v_limit = theme_cache.normal_style->get_margin(SIDE_BOTTOM);
Size2 ctrl_size = get_size();
Expand All @@ -843,8 +844,6 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
float length = l.text_buf->get_line_size(line).x;

// Draw line.
line_count++;

if (rtl) {
off.x = p_width - l.offset.x - width;
if (!lrtl && p_frame == main) { // Skip Scrollbar.
Expand Down Expand Up @@ -1290,6 +1289,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
bool skip = (trim_chars && l.char_offset + glyphs[i].end > visible_characters) || (trim_glyphs_ltr && (processed_glyphs_step >= visible_glyphs)) || (trim_glyphs_rtl && (processed_glyphs_step < total_glyphs - visible_glyphs));
if (!skip) {
if (txt_visible) {
has_visible_chars = true;
if (step == DRAW_STEP_TEXT) {
if (frid != RID()) {
TS->font_draw_glyph(frid, ci, glyphs[i].font_size, fx_offset + char_off, gl, font_color);
Expand Down Expand Up @@ -1410,6 +1410,10 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o

r_processed_glyphs = processed_glyphs_step;
off.y += TS->shaped_text_get_descent(rid);
if (has_visible_chars) {
line_count++;
has_visible_chars = false;
}
}

return line_count;
Expand Down

0 comments on commit 3e333df

Please sign in to comment.