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

Method ShowFontSelector

plugins/Cardinal/src/DearImGui/imgui_demo.cpp:5979–6001  ·  view source on GitHub ↗

Demo helper function to select among loaded fonts. Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.

Source from the content-addressed store, hash-verified

5977// Demo helper function to select among loaded fonts.
5978// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
5979void ImGui::ShowFontSelector(const char* label)
5980{
5981 ImGuiIO& io = ImGui::GetIO();
5982 ImFont* font_current = ImGui::GetFont();
5983 if (ImGui::BeginCombo(label, font_current->GetDebugName()))
5984 {
5985 for (int n = 0; n < io.Fonts->Fonts.Size; n++)
5986 {
5987 ImFont* font = io.Fonts->Fonts[n];
5988 ImGui::PushID((void*)font);
5989 if (ImGui::Selectable(font->GetDebugName(), font == font_current))
5990 io.FontDefault = font;
5991 ImGui::PopID();
5992 }
5993 ImGui::EndCombo();
5994 }
5995 ImGui::SameLine();
5996 HelpMarker(
5997 "- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
5998 "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
5999 "- Read FAQ and docs/FONTS.md for more details.\n"
6000 "- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
6001}
6002
6003// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
6004// Here we use the simplified Combo() api that packs items into a single literal string.

Callers

nothing calls this directly

Calls 2

HelpMarkerFunction · 0.85
GetDebugNameMethod · 0.80

Tested by

no test coverage detected