aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-31 17:20:08 +0100
committerdec05eba <dec05eba@protonmail.com>2020-10-31 17:20:08 +0100
commit8461b2f7c3002d8f30a36411788074ed1ba011f3 (patch)
tree741d6afecb56ab8bf210b034f917f8cf395e6572 /src
parent71424d0fe48bf4cf62626f1e36e2e5f861cb018d (diff)
Do not load fonts that are not used in Text)
Diffstat (limited to 'src')
-rw-r--r--src/Text.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Text.cpp b/src/Text.cpp
index 9650964..6512c48 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -743,20 +743,25 @@ namespace QuickMedia
sf::Vector2f pos = position;
- sf::Font *latin_font;
+ FontLoader::FontType latin_font_type;
if(bold_font)
- latin_font = FontLoader::get_font(FontLoader::FontType::LATIN_BOLD);
+ latin_font_type = FontLoader::FontType::LATIN_BOLD;
else
- latin_font = FontLoader::get_font(FontLoader::FontType::LATIN);
+ latin_font_type = FontLoader::FontType::LATIN;
+ sf::Font *latin_font = FontLoader::get_font(latin_font_type);
const float vspace = latin_font->getLineSpacing(characterSize);
pos.y += floor(vspace); // Origin is at bottom left, we want it to be at top left
- const sf::Font *fonts[] = { latin_font, FontLoader::get_font(FontLoader::FontType::CJK) };
+ const FontLoader::FontType font_types[] = { latin_font_type, FontLoader::FontType::CJK };
for(size_t i = 0; i < 2; ++i) {
+ if(vertices[i].getVertexCount() == 0)
+ continue;
+
+ sf::Font *font = FontLoader::get_font(font_types[i]);
sf::RenderStates states;
states.transform.translate(pos);
- states.texture = &fonts[i]->getTexture(characterSize);
+ states.texture = &font->getTexture(characterSize);
target.draw(vertices[i], states);
}