MCPcopy Create free account
hub / github.com/RenderKit/embree / DebugNodeFont

Method DebugNodeFont

tutorials/common/imgui/imgui.cpp:13600–13689  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

13598
13599// [DEBUG] Display details for a single font, called by ShowStyleEditor().
13600void ImGui::DebugNodeFont(ImFont* font)
13601{
13602 bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
13603 font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
13604 SameLine();
13605 if (SmallButton("Set as default"))
13606 GetIO().FontDefault = font;
13607 if (!opened)
13608 return;
13609
13610 // Display preview text
13611 PushFont(font);
13612 Text("The quick brown fox jumps over the lazy dog");
13613 PopFont();
13614
13615 // Display details
13616 SetNextItemWidth(GetFontSize() * 8);
13617 DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f");
13618 SameLine(); MetricsHelpMarker(
13619 "Note than the default embedded font is NOT meant to be scaled.\n\n"
13620 "Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
13621 "You may oversample them to get some flexibility with scaling. "
13622 "You can also render at multiple sizes and select which one to use at runtime.\n\n"
13623 "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
13624 Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
13625 char c_str[5];
13626 Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar);
13627 Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
13628 const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface);
13629 Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
13630 for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
13631 if (font->ConfigData)
13632 if (const ImFontConfig* cfg = &font->ConfigData[config_i])
13633 BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
13634 config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
13635
13636 // Display all glyphs of the fonts in separate pages of 256 characters
13637 if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
13638 {
13639 ImDrawList* draw_list = GetWindowDrawList();
13640 const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
13641 const float cell_size = font->FontSize * 1;
13642 const float cell_spacing = GetStyle().ItemSpacing.y;
13643 for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
13644 {
13645 // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
13646 // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
13647 // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
13648 if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095))
13649 {
13650 base += 4096 - 256;
13651 continue;
13652 }
13653
13654 int count = 0;
13655 for (unsigned int n = 0; n < 256; n++)
13656 if (font->FindGlyphNoFallback((ImWchar)(base + n)))
13657 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