diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml index fda45a42c8dd..94b1815dce3d 100644 --- a/doc/classes/Label.xml +++ b/doc/classes/Label.xml @@ -10,6 +10,13 @@ https://godotengine.org/asset-library/asset/515 + + + + + Returns the bounding rectangle of the character at position [param pos]. If the character is a non-visual character or [param pos] is outside the valid range, an empty [Rect2] is returned. If the character is a part of a composite grapheme, the bounding rectangle of the whole grapheme is returned. + + diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 3df0d9716020..1b1905e79363 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -668,6 +668,127 @@ void Label::_notification(int p_what) { } } +Rect2 Label::get_character_bounds(int p_pos) const { + if (dirty || font_dirty || lines_dirty) { + const_cast