MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / DebugNodeFont

Method DebugNodeFont

TheForceEngine/TFE_Ui/imGUI/imgui.cpp:15445–15533  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

15443
15444// [DEBUG] Display details for a single font, called by ShowStyleEditor().
15445void ImGui::DebugNodeFont(ImFont* font)
15446{
15447 bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
15448 font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
15449 SameLine();
15450 if (SmallButton("Set as default"))
15451 GetIO().FontDefault = font;
15452 if (!opened)
15453 return;
15454
15455 // Display preview text
15456 PushFont(font);
15457 Text("The quick brown fox jumps over the lazy dog");
15458 PopFont();
15459
15460 // Display details
15461 SetNextItemWidth(GetFontSize() * 8);
15462 DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f");
15463 SameLine(); MetricsHelpMarker(
15464 "Note that the default embedded font is NOT meant to be scaled.\n\n"
15465 "Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
15466 "You may oversample them to get some flexibility with scaling. "
15467 "You can also render at multiple sizes and select which one to use at runtime.\n\n"
15468 "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
15469 Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
15470 char c_str[5];
15471 Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar);
15472 Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
15473 const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface);
15474 Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
15475 for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
15476 if (font->ConfigData)
15477 if (const ImFontConfig* cfg = &font->ConfigData[config_i])
15478 BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
15479 config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
15480
15481 // Display all glyphs of the fonts in separate pages of 256 characters
15482 if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
15483 {
15484 ImDrawList* draw_list = GetWindowDrawList();
15485 const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
15486 const float cell_size = font->FontSize * 1;
15487 const float cell_spacing = GetStyle().ItemSpacing.y;
15488 for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
15489 {
15490 // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
15491 // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
15492 // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
15493 if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095))
15494 {
15495 base += 4096 - 256;
15496 continue;
15497 }
15498
15499 int count = 0;
15500 for (unsigned int n = 0; n < 256; n++)
15501 if (font->FindGlyphNoFallback((ImWchar)(base + n)))
15502 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