Merge pull request #119987 from bruvzg/rtl_ll
[RTL] Fix last line height with some fallback fonts.
This commit is contained in:
1 file changed
+25
@@ -715,8 +715,10 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
||||
String txt;
|
||||
String txt_sub;
|
||||
Item *it_to = (p_line + 1 < (int)p_frame->lines.size()) ? p_frame->lines[p_line + 1].from : nullptr;
|
||||
Item *it_prev = l.from ? l.from : current;
|
||||
int remaining_characters = visible_characters - l.char_offset;
|
||||
for (Item *it = l.from; it && it != it_to; it = _get_next_item(it)) {
|
||||
it_prev = it;
|
||||
switch (it->type) {
|
||||
case ITEM_DROPCAP: {
|
||||
// Add dropcap.
|
||||
@@ -748,6 +750,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
||||
txt += "\n";
|
||||
l.char_count++;
|
||||
remaining_characters--;
|
||||
it_prev = nullptr;
|
||||
} break;
|
||||
case ITEM_TEXT: {
|
||||
ItemText *t = static_cast<ItemText *>(it);
|
||||
@@ -875,6 +878,28 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
||||
}
|
||||
}
|
||||
|
||||
// Add zero-width space to the end if line did not end with /n to ensure uniform height.
|
||||
if (it_prev) {
|
||||
Ref<Font> font = p_base_font;
|
||||
int font_size = p_base_font_size;
|
||||
|
||||
ItemFont *font_it = _find_font(it_prev);
|
||||
if (font_it) {
|
||||
if (font_it->font.is_valid()) {
|
||||
font = font_it->font;
|
||||
}
|
||||
if (font_it->font_size > 0) {
|
||||
font_size = font_it->font_size;
|
||||
}
|
||||
}
|
||||
ItemFontSize *font_size_it = _find_font_size(it_prev);
|
||||
if (font_size_it && font_size_it->font_size > 0) {
|
||||
font_size = font_size_it->font_size;
|
||||
}
|
||||
l.text_buf->add_string(String::chr(0x200B), font, font_size, String(), it_prev->rid);
|
||||
txt += "\n";
|
||||
}
|
||||
|
||||
// Apply BiDi override.
|
||||
TextServer::StructuredTextParser stt = _find_stt(l.from);
|
||||
l.text_buf->set_bidi_override(structured_text_parser(stt, st_args, txt));
|
||||
|
||||
Reference in new issue
Block a user