@@ -16147,18 +16147,24 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
16147
16147
// [DEBUG] Display details for a single font, called by ShowStyleEditor().
16148
16148
void ImGui::DebugNodeFont(ImFont* font)
16149
16149
{
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)",
16151
16151
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;
16157
16152
16158
16153
// Display preview text
16154
+ if (!opened)
16155
+ Indent();
16156
+ Indent();
16159
16157
PushFont(font);
16160
16158
Text("The quick brown fox jumps over the lazy dog");
16161
16159
PopFont();
16160
+ if (!opened)
16161
+ {
16162
+ Unindent();
16163
+ Unindent();
16164
+ return;
16165
+ }
16166
+ if (SmallButton("Set as default"))
16167
+ GetIO().FontDefault = font;
16162
16168
16163
16169
// Display details
16164
16170
SetNextItemWidth(GetFontSize() * 8);
@@ -16182,57 +16188,60 @@ void ImGui::DebugNodeFont(ImFont* font)
16182
16188
config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
16183
16189
16184
16190
// Display all glyphs of the fonts in separate pages of 256 characters
16185
- if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
16186
16191
{
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))
16192
16193
{
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)
16197
16199
{
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
+ }
16210
16208
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"))
16222
16216
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++)
16225
16221
{
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
+ }
16228
16236
}
16237
+ Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
16238
+ TreePop();
16229
16239
}
16230
- Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
16231
16240
TreePop();
16232
16241
}
16233
- TreePop();
16234
16242
}
16235
16243
TreePop();
16244
+ Unindent();
16236
16245
}
16237
16246
16238
16247
void ImGui::DebugNodeFontGlyph(ImFont*, const ImFontGlyph* glyph)
0 commit comments