MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / DebugNodeFont

Method DebugNodeFont

extern/imgui/imgui.cpp:19426–19515  ·  view source on GitHub ↗

[DEBUG] Display details for a single font, called by ShowStyleEditor().

Source from the content-addressed store, hash-verified

19424
19425// [DEBUG] Display details for a single font, called by ShowStyleEditor().
19426void ImGui::DebugNodeFont(ImFont* font)
19427{
19428 bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
19429 font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
19430 SameLine();
19431 if (SmallButton("Set as default"))
19432 GetIO().FontDefault = font;
19433 if (!opened)
19434 return;
19435
19436 // Display preview text
19437 PushFont(font);
19438 Text("The quick brown fox jumps over the lazy dog");
19439 PopFont();
19440
19441 // Display details
19442 SetNextItemWidth(GetFontSize() * 8);
19443 DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f");
19444 SameLine(); MetricsHelpMarker(
19445 "Note than the default embedded font is NOT meant to be scaled.\n\n"
19446 "Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
19447 "You may oversample them to get some flexibility with scaling. "
19448 "You can also render at multiple sizes and select which one to use at runtime.\n\n"
19449 "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
19450 Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
19451 char c_str[5];
19452 Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar);
19453 Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
19454 const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface);
19455 Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
19456 for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
19457 if (font->ConfigData)
19458 if (const ImFontConfig* cfg = &font->ConfigData[config_i])
19459 BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
19460 config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
19461
19462 // Display all glyphs of the fonts in separate pages of 256 characters
19463 if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
19464 {
19465 ImDrawList* draw_list = GetWindowDrawList();
19466 const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
19467 const float cell_size = font->FontSize * 1;
19468 const float cell_spacing = GetStyle().ItemSpacing.y;
19469 for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
19470 {
19471 // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
19472 // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
19473 // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
19474 if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095))
19475 {
19476 base += 4096 - 256;
19477 continue;
19478 }
19479
19480 int count = 0;
19481 for (unsigned int n = 0; n < 256; n++)
19482 if (font->FindGlyphNoFallback((ImWchar)(base + n)))
19483 count++;

Callers

nothing calls this directly

Calls 7

MetricsHelpMarkerFunction · 0.85
ImTextCharToUtf8Function · 0.85
ImVec2Function · 0.85
IsGlyphRangeUnusedMethod · 0.80
FindGlyphNoFallbackMethod · 0.80
AddRectMethod · 0.80
RenderCharMethod · 0.80

Tested by

no test coverage detected