From 0b71339122fabecf925a0a9fb8ca90dacaac71f9 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 5 Mar 2025 17:05:24 +0100 Subject: [PATCH] Demo: Add a "Fonts" section for visibility. --- imgui.cpp | 16 ++++++++++------ imgui_demo.cpp | 4 +--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index a8a04080c..ef311491c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -15640,6 +15640,11 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas) { ImGuiContext& g = *GImGui; + SeparatorText("Backend Support for Dynamic Fonts"); + BeginDisabled(); + CheckboxFlags("io.BackendFlags: RendererHasTextures", &GetIO().BackendFlags, ImGuiBackendFlags_RendererHasTextures); + EndDisabled(); + SeparatorText("Fonts"); Text("Read "); SameLine(0, 0); @@ -16548,12 +16553,11 @@ void ImGui::DebugNodeFont(ImFont* font) } if (SmallButton("Set as default")) GetIO().FontDefault = font; - if (atlas->Fonts.Size > 1 && !atlas->Locked) - { - SameLine(); - if (SmallButton("Remove")) - atlas->RemoveFont(font); - } + SameLine(); + BeginDisabled(atlas->Fonts.Size <= 1 || atlas->Locked); + if (SmallButton("Remove")) + atlas->RemoveFont(font); + EndDisabled(); // Display details SetNextItemWidth(GetFontSize() * 8); diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 55b09a2bf..894012903 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1745,6 +1745,7 @@ static void DemoWindowWidgetsFonts() { ImFontAtlas* atlas = ImGui::GetIO().Fonts; ImGui::ShowFontAtlas(atlas); + // FIXME-NEWATLAS: Provide a demo to add/create a procedural font? ImGui::TreePop(); } } @@ -8171,9 +8172,6 @@ void ImGui::ShowAboutWindow(bool* p_open) // - ShowStyleEditor() //----------------------------------------------------------------------------- -// Forward declare ShowFontAtlas() which isn't worth putting in public API yet -namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); } - // Demo helper function to select among loaded fonts. // Here we use the regular BeginCombo()/EndCombo() api which is the more flexible one. void ImGui::ShowFontSelector(const char* label)