diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/Text.cpp b/src/Text.cpp index 421de8c..e6edb6e 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -394,9 +394,10 @@ namespace QuickMedia else latin_font = FontLoader::get_font(FontLoader::FontType::LATIN); - float latin_font_height = latin_font->getGlyph(' ', characterSize, false).advance; - float hspace = latin_font_height + characterSpacing; + const float latin_font_width = latin_font->getGlyph(' ', characterSize, false).advance; + const float hspace = latin_font_width + characterSpacing; const float vspace = font_get_real_height(latin_font); + const float emoji_scale = vspace / 20.0f; const sf::Color url_color = get_current_theme().url_text_color; @@ -427,11 +428,11 @@ namespace QuickMedia int vertexStart = vertices[vertices_index].getVertexCount(); EmojiRectangle emoji_rec = emoji_get_extents(codePoint); - const float font_height_offset = std::floor(-latin_font_height * 1.2f); - 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 + std::floor(emoji_rec.width * get_ui_scale()), glyphPos.y + font_height_offset + std::floor(emoji_rec.height * get_ui_scale()) * 0.5f); + const float font_height_offset = std::floor(-vspace * 0.2f); + sf::Vector2f vertexTopLeft(glyphPos.x, glyphPos.y + font_height_offset - std::floor(emoji_rec.height * emoji_scale) * 0.5f); + sf::Vector2f vertexTopRight(glyphPos.x + std::floor(emoji_rec.width * emoji_scale), glyphPos.y + font_height_offset - std::floor(emoji_rec.height * emoji_scale) * 0.5f); + sf::Vector2f vertexBottomLeft(glyphPos.x, glyphPos.y + font_height_offset + emoji_rec.height * emoji_scale * 0.5f); + sf::Vector2f vertexBottomRight(glyphPos.x + std::floor(emoji_rec.width * emoji_scale), glyphPos.y + font_height_offset + std::floor(emoji_rec.height * emoji_scale) * 0.5f); sf::Vector2f textureTopLeft(emoji_rec.x, emoji_rec.y); sf::Vector2f textureTopRight(emoji_rec.x + emoji_rec.width, emoji_rec.y); @@ -445,7 +446,7 @@ namespace QuickMedia vertices[vertices_index].append({ vertexBottomRight, emoji_color, textureBottomRight }); vertices[vertices_index].append({ vertexTopRight, emoji_color, textureTopRight }); - glyphPos.x += std::floor(emoji_rec.width * get_ui_scale()) + characterSpacing; + glyphPos.x += std::floor(emoji_rec.width * emoji_scale) + characterSpacing; vertices_linear.push_back({vertices_index, vertexStart, 0, codePoint}); } continue; |