MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / DebugNodeFont

Method DebugNodeFont

KBotExt/imgui/imgui.cpp:14292–14380  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

14290
14291// [DEBUG] Display details for a single font, called by ShowStyleEditor().
14292void ImGui::DebugNodeFont(ImFont* font)
14293{
14294 bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
14295 font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
14296 SameLine();
14297 if (SmallButton("Set as default"))
14298 GetIO().FontDefault = font;
14299 if (!opened)
14300 return;
14301
14302 // Display preview text
14303 PushFont(font);
14304 Text("The quick brown fox jumps over the lazy dog");
14305 PopFont();
14306
14307 // Display details
14308 SetNextItemWidth(GetFontSize() * 8);
14309 DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f");
14310 SameLine(); MetricsHelpMarker(
14311 "Note than the default embedded font is NOT meant to be scaled.\n\n"
14312 "Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
14313 "You may oversample them to get some flexibility with scaling. "
14314 "You can also render at multiple sizes and select which one to use at runtime.\n\n"
14315 "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
14316 Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
14317 char c_str[5];
14318 Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar);
14319 Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
14320 const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface);
14321 Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
14322 for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
14323 if (font->ConfigData)
14324 if (const ImFontConfig* cfg = &font->ConfigData[config_i])
14325 BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
14326 config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
14327
14328 // Display all glyphs of the fonts in separate pages of 256 characters
14329 if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
14330 {
14331 ImDrawList* draw_list = GetWindowDrawList();
14332 const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
14333 const float cell_size = font->FontSize * 1;
14334 const float cell_spacing = GetStyle().ItemSpacing.y;
14335 for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
14336 {
14337 // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
14338 // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
14339 // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
14340 if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095))
14341 {
14342 base += 4096 - 256;
14343 continue;
14344 }
14345
14346 int count = 0;
14347 for (unsigned int n = 0; n < 256; n++)
14348 if (font->FindGlyphNoFallback((ImWchar)(base + n)))
14349 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