diff --git a/doc/classes/TextParagraph.xml b/doc/classes/TextParagraph.xml
index 541078ed223..c6511a2b8e9 100644
--- a/doc/classes/TextParagraph.xml
+++ b/doc/classes/TextParagraph.xml
@@ -175,7 +175,7 @@
- Returns size of the bounding box of the line of text.
+ Returns size of the bounding box of the line of text. Returned size is rounded up.
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5ef02bf19d7..1da3668ebed 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -828,14 +828,14 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
break;
}
- const Size2 line_size = l.text_buf->get_line_size(line);
- if (p_ofs.y + off.y + line_size.y <= 0) {
- off.y += line_size.y;
+ double l_height = l.text_buf->get_line_ascent(line) + l.text_buf->get_line_descent(line);
+ if (p_ofs.y + off.y + l_height <= 0) {
+ off.y += l_height;
continue;
}
float width = l.text_buf->get_width();
- float length = line_size.x;
+ float length = l.text_buf->get_line_size(line).x;
// Draw line.
line_count++;
@@ -5139,7 +5139,7 @@ void RichTextLabel::scroll_to_selection() {
if (range.x <= selection.from_char && range.y >= selection.from_char) {
break;
}
- line_offset += selection.from_frame->lines[selection.from_line].text_buf->get_line_size(i).y + theme_cache.line_separation;
+ line_offset += selection.from_frame->lines[selection.from_line].text_buf->get_line_ascent(i) + selection.from_frame->lines[selection.from_line].text_buf->get_line_descent(i) + theme_cache.line_separation;
}
// Add nested frame (e.g. table cell) offset.
@@ -5191,7 +5191,7 @@ void RichTextLabel::scroll_to_line(int p_line) {
if ((line_count <= p_line) && (line_count + main->lines[i].text_buf->get_line_count() >= p_line)) {
float line_offset = 0.f;
for (int j = 0; j < p_line - line_count; j++) {
- line_offset += main->lines[i].text_buf->get_line_size(j).y + theme_cache.line_separation;
+ line_offset += main->lines[i].text_buf->get_line_ascent(j) + main->lines[i].text_buf->get_line_descent(j) + theme_cache.line_separation;
}
vscroll->set_value(main->lines[i].offset.y + line_offset);
return;
@@ -5211,7 +5211,7 @@ float RichTextLabel::get_line_offset(int p_line) {
if ((line_count <= p_line) && (p_line <= line_count + main->lines[i].text_buf->get_line_count())) {
float line_offset = 0.f;
for (int j = 0; j < p_line - line_count; j++) {
- line_offset += main->lines[i].text_buf->get_line_size(j).y + theme_cache.line_separation;
+ line_offset += main->lines[i].text_buf->get_line_ascent(j) + main->lines[i].text_buf->get_line_descent(j) + theme_cache.line_separation;
}
return main->lines[i].offset.y + line_offset;
}