Merge pull request #56686 from timothyqiu/rtl-su-3.x

[3.x] Fix BBCode underline prevents strikethrough from rendering
This commit is contained in:
Rémi Verschelde 2022-01-11 08:51:38 +01:00 committed by GitHub
commit 0eb3b3e1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 13 deletions

View File

@ -374,7 +374,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
font_color_shadow = _find_color(text, p_font_color_shadow); font_color_shadow = _find_color(text, p_font_color_shadow);
if (_find_underline(text) || (_find_meta(text, &meta) && underline_meta)) { if (_find_underline(text) || (_find_meta(text, &meta) && underline_meta)) {
underline = true; underline = true;
} else if (_find_strikethrough(text)) { }
if (_find_strikethrough(text)) {
strikethrough = true; strikethrough = true;
} }
@ -620,24 +621,27 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} }
} }
if (underline || strikethrough) { #ifdef TOOLS_ENABLED
const float line_width = EDSCALE;
#else
const float line_width = 1.0f;
#endif
if (underline) {
Color uc = color; Color uc = color;
uc.a *= 0.5; uc.a *= 0.5;
int line_y = y + lh; const int line_y = y + lh - (line_descent - 2);
if (underline) {
line_y -= line_descent - 2;
} else {
line_y -= (line_ascent + line_descent) / 2;
}
const Point2 from = p_ofs + Point2(align_ofs + wofs, line_y); const Point2 from = p_ofs + Point2(align_ofs + wofs, line_y);
const Point2 to = from + Point2(w + (is_at_line_wrap ? 0 : align_spacing), 0); const Point2 to = from + Point2(w + (is_at_line_wrap ? 0 : align_spacing), 0);
VS::get_singleton()->canvas_item_add_line(ci, from, to, uc, line_width);
}
if (strikethrough) {
Color uc = color;
uc.a *= 0.5;
float line_width = 1.0f; const int line_y = y + lh - (line_ascent + line_descent) / 2;
#ifdef TOOLS_ENABLED const Point2 from = p_ofs + Point2(align_ofs + wofs, line_y);
line_width *= EDSCALE; const Point2 to = from + Point2(w + (is_at_line_wrap ? 0 : align_spacing), 0);
#endif
VS::get_singleton()->canvas_item_add_line(ci, from, to, uc, line_width); VS::get_singleton()->canvas_item_add_line(ci, from, to, uc, line_width);
} }
} }