@@ -16147,18 +16147,24 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
1614716147// [DEBUG] Display details for a single font, called by ShowStyleEditor().
1614816148void ImGui::DebugNodeFont(ImFont* font)
1614916149{
16150- bool opened = TreeNode(font, "Font: \"%s\"\n %.2f px, %d glyphs, %d file (s)",
16150+ bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources (s)",
1615116151 font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
16152- SameLine();
16153- if (SmallButton("Set as default"))
16154- GetIO().FontDefault = font;
16155- if (!opened)
16156- return;
1615716152
1615816153 // Display preview text
16154+ if (!opened)
16155+ Indent();
16156+ Indent();
1615916157 PushFont(font);
1616016158 Text("The quick brown fox jumps over the lazy dog");
1616116159 PopFont();
16160+ if (!opened)
16161+ {
16162+ Unindent();
16163+ Unindent();
16164+ return;
16165+ }
16166+ if (SmallButton("Set as default"))
16167+ GetIO().FontDefault = font;
1616216168
1616316169 // Display details
1616416170 SetNextItemWidth(GetFontSize() * 8);
@@ -16182,57 +16188,60 @@ void ImGui::DebugNodeFont(ImFont* font)
1618216188 config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
1618316189
1618416190 // Display all glyphs of the fonts in separate pages of 256 characters
16185- if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
1618616191 {
16187- ImDrawList* draw_list = GetWindowDrawList();
16188- const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
16189- const float cell_size = font->FontSize * 1;
16190- const float cell_spacing = GetStyle().ItemSpacing.y;
16191- for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
16192+ if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
1619216193 {
16193- // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
16194- // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
16195- // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
16196- if (!(base & 8191) && font->IsGlyphRangeUnused(base, base + 8191))
16194+ ImDrawList* draw_list = GetWindowDrawList();
16195+ const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
16196+ const float cell_size = font->FontSize * 1;
16197+ const float cell_spacing = GetStyle().ItemSpacing.y;
16198+ for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
1619716199 {
16198- base += 8192 - 256;
16199- continue;
16200- }
16201-
16202- int count = 0;
16203- for (unsigned int n = 0; n < 256; n++)
16204- if (font->FindGlyphNoFallback((ImWchar)(base + n)))
16205- count++;
16206- if (count <= 0)
16207- continue;
16208- if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
16209- continue;
16200+ // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
16201+ // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
16202+ // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
16203+ if (!(base & 8191) && font->IsGlyphRangeUnused(base, base + 8191))
16204+ {
16205+ base += 8192 - 256;
16206+ continue;
16207+ }
1621016208
16211- // Draw a 16x16 grid of glyphs
16212- ImVec2 base_pos = GetCursorScreenPos();
16213- for (unsigned int n = 0; n < 256; n++)
16214- {
16215- // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
16216- // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
16217- ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
16218- ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
16219- const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
16220- draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
16221- if (!glyph)
16209+ int count = 0;
16210+ for (unsigned int n = 0; n < 256; n++)
16211+ if (font->FindGlyphNoFallback((ImWchar)(base + n)))
16212+ count++;
16213+ if (count <= 0)
16214+ continue;
16215+ if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
1622216216 continue;
16223- font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
16224- if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
16217+
16218+ // Draw a 16x16 grid of glyphs
16219+ ImVec2 base_pos = GetCursorScreenPos();
16220+ for (unsigned int n = 0; n < 256; n++)
1622516221 {
16226- DebugNodeFontGlyph(font, glyph);
16227- EndTooltip();
16222+ // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
16223+ // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
16224+ ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
16225+ ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
16226+ const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
16227+ draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
16228+ if (!glyph)
16229+ continue;
16230+ font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
16231+ if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
16232+ {
16233+ DebugNodeFontGlyph(font, glyph);
16234+ EndTooltip();
16235+ }
1622816236 }
16237+ Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
16238+ TreePop();
1622916239 }
16230- Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
1623116240 TreePop();
1623216241 }
16233- TreePop();
1623416242 }
1623516243 TreePop();
16244+ Unindent();
1623616245}
1623716246
1623816247void ImGui::DebugNodeFontGlyph(ImFont*, const ImFontGlyph* glyph)
0 commit comments