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

Demo: Add a "Fonts" section for visibility.

This commit is contained in:
ocornut 2025-03-05 17:05:24 +01:00
parent 161e222322
commit 0b71339122
2 changed files with 11 additions and 9 deletions

View file

@ -15640,6 +15640,11 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
SeparatorText("Backend Support for Dynamic Fonts");
BeginDisabled();
CheckboxFlags("io.BackendFlags: RendererHasTextures", &GetIO().BackendFlags, ImGuiBackendFlags_RendererHasTextures);
EndDisabled();
SeparatorText("Fonts"); SeparatorText("Fonts");
Text("Read "); Text("Read ");
SameLine(0, 0); SameLine(0, 0);
@ -16548,12 +16553,11 @@ void ImGui::DebugNodeFont(ImFont* font)
} }
if (SmallButton("Set as default")) if (SmallButton("Set as default"))
GetIO().FontDefault = font; GetIO().FontDefault = font;
if (atlas->Fonts.Size > 1 && !atlas->Locked) SameLine();
{ BeginDisabled(atlas->Fonts.Size <= 1 || atlas->Locked);
SameLine(); if (SmallButton("Remove"))
if (SmallButton("Remove")) atlas->RemoveFont(font);
atlas->RemoveFont(font); EndDisabled();
}
// Display details // Display details
SetNextItemWidth(GetFontSize() * 8); SetNextItemWidth(GetFontSize() * 8);

View file

@ -1745,6 +1745,7 @@ static void DemoWindowWidgetsFonts()
{ {
ImFontAtlas* atlas = ImGui::GetIO().Fonts; ImFontAtlas* atlas = ImGui::GetIO().Fonts;
ImGui::ShowFontAtlas(atlas); ImGui::ShowFontAtlas(atlas);
// FIXME-NEWATLAS: Provide a demo to add/create a procedural font?
ImGui::TreePop(); ImGui::TreePop();
} }
} }
@ -8171,9 +8172,6 @@ void ImGui::ShowAboutWindow(bool* p_open)
// - ShowStyleEditor() // - 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. // Demo helper function to select among loaded fonts.
// Here we use the regular BeginCombo()/EndCombo() api which is the more flexible one. // Here we use the regular BeginCombo()/EndCombo() api which is the more flexible one.
void ImGui::ShowFontSelector(const char* label) void ImGui::ShowFontSelector(const char* label)