From 8461b2f7c3002d8f30a36411788074ed1ba011f3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 31 Oct 2020 17:20:08 +0100 Subject: Do not load fonts that are not used in Text) --- src/Text.cpp | 15 ++++++++++----- 1 file 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); } -- cgit v1.2.3