MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / DebugNodeFont

Method DebugNodeFont

plugins/Cardinal/src/DearImGui/imgui.cpp:12147–12240  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

12145
12146// [DEBUG] Display details for a single font, called by ShowStyleEditor().
12147void ImGui::DebugNodeFont(ImFont* font)
12148{
12149 bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
12150 font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
12151 SameLine();
12152 if (SmallButton("Set as default"))
12153 GetIO().FontDefault = font;
12154 if (!opened)
12155 return;
12156
12157 // Display preview text
12158 PushFont(font);
12159 Text("The quick brown fox jumps over the lazy dog");
12160 PopFont();
12161
12162 // Display details
12163 SetNextItemWidth(GetFontSize() * 8);
12164 DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f");
12165 SameLine(); MetricsHelpMarker(
12166 "Note than the default embedded font is NOT meant to be scaled.\n\n"
12167 "Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
12168 "You may oversample them to get some flexibility with scaling. "
12169 "You can also render at multiple sizes and select which one to use at runtime.\n\n"
12170 "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
12171 Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
12172 char c_str[5];
12173 Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar);
12174 Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
12175 const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface);
12176 Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
12177 for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
12178 if (font->ConfigData)
12179 if (const ImFontConfig* cfg = &font->ConfigData[config_i])
12180 BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
12181 config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
12182
12183 // Display all glyphs of the fonts in separate pages of 256 characters
12184 if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
12185 {
12186 ImDrawList* draw_list = GetWindowDrawList();
12187 const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
12188 const float cell_size = font->FontSize * 1;
12189 const float cell_spacing = GetStyle().ItemSpacing.y;
12190 for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
12191 {
12192 // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
12193 // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
12194 // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
12195 if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095))
12196 {
12197 base += 4096 - 256;
12198 continue;
12199 }
12200
12201 int count = 0;
12202 for (unsigned int n = 0; n < 256; n++)
12203 if (font->FindGlyphNoFallback((ImWchar)(base + n)))
12204 count++;

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected