|
@@ -16147,18 +16147,24 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
|
|
|
// [DEBUG] Display details for a single font, called by ShowStyleEditor().
|
|
|
void ImGui::DebugNodeFont(ImFont* font)
|
|
|
{
|
|
|
- bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
|
|
|
+ bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources(s)",
|
|
|
font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
|
|
|
- SameLine();
|
|
|
- if (SmallButton("Set as default"))
|
|
|
- GetIO().FontDefault = font;
|
|
|
- if (!opened)
|
|
|
- return;
|
|
|
|
|
|
// Display preview text
|
|
|
+ if (!opened)
|
|
|
+ Indent();
|
|
|
+ Indent();
|
|
|
PushFont(font);
|
|
|
Text("The quick brown fox jumps over the lazy dog");
|
|
|
PopFont();
|
|
|
+ if (!opened)
|
|
|
+ {
|
|
|
+ Unindent();
|
|
|
+ Unindent();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (SmallButton("Set as default"))
|
|
|
+ GetIO().FontDefault = font;
|
|
|
|
|
|
// Display details
|
|
|
SetNextItemWidth(GetFontSize() * 8);
|
|
@@ -16182,57 +16188,60 @@ void ImGui::DebugNodeFont(ImFont* font)
|
|
|
config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
|
|
|
|
|
|
// Display all glyphs of the fonts in separate pages of 256 characters
|
|
|
- if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
|
|
|
{
|
|
|
- ImDrawList* draw_list = GetWindowDrawList();
|
|
|
- const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
|
|
|
- const float cell_size = font->FontSize * 1;
|
|
|
- const float cell_spacing = GetStyle().ItemSpacing.y;
|
|
|
- for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
|
|
|
+ if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
|
|
|
{
|
|
|
- // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
|
|
|
- // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
|
|
|
- // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
|
|
|
- if (!(base & 8191) && font->IsGlyphRangeUnused(base, base + 8191))
|
|
|
+ ImDrawList* draw_list = GetWindowDrawList();
|
|
|
+ const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
|
|
|
+ const float cell_size = font->FontSize * 1;
|
|
|
+ const float cell_spacing = GetStyle().ItemSpacing.y;
|
|
|
+ for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
|
|
|
{
|
|
|
- base += 8192 - 256;
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- int count = 0;
|
|
|
- for (unsigned int n = 0; n < 256; n++)
|
|
|
- if (font->FindGlyphNoFallback((ImWchar)(base + n)))
|
|
|
- count++;
|
|
|
- if (count <= 0)
|
|
|
- continue;
|
|
|
- if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
|
|
|
- continue;
|
|
|
+ // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
|
|
|
+ // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
|
|
|
+ // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
|
|
|
+ if (!(base & 8191) && font->IsGlyphRangeUnused(base, base + 8191))
|
|
|
+ {
|
|
|
+ base += 8192 - 256;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- // Draw a 16x16 grid of glyphs
|
|
|
- ImVec2 base_pos = GetCursorScreenPos();
|
|
|
- for (unsigned int n = 0; n < 256; n++)
|
|
|
- {
|
|
|
- // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
|
|
|
- // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
|
|
|
- ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
|
|
|
- ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
|
|
|
- const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
|
|
|
- draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
|
|
|
- if (!glyph)
|
|
|
+ int count = 0;
|
|
|
+ for (unsigned int n = 0; n < 256; n++)
|
|
|
+ if (font->FindGlyphNoFallback((ImWchar)(base + n)))
|
|
|
+ count++;
|
|
|
+ if (count <= 0)
|
|
|
+ continue;
|
|
|
+ if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
|
|
|
continue;
|
|
|
- font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
|
|
|
- if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
|
|
|
+
|
|
|
+ // Draw a 16x16 grid of glyphs
|
|
|
+ ImVec2 base_pos = GetCursorScreenPos();
|
|
|
+ for (unsigned int n = 0; n < 256; n++)
|
|
|
{
|
|
|
- DebugNodeFontGlyph(font, glyph);
|
|
|
- EndTooltip();
|
|
|
+ // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
|
|
|
+ // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
|
|
|
+ ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
|
|
|
+ ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
|
|
|
+ const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
|
|
|
+ draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
|
|
|
+ if (!glyph)
|
|
|
+ continue;
|
|
|
+ font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
|
|
|
+ if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
|
|
|
+ {
|
|
|
+ DebugNodeFontGlyph(font, glyph);
|
|
|
+ EndTooltip();
|
|
|
+ }
|
|
|
}
|
|
|
+ Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
|
|
|
+ TreePop();
|
|
|
}
|
|
|
- Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
|
|
|
TreePop();
|
|
|
}
|
|
|
- TreePop();
|
|
|
}
|
|
|
TreePop();
|
|
|
+ Unindent();
|
|
|
}
|
|
|
|
|
|
void ImGui::DebugNodeFontGlyph(ImFont*, const ImFontGlyph* glyph)
|