diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-03-13 17:26:00 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-03-13 17:26:00 +0200 |
commit | aada3953543b7a70ad4b92bbcaa35efae7bc9799 (patch) | |
tree | 8124d0c9f6a387b00819b4fe3b030dc834a0bbae | |
parent | c8fce1661da2ed02e94d3edd91fc3f31aa6888cc (diff) |
Fix text clipping on the right side.
-rw-r--r-- | scene/gui/button.cpp | 2 | ||||
-rw-r--r-- | servers/text_server.cpp | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 724714b93b..29a0681f9c 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -293,7 +293,7 @@ void Button::_notification(int p_what) { int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width; text_buf->set_width(clip_text ? text_clip : -1); - int text_width = clip_text ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x; + int text_width = MAX(1, clip_text ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x); if (_internal_margin[SIDE_LEFT] > 0) { text_clip -= _internal_margin[SIDE_LEFT] + get_theme_constant(SNAME("hseparation")); diff --git a/servers/text_server.cpp b/servers/text_server.cpp index d188076607..aaba79c049 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -1267,11 +1267,11 @@ void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_p if (p_clip_r > 0) { // Clip right / bottom. if (orientation == ORIENTATION_HORIZONTAL) { - if (ofs.x - p_pos.x > p_clip_r) { + if (ofs.x - p_pos.x + glyphs[i].advance > p_clip_r) { return; } } else { - if (ofs.y - p_pos.y > p_clip_r) { + if (ofs.y - p_pos.y + glyphs[i].advance > p_clip_r) { return; } } @@ -1362,11 +1362,11 @@ void TextServer::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vect if (p_clip_r > 0) { // Clip right / bottom. if (orientation == ORIENTATION_HORIZONTAL) { - if (ofs.x - p_pos.x > p_clip_r) { + if (ofs.x - p_pos.x + glyphs[i].advance > p_clip_r) { return; } } else { - if (ofs.y - p_pos.y > p_clip_r) { + if (ofs.y - p_pos.y + glyphs[i].advance > p_clip_r) { return; } } |