mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-26 12:27:30 +00:00
Demo: added basic Fonts section under main demo (same as Metrics one) for visibility.
This commit is contained in:
24
imgui.cpp
24
imgui.cpp
@@ -15491,6 +15491,18 @@ static void MetricsHelpMarker(const char* desc)
|
||||
// [DEBUG] List fonts in a font atlas and display its texture
|
||||
void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
Text("Read ");
|
||||
SameLine(0, 0);
|
||||
TextLinkOpenURL("https://www.dearimgui.com/faq/");
|
||||
SameLine(0, 0);
|
||||
Text(" for details on font loading.");
|
||||
|
||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||
Checkbox("Show font preview", &cfg->ShowFontPreview);
|
||||
|
||||
// Font list
|
||||
for (ImFont* font : atlas->Fonts)
|
||||
{
|
||||
PushID(font);
|
||||
@@ -15499,7 +15511,6 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
||||
}
|
||||
if (TreeNode("Font Atlas", "Font Atlas (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
PushStyleVar(ImGuiStyleVar_ImageBorderSize, ImMax(1.0f, g.Style.ImageBorderSize));
|
||||
ImageWithBg(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), ImVec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
PopStyleVar();
|
||||
@@ -16290,6 +16301,8 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
|
||||
// [DEBUG] Display details for a single font, called by ShowStyleEditor().
|
||||
void ImGui::DebugNodeFont(ImFont* font)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||
bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources(s)",
|
||||
font->Sources ? font->Sources[0].Name : "", font->FontSize, font->Glyphs.Size, font->SourcesCount);
|
||||
|
||||
@@ -16297,9 +16310,12 @@ void ImGui::DebugNodeFont(ImFont* font)
|
||||
if (!opened)
|
||||
Indent();
|
||||
Indent();
|
||||
PushFont(font);
|
||||
Text("The quick brown fox jumps over the lazy dog");
|
||||
PopFont();
|
||||
if (cfg->ShowFontPreview)
|
||||
{
|
||||
PushFont(font);
|
||||
Text("The quick brown fox jumps over the lazy dog");
|
||||
PopFont();
|
||||
}
|
||||
if (!opened)
|
||||
{
|
||||
Unindent();
|
||||
|
||||
Reference in New Issue
Block a user