From 99376eebe07f6147d4db7110bc41eb5647a31bb7 Mon Sep 17 00:00:00 2001 From: Koyper Date: Fri, 20 Jan 2023 11:07:03 -0600 Subject: [PATCH] Fixed RichTextLabel wrong selection offset after drop cap. --- scene/gui/rich_text_label.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 973b02b3a31a..18530e163fc2 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1470,7 +1470,16 @@ float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const V } } break; } - + // Adjust for dropcap. + int dc_lines = l.text_buf->get_dropcap_lines(); + float h_off = l.text_buf->get_dropcap_size().x; + if (line <= dc_lines) { + if (rtl) { + off.x -= h_off; + } else { + off.x += h_off; + } + } off.y += TS->shaped_text_get_ascent(rid); Array objects = TS->shaped_text_get_objects(rid);