Merge pull request #84287 from bruvzg/rtl_img_resize_and_dropcap_flow

[TextServer] Fix line breaks for dropcap and resizing embedded objects.
This commit is contained in:
Rémi Verschelde 2023-11-01 15:11:20 +01:00
commit 3d0041ff97
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 8 additions and 7 deletions

View file

@ -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;

View file

@ -307,7 +307,7 @@ float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font
Size2 img_size = img->size;
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: {

View file

@ -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.