Preload font resources

This commit is contained in:
Dan Paulat 2021-10-23 09:03:54 -05:00
parent 6ff4718ef4
commit 28ea12cbfe
7 changed files with 53 additions and 3 deletions

View file

@ -1,4 +1,5 @@
#include "main_window.hpp"
#include <scwx/qt/main/main_window.hpp>
#include <scwx/qt/manager/resource_manager.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/trivial.hpp>
@ -9,6 +10,8 @@ int main(int argc, char* argv[])
boost::log::core::get()->set_filter(boost::log::trivial::severity >=
boost::log::trivial::debug);
scwx::qt::manager::ResourceManager::PreLoad();
QApplication a(argc, argv);
scwx::qt::main::MainWindow w;
w.show();

View file

@ -0,0 +1,28 @@
#include <scwx/qt/manager/resource_manager.hpp>
#include <scwx/qt/util/font.hpp>
namespace scwx
{
namespace qt
{
namespace manager
{
namespace ResourceManager
{
static void LoadFonts();
void PreLoad()
{
LoadFonts();
}
static void LoadFonts()
{
util::Font::Create(":/res/fonts/din1451alt.ttf");
util::Font::Create(":/res/fonts/din1451alt_g.ttf");
}
} // namespace ResourceManager
} // namespace manager
} // namespace qt
} // namespace scwx

View file

@ -0,0 +1,15 @@
#pragma once
namespace scwx
{
namespace qt
{
namespace manager
{
namespace ResourceManager
{
void PreLoad();
} // namespace ResourceManager
} // namespace manager
} // namespace qt
} // namespace scwx

View file

@ -250,6 +250,7 @@ std::shared_ptr<Font> Font::Create(const std::string& resource)
auto it = fontMap_.find(resource);
if (it != fontMap_.end())
{
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Font already created";
return it->second;
}