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/manager/resource_manager.hpp>
|
||||||
#include <scwx/qt/config/county_database.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/font.hpp>
|
||||||
#include <scwx/qt/util/texture_atlas.hpp>
|
#include <scwx/qt/util/texture_atlas.hpp>
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace qt
|
namespace qt
|
||||||
|
|
@ -32,6 +36,13 @@ static void LoadFonts()
|
||||||
{
|
{
|
||||||
util::Font::Create(":/res/fonts/din1451alt.ttf");
|
util::Font::Create(":/res/fonts/din1451alt.ttf");
|
||||||
util::Font::Create(":/res/fonts/din1451alt_g.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()
|
static void LoadTextures()
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
#include <scwx/qt/util/font.hpp>
|
#include <scwx/qt/util/font.hpp>
|
||||||
|
#include <scwx/qt/manager/settings_manager.hpp>
|
||||||
#include <scwx/qt/model/imgui_context_model.hpp>
|
#include <scwx/qt/model/imgui_context_model.hpp>
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
|
|
@ -109,9 +110,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateImGuiFont(QFile& fontFile,
|
void CreateImGuiFont(QFile& fontFile,
|
||||||
QByteArray& fontData,
|
QByteArray& fontData,
|
||||||
std::vector<size_t> fontSizes);
|
const std::vector<int64_t>& fontSizes);
|
||||||
void ParseNames(FT_Face face);
|
void ParseNames(FT_Face face);
|
||||||
|
|
||||||
const std::string resource_;
|
const std::string resource_;
|
||||||
|
|
@ -249,9 +250,9 @@ GLuint Font::GenerateTexture(gl::OpenGLFunctions& gl)
|
||||||
return p->atlas_->id;
|
return p->atlas_->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontImpl::CreateImGuiFont(QFile& fontFile,
|
void FontImpl::CreateImGuiFont(QFile& fontFile,
|
||||||
QByteArray& fontData,
|
QByteArray& fontData,
|
||||||
std::vector<size_t> fontSizes)
|
const std::vector<int64_t>& fontSizes)
|
||||||
{
|
{
|
||||||
QFileInfo fileInfo(fontFile);
|
QFileInfo fileInfo(fontFile);
|
||||||
ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas();
|
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
|
// Do not transfer ownership of font data to ImGui, makes const_cast safe
|
||||||
fontConfig.FontDataOwnedByAtlas = false;
|
fontConfig.FontDataOwnedByAtlas = false;
|
||||||
|
|
||||||
for (size_t fontSize : fontSizes)
|
for (int64_t fontSize : fontSizes)
|
||||||
{
|
{
|
||||||
const float sizePixels = static_cast<float>(fontSize);
|
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);
|
font = std::make_shared<Font>(resource);
|
||||||
QByteArray fontData = fontFile.readAll();
|
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);
|
font->p->atlas_ = ftgl::texture_atlas_new(512, 512, 1);
|
||||||
ftgl::texture_font_t* textureFont = ftgl::texture_font_new_from_memory(
|
ftgl::texture_font_t* textureFont = ftgl::texture_font_new_from_memory(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue