From 9ad55dc32df2ae06eface1a4ebb5a37478600134 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 31 Oct 2023 09:34:43 +0200 Subject: [PATCH] [TextServer] Fix line breaks for dropcap and resizing embedded objects. --- modules/text_server_adv/text_server_adv.cpp | 2 ++ scene/gui/rich_text_label.cpp | 2 +- scene/resources/text_paragraph.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 8987a491cb61..eaab04b49a0c 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -4312,6 +4312,8 @@ bool TextServerAdvanced::_shaped_text_resize_object(const RID &p_shaped, const V sd->width += gl.advance * gl.repeat; } } + sd->sort_valid = false; + sd->glyphs_logical.clear(); _realign(sd); } return true; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 1e2f010aad8d..31ed5984a4ea 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -307,7 +307,7 @@ float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Refsize; if (img->size_in_percent) { img_size = _get_image_size(img->image, p_width * img->rq_size.width / 100.f, p_width * img->rq_size.height / 100.f, img->region); - l.text_buf->resize_object((uint64_t)it, img_size, img->inline_align, 1); + l.text_buf->resize_object((uint64_t)it, img_size, img->inline_align); } } break; case ITEM_TABLE: { diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp index 239ecb500e07..147c9044b802 100644 --- a/scene/resources/text_paragraph.cpp +++ b/scene/resources/text_paragraph.cpp @@ -175,17 +175,16 @@ void TextParagraph::_shape_lines() { for (int i = 0; i < line_breaks.size(); i = i + 2) { RID line = TS->shaped_text_substr(rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]); float h = (TS->shaped_text_get_orientation(line) == TextServer::ORIENTATION_HORIZONTAL) ? TS->shaped_text_get_size(line).y : TS->shaped_text_get_size(line).x; - if (v_offset < h) { - TS->free_rid(line); - break; - } if (!tab_stops.is_empty()) { TS->shaped_text_tab_align(line, tab_stops); } - dropcap_lines++; - v_offset -= h; start = line_breaks[i + 1]; lines_rid.push_back(line); + if (v_offset < h) { + break; + } + dropcap_lines++; + v_offset -= h; } } // Use fixed for the rest of lines.