summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2021-10-18 11:02:49 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2021-10-18 11:02:49 +0300
commit7c4fbc31a669c6ee92f641d2d47a71da724b7ad7 (patch)
treea8afe36290259adeb9048e3bc2c4356fb52544ec
parent523e0d80a8118c933dc2fb747874526cd72e1f92 (diff)
[TextServer] Use `round` instead of `floor` for hex code box size calculation to better match font size.
-rw-r--r--servers/text_server.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/servers/text_server.cpp b/servers/text_server.cpp
index 5087d32a7f..9b64661b0c 100644
--- a/servers/text_server.cpp
+++ b/servers/text_server.cpp
@@ -482,7 +482,7 @@ void TextServer::_bind_methods() {
Vector2 TextServer::get_hex_code_box_size(int p_size, char32_t p_index) const {
int w = ((p_index <= 0xFF) ? 1 : ((p_index <= 0xFFFF) ? 2 : 3));
int sp = MAX(0, w - 1);
- int sz = MAX(1, p_size / 15);
+ int sz = MAX(1, Math::round(p_size / 15.f));
return Vector2(4 + 3 * w + sp + 1, 15) * sz;
}
@@ -520,7 +520,7 @@ void TextServer::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_po
int w = ((p_index <= 0xFF) ? 1 : ((p_index <= 0xFFFF) ? 2 : 3));
int sp = MAX(0, w - 1);
- int sz = MAX(1, p_size / 15);
+ int sz = MAX(1, Math::round(p_size / 15.f));
Size2 size = Vector2(4 + 3 * w + sp, 15) * sz;
Point2 pos = p_pos - Point2i(0, size.y * 0.85);