diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 1821203ee..f804bfd07 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -334,6 +334,9 @@ namespace hex { } void Window::frameBegin() { + // Run all deferred calls + TaskManager::runDeferredCalls(); + ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); @@ -353,7 +356,7 @@ namespace hex { } { - const auto &font = ImHexApi::Fonts::getFont("hex.fonts.font.default"); + auto font = ImHexApi::Fonts::getFont("hex.fonts.font.default"); if (font == nullptr) { const auto &io = ImGui::GetIO(); @@ -362,13 +365,15 @@ namespace hex { ImFontConfig cfg; cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true; cfg.SizePixels = ImHexApi::Fonts::DefaultFontSize; - io.Fonts->AddFontDefault(&cfg); + font = io.Fonts->AddFontDefault(&cfg); ImGui_ImplOpenGL3_CreateFontsTexture(); io.Fonts->ClearInputData(); io.Fonts->ClearTexData(); } else { currentFont = font->ContainerAtlas; } + + ImGui::SetCurrentFont(font); } } @@ -682,9 +687,6 @@ namespace hex { return banner->shouldClose(); }); } - - // Run all deferred calls - TaskManager::runDeferredCalls(); } void Window::frame() { diff --git a/plugins/fonts/source/library_fonts.cpp b/plugins/fonts/source/library_fonts.cpp index ab693c73b..2315eca22 100644 --- a/plugins/fonts/source/library_fonts.cpp +++ b/plugins/fonts/source/library_fonts.cpp @@ -65,7 +65,9 @@ namespace hex::fonts { return; } - loadFont(widget, name, &font, ImHexApi::System::getGlobalScale() * ImHexApi::System::getBackingScaleFactor()); + TaskManager::doLater([&name, &font, &widget] { + loadFont(widget, name, &font, ImHexApi::System::getGlobalScale() * ImHexApi::System::getBackingScaleFactor()); + }); }); loadFont(widget.getWidget(), name, &font, ImHexApi::System::getGlobalScale() * ImHexApi::System::getBackingScaleFactor());