1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Fonts: Allow PushFont/NewFrame/PopFont idioms to function.

This commit is contained in:
ocornut 2025-02-03 19:15:26 +01:00
parent 842c313db2
commit 6580590226

View file

@ -8581,7 +8581,13 @@ void ImGui::UpdateFontsNewFrame()
ImFontAtlas* atlas = g.IO.Fonts;
if ((g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures) == 0)
atlas->Locked = true;
PushFont(GetDefaultFont(), GetDefaultFont()->Sources[0].SizePixels);
// We do this really unusual thing of calling *push_front()*, the reason behind that we want to support the PushFont()/NewFrame()/PopFont() idiom.
ImFontStackData font_stack_data = { ImGui::GetDefaultFont(), ImGui::GetDefaultFont()->Sources[0].SizePixels };
g.FontStack.push_front(font_stack_data);
if (g.FontStack.Size == 1)
ImGui::SetCurrentFont(font_stack_data.Font, font_stack_data.FontSize);
IM_ASSERT(g.Font->IsLoaded());
}