Skip to content

Commit

Permalink
[TextServer] Fix line breaks for dropcap and resizing embedded objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruvzg committed Oct 31, 2023
1 parent 6afd320 commit 9ad55dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions modules/text_server_adv/text_server_adv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
11 changes: 5 additions & 6 deletions scene/resources/text_paragraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9ad55dc

Please sign in to comment.