Merge pull request #29785 from eligt/fix-richtext-alignment
Fix RichTextLabel alignment tags not working properly
This commit is contained in:
commit
0a3c21d999
@ -307,6 +307,13 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
|
|||||||
|
|
||||||
switch (it->type) {
|
switch (it->type) {
|
||||||
|
|
||||||
|
case ITEM_ALIGN: {
|
||||||
|
|
||||||
|
ItemAlign *align_it = static_cast<ItemAlign *>(it);
|
||||||
|
|
||||||
|
align = align_it->align;
|
||||||
|
|
||||||
|
} break;
|
||||||
case ITEM_TEXT: {
|
case ITEM_TEXT: {
|
||||||
|
|
||||||
ItemText *text = static_cast<ItemText *>(it);
|
ItemText *text = static_cast<ItemText *>(it);
|
||||||
@ -1411,10 +1418,14 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline)
|
|||||||
if (p_enter)
|
if (p_enter)
|
||||||
current = p_item;
|
current = p_item;
|
||||||
|
|
||||||
if (p_ensure_newline && current_frame->lines[current_frame->lines.size() - 1].from) {
|
if (p_ensure_newline) {
|
||||||
|
Item *from = current_frame->lines[current_frame->lines.size() - 1].from;
|
||||||
|
// only create a new line for Item types that generate content/layout, ignore those that represent formatting/styling
|
||||||
|
if (from && from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH) {
|
||||||
_invalidate_current_line(current_frame);
|
_invalidate_current_line(current_frame);
|
||||||
current_frame->lines.resize(current_frame->lines.size() + 1);
|
current_frame->lines.resize(current_frame->lines.size() + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (current_frame->lines[current_frame->lines.size() - 1].from == NULL) {
|
if (current_frame->lines[current_frame->lines.size() - 1].from == NULL) {
|
||||||
current_frame->lines.write[current_frame->lines.size() - 1].from = p_item;
|
current_frame->lines.write[current_frame->lines.size() - 1].from = p_item;
|
||||||
|
Loading…
Reference in New Issue
Block a user