From 62bbf0daacdd110509f8166e9a1bf162ecb23138 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 19 Mar 2021 12:55:55 +0100 Subject: Fix glitching when using fractional scaling --- src/Text.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Text.cpp') 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; } -- cgit v1.2.3