1
0
mirror of synced 2025-02-20 12:11:04 +01:00

fix: Black screen issues when font atlas got too big

This commit is contained in:
WerWolv 2022-11-14 10:02:34 +01:00
parent 3bcfa7e10b
commit 3fccd03bbb
2 changed files with 7 additions and 8 deletions

View File

@ -83,7 +83,6 @@ namespace hex::init {
}
bool loadFonts() {
const auto scale = ImHexApi::System::getNativeScale();
float fontSize = ImHexApi::System::getFontSize();
const auto &fontFile = ImHexApi::System::getCustomFontPath();
@ -91,7 +90,7 @@ namespace hex::init {
auto fonts = IM_NEW(ImFontAtlas)();
ImFontConfig cfg = {};
cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true;
cfg.SizePixels = fontSize * scale;
cfg.SizePixels = fontSize;
ImVector<ImWchar> ranges;
{
@ -125,17 +124,17 @@ namespace hex::init {
fonts->AddFontDefault(&cfg);
} else {
// Load custom font
fonts->AddFontFromFileTTF(hex::toUTF8String(fontFile).c_str(), std::floor(fontSize * scale), &cfg, ranges.Data); // Needs conversion to char for Windows
fonts->AddFontFromFileTTF(hex::toUTF8String(fontFile).c_str(), 0, &cfg, ranges.Data); // Needs conversion to char for Windows
}
cfg.MergeMode = true;
fonts->AddFontFromMemoryCompressedTTF(font_awesome_compressed_data, font_awesome_compressed_size, fontSize * scale, &cfg, fontAwesomeRange);
fonts->AddFontFromMemoryCompressedTTF(codicons_compressed_data, codicons_compressed_size, fontSize * scale, &cfg, codiconsRange);
fonts->AddFontFromMemoryCompressedTTF(font_awesome_compressed_data, font_awesome_compressed_size, 0, &cfg, fontAwesomeRange);
fonts->AddFontFromMemoryCompressedTTF(codicons_compressed_data, codicons_compressed_size, 0, &cfg, codiconsRange);
bool enableUnicode = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.enable_unicode", true);
if (enableUnicode)
fonts->AddFontFromMemoryCompressedTTF(unifont_compressed_data, unifont_compressed_size, fontSize * scale, &cfg, unifontRange);
fonts->AddFontFromMemoryCompressedTTF(unifont_compressed_data, unifont_compressed_size, 0, &cfg, unifontRange);
fonts->Build();

View File

@ -464,7 +464,7 @@ namespace hex {
continue;
if (view->isAvailable()) {
float fontScaling = std::max(1.0F, ImHexApi::System::getFontSize() / ImHexApi::System::DefaultFontSize);
float fontScaling = std::max(1.0F, ImHexApi::System::getFontSize() / ImHexApi::System::DefaultFontSize) * ImHexApi::System::getGlobalScale();
ImGui::SetNextWindowSizeConstraints(view->getMinSize() * fontScaling, view->getMaxSize() * fontScaling);
view->drawContent();
}
@ -690,7 +690,7 @@ namespace hex {
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable | ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigWindowsMoveFromTitleBarOnly = true;
io.FontGlobalScale = 1.0F / ImHexApi::System::getNativeScale();
io.FontGlobalScale = 1.0F;
if (glfwGetPrimaryMonitor() != nullptr) {
auto sessionType = hex::getEnvironmentVariable("XDG_SESSION_TYPE");