1
0
mirror of synced 2024-11-24 15:50:16 +01:00

fix: New font settings not applying correctly

This commit is contained in:
WerWolv 2023-11-24 20:01:02 +01:00
parent fb00f688a8
commit 96a3a74e08

View File

@ -185,7 +185,7 @@ namespace hex::init {
const float defaultFontSize = ImHexApi::System::DefaultFontSize * std::round(ImHexApi::System::getGlobalScale()); const float defaultFontSize = ImHexApi::System::DefaultFontSize * std::round(ImHexApi::System::getGlobalScale());
// Load custom font related settings // Load custom font related settings
if (ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font_enable", false)) { if (ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font_enable", false).get<bool>()) {
std::fs::path fontFile = ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_path", "").get<std::string>(); std::fs::path fontFile = ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_path", "").get<std::string>();
if (!fontFile.empty()) { if (!fontFile.empty()) {
if (!wolv::io::fs::exists(fontFile) || !wolv::io::fs::isRegularFile(fontFile)) { if (!wolv::io::fs::exists(fontFile) || !wolv::io::fs::isRegularFile(fontFile)) {
@ -279,14 +279,17 @@ namespace hex::init {
fonts->Clear(); fonts->Clear();
fonts->AddFontDefault(&cfg); fonts->AddFontDefault(&cfg);
} else { } else {
if (ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.bold", false)) if (ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_bold", false))
cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Bold; cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Bold;
if (ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.italic", false)) if (ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_italic", false))
cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Oblique; cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Oblique;
if (!ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.antialias", false)) if (!ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_antialias", false))
cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Monochrome | ImGuiFreeTypeBuilderFlags_MonoHinting; cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Monochrome | ImGuiFreeTypeBuilderFlags_MonoHinting;
auto font = fonts->AddFontFromFileTTF(wolv::util::toUTF8String(fontFile).c_str(), 0, &cfg, ranges.Data); auto font = fonts->AddFontFromFileTTF(wolv::util::toUTF8String(fontFile).c_str(), 0, &cfg, ranges.Data);
cfg.FontBuilderFlags = 0;
if (font == nullptr) { if (font == nullptr) {
log::warn("Failed to load custom font! Falling back to default font."); log::warn("Failed to load custom font! Falling back to default font.");