From 61d4bf95dc5345c77b97b279011fce2c46efcaa8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 20 Dec 2024 17:17:40 +0100 Subject: [PATCH] Fonts: Allowing PushFont()/PopFont() to be called outside the imgui frame scope. (#3621) --- docs/CHANGELOG.txt | 1 + imgui.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 8ecf76cde..8a091be6a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -58,6 +58,7 @@ Other changes: yourself based on your own logic. (#8223) - Nav: Fixed an issue where Alt key would clear current active item on windows with the ImGuiWindowFlags_NoNavInputs flag. (#8231) +- Fonts: Allowing PushFont()/PopFont() to be called outside the imgui frame scope. (#3621) - Debug Tools: Debug Log: hovering 0xXXXXXXXX values in log is allowed even if a popup is blocking mouse access to the debug log window. (#5855) - Backends: Vulkan: Fixed setting VkSwapchainCreateInfoKHR::preTransform for diff --git a/imgui.cpp b/imgui.cpp index 797f968d9..f074f4fe5 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8018,7 +8018,8 @@ void ImGui::PushFont(ImFont* font) font = GetDefaultFont(); g.FontStack.push_back(font); SetCurrentFont(font); - g.CurrentWindow->DrawList->_SetTextureID(font->ContainerAtlas->TexID); + if (ImGuiWindow* window = g.CurrentWindow) + window->DrawList->_SetTextureID(font->ContainerAtlas->TexID); } void ImGui::PopFont() @@ -8032,7 +8033,8 @@ void ImGui::PopFont() g.FontStack.pop_back(); ImFont* font = g.FontStack.Size == 0 ? GetDefaultFont() : g.FontStack.back(); SetCurrentFont(font); - g.CurrentWindow->DrawList->_SetTextureID(font->ContainerAtlas->TexID); + if (ImGuiWindow* window = g.CurrentWindow) + window->DrawList->_SetTextureID(font->ContainerAtlas->TexID); } void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled)