diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-03-19 12:55:55 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-03-19 12:55:55 +0100 |
commit | 62bbf0daacdd110509f8166e9a1bf162ecb23138 (patch) | |
tree | 15c75254514f47bc6c6f7c4be515a107449050c2 /src/Text.cpp | |
parent | c207201a4a5a47e4ad286ba7371e4176c8ed5056 (diff) |
Fix glitching when using fractional scaling
Diffstat (limited to 'src/Text.cpp')
-rw-r--r-- | src/Text.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Text.cpp b/src/Text.cpp index a84a824..32ba360 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -366,10 +366,10 @@ namespace QuickMedia EmojiRectangle emoji_rec = emoji_get_extents(codePoint); const float font_height_offset = -latin_font_height * 1.2f; - sf::Vector2f vertexTopLeft(glyphPos.x, glyphPos.y + font_height_offset - emoji_rec.height * get_ui_scale() * 0.5f); - sf::Vector2f vertexTopRight(glyphPos.x + emoji_rec.width * get_ui_scale(), glyphPos.y + font_height_offset - emoji_rec.height * get_ui_scale() * 0.5f); + sf::Vector2f vertexTopLeft(glyphPos.x, glyphPos.y + font_height_offset - std::floor(emoji_rec.height * get_ui_scale()) * 0.5f); + sf::Vector2f vertexTopRight(glyphPos.x + std::floor(emoji_rec.width * get_ui_scale()), glyphPos.y + font_height_offset - std::floor(emoji_rec.height * get_ui_scale()) * 0.5f); sf::Vector2f vertexBottomLeft(glyphPos.x, glyphPos.y + font_height_offset + emoji_rec.height * get_ui_scale() * 0.5f); - sf::Vector2f vertexBottomRight(glyphPos.x + emoji_rec.width * get_ui_scale(), glyphPos.y + font_height_offset + emoji_rec.height * get_ui_scale() * 0.5f); + sf::Vector2f vertexBottomRight(glyphPos.x + std::floor(emoji_rec.width * get_ui_scale()), glyphPos.y + font_height_offset + std::floor(emoji_rec.height * get_ui_scale()) * 0.5f); sf::Vector2f textureTopLeft(emoji_rec.x, emoji_rec.y); sf::Vector2f textureTopRight(emoji_rec.x + emoji_rec.width, emoji_rec.y); @@ -888,10 +888,10 @@ namespace QuickMedia if(!editable) return true; pos.y -= floor(vspace * 2.0f); - const float caret_margin = 2.0f * get_ui_scale(); + const float caret_margin = std::floor(2.0f * get_ui_scale()); - sf::RectangleShape caretRect(sf::Vector2f(2.0f * get_ui_scale(), floor(vspace - caret_margin * 2.0f))); - caretRect.setPosition(floor(pos.x + caretPosition.x), floor(pos.y + caretPosition.y + caret_margin + 4.0f * get_ui_scale())); + sf::RectangleShape caretRect(sf::Vector2f(std::floor(2.0f * get_ui_scale()), floor(vspace - caret_margin * 2.0f))); + caretRect.setPosition(floor(pos.x + caretPosition.x), floor(pos.y + caretPosition.y + caret_margin + std::floor(4.0f * get_ui_scale()))); target.draw(caretRect); return true; } |