MCPcopy Create free account
hub / github.com/Wemino/MarkerPatch / DebugNodeFontGlyphsForSrcMask

Method DebugNodeFontGlyphsForSrcMask

include/imgui/imgui.cpp:17548–17597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17546}
17547
17548void ImGui::DebugNodeFontGlyphsForSrcMask(ImFont* font, ImFontBaked* baked, int src_mask)
17549{
17550 ImDrawList* draw_list = GetWindowDrawList();
17551 const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
17552 const float cell_size = baked->Size * 1;
17553 const float cell_spacing = GetStyle().ItemSpacing.y;
17554 for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
17555 {
17556 // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
17557 // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
17558 // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
17559 if (!(base & 8191) && font->IsGlyphRangeUnused(base, base + 8191))
17560 {
17561 base += 8192 - 256;
17562 continue;
17563 }
17564
17565 int count = 0;
17566 for (unsigned int n = 0; n < 256; n++)
17567 if (const ImFontGlyph* glyph = baked->IsGlyphLoaded((ImWchar)(base + n)) ? baked->FindGlyph((ImWchar)(base + n)) : NULL)
17568 if (src_mask & (1 << glyph->SourceIdx))
17569 count++;
17570 if (count <= 0)
17571 continue;
17572 if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
17573 continue;
17574
17575 // Draw a 16x16 grid of glyphs
17576 ImVec2 base_pos = GetCursorScreenPos();
17577 for (unsigned int n = 0; n < 256; n++)
17578 {
17579 // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
17580 // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
17581 ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
17582 ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
17583 const ImFontGlyph* glyph = baked->IsGlyphLoaded((ImWchar)(base + n)) ? baked->FindGlyph((ImWchar)(base + n)) : NULL;
17584 draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
17585 if (!glyph || (src_mask & (1 << glyph->SourceIdx)) == 0)
17586 continue;
17587 font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
17588 if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
17589 {
17590 DebugNodeFontGlyph(font, glyph);
17591 EndTooltip();
17592 }
17593 }
17594 Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
17595 TreePop();
17596 }
17597}
17598
17599void ImGui::DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph)
17600{

Callers

nothing calls this directly

Calls 6

ImVec2Function · 0.85
IsGlyphRangeUnusedMethod · 0.80
IsGlyphLoadedMethod · 0.80
FindGlyphMethod · 0.80
RenderCharMethod · 0.80
AddRectMethod · 0.45

Tested by

no test coverage detected