Explorar o código

Merge pull request #71747 from Koyper/rich_text_label_dropcap_selection_bug

Fixed RichTextLabel wrong selection offset after drop cap
Yuri Sizov %!s(int64=2) %!d(string=hai) anos
pai
achega
ca808c88a4
Modificáronse 1 ficheiros con 10 adicións e 1 borrados
  1. 10 1
      scene/gui/rich_text_label.cpp

+ 10 - 1
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);