MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / DebugNodeFont

Method DebugNodeFont

Dependencies/ImGui/src/imgui.cpp:22099–22200  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

22097
22098// [DEBUG] Display details for a single font, called by ShowStyleEditor().
22099void ImGui::DebugNodeFont(ImFont* font)
22100{
22101 bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources(s)",
22102 font->Sources ? font->Sources[0].Name : "", font->FontSize, font->Glyphs.Size, font->SourcesCount);
22103
22104 // Display preview text
22105 if (!opened)
22106 Indent();
22107 Indent();
22108 PushFont(font);
22109 Text("The quick brown fox jumps over the lazy dog");
22110 PopFont();
22111 if (!opened)
22112 {
22113 Unindent();
22114 Unindent();
22115 return;
22116 }
22117 if (SmallButton("Set as default"))
22118 GetIO().FontDefault = font;
22119
22120 // Display details
22121 SetNextItemWidth(GetFontSize() * 8);
22122 DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f");
22123 SameLine(); MetricsHelpMarker(
22124 "Note that the default embedded font is NOT meant to be scaled.\n\n"
22125 "Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
22126 "You may oversample them to get some flexibility with scaling. "
22127 "You can also render at multiple sizes and select which one to use at runtime.\n\n"
22128 "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
22129 Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
22130 char c_str[5];
22131 Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar);
22132 Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
22133 const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface);
22134 Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
22135 for (int config_i = 0; config_i < font->SourcesCount; config_i++)
22136 if (font->Sources)
22137 {
22138 const ImFontConfig* src = &font->Sources[config_i];
22139 int oversample_h, oversample_v;
22140 ImFontAtlasBuildGetOversampleFactors(src, &oversample_h, &oversample_v);
22141 BulletText("Input %d: \'%s\', Oversample: (%d=>%d,%d=>%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
22142 config_i, src->Name, src->OversampleH, oversample_h, src->OversampleV, oversample_v, src->PixelSnapH, src->GlyphOffset.x, src->GlyphOffset.y);
22143 }
22144
22145 // Display all glyphs of the fonts in separate pages of 256 characters
22146 {
22147 if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
22148 {
22149 ImDrawList* draw_list = GetWindowDrawList();
22150 const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
22151 const float cell_size = font->FontSize * 1;
22152 const float cell_spacing = GetStyle().ItemSpacing.y;
22153 for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
22154 {
22155 // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
22156 // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT

Callers

nothing calls this directly

Calls 13

TreeNodeClass · 0.85
DragFloatClass · 0.85
MetricsHelpMarkerFunction · 0.85
ImTextCharToUtf8Function · 0.85
GetStyleFunction · 0.85
DummyClass · 0.85
ImVec2Function · 0.85
IsGlyphRangeUnusedMethod · 0.80
FindGlyphNoFallbackMethod · 0.80
AddRectMethod · 0.80
RenderCharMethod · 0.80

Tested by

no test coverage detected