summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuri Sizov <11782833+YuriSizov@users.noreply.github.com>2023-04-11 18:25:39 +0200
committerGitHub <noreply@github.com>2023-04-11 18:25:39 +0200
commitca808c88a490368d1047a7b46d614f9d94acda67 (patch)
tree8f9a96a89cc943ec668b44294756118d585280ec
parent6a655975694655a1ec0298345afbf5fad5148a72 (diff)
parent99376eebe07f6147d4db7110bc41eb5647a31bb7 (diff)
downloadredot-engine-ca808c88a490368d1047a7b46d614f9d94acda67.tar.gz
Merge pull request #71747 from Koyper/rich_text_label_dropcap_selection_bug
Fixed RichTextLabel wrong selection offset after drop cap
-rw-r--r--scene/gui/rich_text_label.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index c1d51f8a07..c2bbae9c38 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1469,7 +1469,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);