MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / ShowFontSelector

Method ShowFontSelector

extern/imgui/imgui_demo.cpp:6145–6167  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

6143// Demo helper function to select among loaded fonts.
6144// Here we use the regular BeginCombo()/EndCombo() api which is the more flexible one.
6145void ImGui::ShowFontSelector(const char* label)
6146{
6147 ImGuiIO& io = ImGui::GetIO();
6148 ImFont* font_current = ImGui::GetFont();
6149 if (ImGui::BeginCombo(label, font_current->GetDebugName()))
6150 {
6151 for (int n = 0; n < io.Fonts->Fonts.Size; n++)
6152 {
6153 ImFont* font = io.Fonts->Fonts[n];
6154 ImGui::PushID((void*)font);
6155 if (ImGui::Selectable(font->GetDebugName(), font == font_current))
6156 io.FontDefault = font;
6157 ImGui::PopID();
6158 }
6159 ImGui::EndCombo();
6160 }
6161 ImGui::SameLine();
6162 HelpMarker(
6163 "- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
6164 "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
6165 "- Read FAQ and docs/FONTS.md for more details.\n"
6166 "- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
6167}
6168
6169// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
6170// 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