Skip to content

Commit d34c1f7

Browse files
committed
[RTL] Fix dropcaps and list prefixes not taking visible characters into account.
1 parent 6c57928 commit d34c1f7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scene/gui/rich_text_label.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,10 +835,13 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
835835
// Draw dropcap.
836836
int dc_lines = l.text_buf->get_dropcap_lines();
837837
float h_off = l.text_buf->get_dropcap_size().x;
838-
if (l.dc_ol_size > 0) {
839-
l.text_buf->draw_dropcap_outline(ci, p_ofs + ((rtl) ? Vector2() : Vector2(l.offset.x, 0)), l.dc_ol_size, l.dc_ol_color);
838+
bool skip_dc = (trim_chars && l.char_offset > visible_characters) || (trim_glyphs_ltr && (r_processed_glyphs >= visible_glyphs)) || (trim_glyphs_rtl && (r_processed_glyphs < total_glyphs - visible_glyphs));
839+
if (!skip_dc) {
840+
if (l.dc_ol_size > 0) {
841+
l.text_buf->draw_dropcap_outline(ci, p_ofs + ((rtl) ? Vector2() : Vector2(l.offset.x, 0)), l.dc_ol_size, l.dc_ol_color);
842+
}
843+
l.text_buf->draw_dropcap(ci, p_ofs + ((rtl) ? Vector2() : Vector2(l.offset.x, 0)), l.dc_color);
840844
}
841-
l.text_buf->draw_dropcap(ci, p_ofs + ((rtl) ? Vector2() : Vector2(l.offset.x, 0)), l.dc_color);
842845

843846
int line_count = 0;
844847
Size2 ctrl_size = get_size();
@@ -894,7 +897,8 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
894897
} break;
895898
}
896899

897-
if (!prefix.is_empty() && line == 0) {
900+
bool skip_prefix = (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING && l.char_offset == visible_characters) || (trim_chars && l.char_offset > visible_characters) || (trim_glyphs_ltr && (r_processed_glyphs >= visible_glyphs)) || (trim_glyphs_rtl && (r_processed_glyphs < total_glyphs - visible_glyphs));
901+
if (!prefix.is_empty() && line == 0 && !skip_prefix) {
898902
Ref<Font> font = theme_cache.normal_font;
899903
int font_size = theme_cache.normal_font_size;
900904

0 commit comments

Comments
 (0)