mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:10:05 +00:00
Apply settings to font loading
This commit is contained in:
parent
81f1beb8d8
commit
ca044850fa
2 changed files with 23 additions and 8 deletions
|
|
@ -1,9 +1,13 @@
|
|||
#include <scwx/qt/manager/resource_manager.hpp>
|
||||
#include <scwx/qt/config/county_database.hpp>
|
||||
#include <scwx/qt/manager/settings_manager.hpp>
|
||||
#include <scwx/qt/model/imgui_context_model.hpp>
|
||||
#include <scwx/qt/util/font.hpp>
|
||||
#include <scwx/qt/util/texture_atlas.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
|
|
@ -32,6 +36,13 @@ static void LoadFonts()
|
|||
{
|
||||
util::Font::Create(":/res/fonts/din1451alt.ttf");
|
||||
util::Font::Create(":/res/fonts/din1451alt_g.ttf");
|
||||
|
||||
if (manager::SettingsManager::general_settings()->debug_enabled())
|
||||
{
|
||||
ImFontAtlas* fontAtlas =
|
||||
model::ImGuiContextModel::Instance().font_atlas();
|
||||
fontAtlas->AddFontDefault();
|
||||
}
|
||||
}
|
||||
|
||||
static void LoadTextures()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <scwx/qt/util/font.hpp>
|
||||
#include <scwx/qt/manager/settings_manager.hpp>
|
||||
#include <scwx/qt/model/imgui_context_model.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
|
|
@ -111,7 +112,7 @@ public:
|
|||
|
||||
void CreateImGuiFont(QFile& fontFile,
|
||||
QByteArray& fontData,
|
||||
std::vector<size_t> fontSizes);
|
||||
const std::vector<int64_t>& fontSizes);
|
||||
void ParseNames(FT_Face face);
|
||||
|
||||
const std::string resource_;
|
||||
|
|
@ -251,7 +252,7 @@ GLuint Font::GenerateTexture(gl::OpenGLFunctions& gl)
|
|||
|
||||
void FontImpl::CreateImGuiFont(QFile& fontFile,
|
||||
QByteArray& fontData,
|
||||
std::vector<size_t> fontSizes)
|
||||
const std::vector<int64_t>& fontSizes)
|
||||
{
|
||||
QFileInfo fileInfo(fontFile);
|
||||
ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas();
|
||||
|
|
@ -260,7 +261,7 @@ void FontImpl::CreateImGuiFont(QFile& fontFile,
|
|||
// Do not transfer ownership of font data to ImGui, makes const_cast safe
|
||||
fontConfig.FontDataOwnedByAtlas = false;
|
||||
|
||||
for (size_t fontSize : fontSizes)
|
||||
for (int64_t fontSize : fontSizes)
|
||||
{
|
||||
const float sizePixels = static_cast<float>(fontSize);
|
||||
|
||||
|
|
@ -307,7 +308,10 @@ std::shared_ptr<Font> Font::Create(const std::string& resource)
|
|||
font = std::make_shared<Font>(resource);
|
||||
QByteArray fontData = fontFile.readAll();
|
||||
|
||||
font->p->CreateImGuiFont(fontFile, fontData, {16});
|
||||
font->p->CreateImGuiFont(
|
||||
fontFile,
|
||||
fontData,
|
||||
manager::SettingsManager::general_settings()->font_sizes());
|
||||
|
||||
font->p->atlas_ = ftgl::texture_atlas_new(512, 512, 1);
|
||||
ftgl::texture_font_t* textureFont = ftgl::texture_font_new_from_memory(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue