From d638a6092bd6291c983490ba3f966162c7ca06c2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 31 Oct 2020 09:46:32 +0100 Subject: Load fonts on demand --- src/Body.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/Body.cpp') diff --git a/src/Body.cpp b/src/Body.cpp index 3f5c755..06907c8 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -1,6 +1,7 @@ #include "../include/Body.hpp" #include "../include/QuickMedia.hpp" #include "../include/Scale.hpp" +#include "../include/FontLoader.hpp" #include "../plugins/Plugin.hpp" #include #include @@ -79,13 +80,10 @@ namespace QuickMedia { return *this; } - Body::Body(Program *program, sf::Font *font, sf::Font *bold_font, sf::Font *cjk_font, sf::Texture &loading_icon_texture) : - font(font), - bold_font(bold_font), - cjk_font(cjk_font), - progress_text("", *font, 14), - replies_text("", *font, 14), - embedded_item_load_text("", *font, 14), + Body::Body(Program *program, sf::Texture &loading_icon_texture) : + progress_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), 14), + replies_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), 14), + embedded_item_load_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), 14), draw_thumbnails(true), wrap_around(false), line_separator_color(sf::Color(32, 37, 43, 255)), @@ -475,7 +473,7 @@ namespace QuickMedia { if(body_item->title_text) body_item->title_text->setString(std::move(str)); else - body_item->title_text = std::make_unique(std::move(str), font, cjk_font, 16, width - 50 - image_padding_x * 2.0f); + body_item->title_text = std::make_unique(std::move(str), false, 16, width - 50 - image_padding_x * 2.0f); body_item->title_text->setFillColor(body_item->get_title_color()); body_item->title_text->updateGeometry(); } @@ -486,7 +484,7 @@ namespace QuickMedia { if(body_item->description_text) body_item->description_text->setString(std::move(str)); else - body_item->description_text = std::make_unique(std::move(str), font, cjk_font, 14, width - 50 - image_padding_x * 2.0f); + body_item->description_text = std::make_unique(std::move(str), false, 14, width - 50 - image_padding_x * 2.0f); body_item->description_text->setFillColor(body_item->get_description_color()); body_item->description_text->updateGeometry(); } @@ -497,7 +495,7 @@ namespace QuickMedia { if(body_item->author_text) body_item->author_text->setString(std::move(str)); else - body_item->author_text = std::make_unique(std::move(str), bold_font, cjk_font, 14, width - 50 - image_padding_x * 2.0f); + body_item->author_text = std::make_unique(std::move(str), true, 14, width - 50 - image_padding_x * 2.0f); body_item->author_text->setFillColor(body_item->get_author_color()); body_item->author_text->updateGeometry(); } @@ -525,7 +523,7 @@ namespace QuickMedia { if(body_item->timestamp_text) body_item->timestamp_text->setString(time_str); else - body_item->timestamp_text = std::make_unique(time_str, *font, 10); + body_item->timestamp_text = std::make_unique(time_str, *FontLoader::get_font(FontLoader::FontType::LATIN), 10); body_item->timestamp_text->setFillColor(sf::Color(185, 190, 198, 100)); } -- cgit v1.2.3