diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-05-07 21:18:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-07 21:18:41 +0200 |
commit | d7b85fbaa1fc438effe406c9d7f973749eb4e527 (patch) | |
tree | d76ca3eeb5681426ec48aed248df9ed0180f364d /scene/gui | |
parent | ae33cf5f458a57fbf8aa3ec0a65c94e86cd4d6f4 (diff) | |
parent | 9f1de2cfddf2f5f8f4a9d1f861a3141c052517a2 (diff) |
Merge pull request #31086 from volzhs/underline
Use underline position and thickness value in font file
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/link_button.cpp | 4 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 6 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index 3dffa06b49..098e8297ad 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -111,11 +111,11 @@ void LinkButton::_notification(int p_what) { draw_string(font, Vector2(0, font->get_ascent()), text, color); if (do_underline) { - int underline_spacing = get_theme_constant("underline_spacing"); + int underline_spacing = get_theme_constant("underline_spacing") + font->get_underline_position(); int width = font->get_string_size(text).width; int y = font->get_ascent() + underline_spacing; - draw_line(Vector2(0, y), Vector2(width, y), color); + draw_line(Vector2(0, y), Vector2(width, y), color, font->get_underline_thickness()); } } break; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 5c293cdf3c..84097eb6a1 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -600,8 +600,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & if (underline) { Color uc = color; uc.a *= 0.5; - int uy = y + lh - line_descent + 2; - float underline_width = 1.0; + int uy = y + lh - line_descent + font->get_underline_position(); + float underline_width = font->get_underline_thickness(); #ifdef TOOLS_ENABLED underline_width *= EDSCALE; #endif @@ -610,7 +610,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & Color uc = color; uc.a *= 0.5; int uy = y + lh - (line_ascent + line_descent) / 2; - float strikethrough_width = 1.0; + float strikethrough_width = font->get_underline_thickness(); #ifdef TOOLS_ENABLED strikethrough_width *= EDSCALE; #endif diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 3c10e1027c..aa518fbb7d 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1487,12 +1487,12 @@ void TextEdit::_notification(int p_what) { int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color); if (underlined) { - float line_width = 1.0; + float line_width = cache.font->get_underline_thickness(); #ifdef TOOLS_ENABLED line_width *= EDSCALE; #endif - draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, line_width), in_selection && override_selected_font_color ? cache.font_color_selected : color); + draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + cache.font->get_underline_position(), w, line_width), in_selection && override_selected_font_color ? cache.font_color_selected : color); } } else if (draw_tabs && str[j] == '\t') { int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2; |