ui: Added custom font size setting

This commit is contained in:
WerWolv 2021-09-22 23:42:52 +02:00
parent e57481b87c
commit cd33376c07
1 changed files with 12 additions and 6 deletions

View File

@ -113,9 +113,11 @@ namespace hex::init {
std::string fontFile; std::string fontFile;
for (const auto &dir : hex::getPath(ImHexPath::Resources)) { for (const auto &dir : hex::getPath(ImHexPath::Resources)) {
fontFile = dir + "/font.ttf"; auto path = dir + "/font.ttf";
if (std::filesystem::exists(fontFile)) if (std::filesystem::exists(path)) {
fontFile = path;
break; break;
}
} }
ImVector<ImWchar> ranges; ImVector<ImWchar> ranges;
@ -146,8 +148,10 @@ namespace hex::init {
0 0
}; };
if (!std::filesystem::exists(fontFile)) {
if (fontFile.empty()) {
// Load default font // Load default font
fonts->Clear(); fonts->Clear();
cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true; cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true;
@ -156,10 +160,12 @@ namespace hex::init {
} else { } else {
// Load custom font // Load custom font
cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true; auto fontSize = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.font_size", 14);
cfg.SizePixels = 13.0f * SharedData::fontScale;
fonts->AddFontFromFileTTF(fontFile.c_str(), std::floor(14.0f * SharedData::fontScale), &cfg, ranges.Data); // Needs conversion to char for Windows cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true;
cfg.SizePixels = fontSize * SharedData::fontScale;
fonts->AddFontFromFileTTF(fontFile.c_str(), std::floor(fontSize * SharedData::fontScale), &cfg, ranges.Data); // Needs conversion to char for Windows
} }
cfg.MergeMode = true; cfg.MergeMode = true;