Demo helper function to select among loaded fonts. Here we use the regular BeginCombo()/EndCombo() api which is the more flexible one.
| 24229 | // Demo helper function to select among loaded fonts. |
| 24230 | // Here we use the regular BeginCombo()/EndCombo() api which is the more flexible one. |
| 24231 | void ImGui::ShowFontSelector(const char* label) |
| 24232 | { |
| 24233 | ImGuiIO& io = GetIO(); |
| 24234 | ImFont* font_current = GetFont(); |
| 24235 | if (BeginCombo(label, font_current->GetDebugName())) |
| 24236 | { |
| 24237 | for (ImFont* font : io.Fonts->Fonts) |
| 24238 | { |
| 24239 | PushID((void*)font); |
| 24240 | if (Selectable(font->GetDebugName(), font == font_current, ImGuiSelectableFlags_SelectOnNav)) |
| 24241 | io.FontDefault = font; |
| 24242 | if (font == font_current) |
| 24243 | SetItemDefaultFocus(); |
| 24244 | PopID(); |
| 24245 | } |
| 24246 | EndCombo(); |
| 24247 | } |
| 24248 | SameLine(); |
| 24249 | if (io.BackendFlags & ImGuiBackendFlags_RendererHasTextures) |
| 24250 | MetricsHelpMarker( |
| 24251 | "- Load additional fonts with io.Fonts->AddFontXXX() functions.\n" |
| 24252 | "- Read FAQ and docs/FONTS.md for more details."); |
| 24253 | else |
| 24254 | MetricsHelpMarker( |
| 24255 | "- Load additional fonts with io.Fonts->AddFontXXX() functions.\n" |
| 24256 | "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n" |
| 24257 | "- Read FAQ and docs/FONTS.md for more details.\n" |
| 24258 | "- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame()."); |
| 24259 | } |
| 24260 | #endif // #if !defined(IMGUI_DISABLE_DEMO_WINDOWS) || !defined(IMGUI_DISABLE_DEBUG_TOOLS) |
| 24261 | |
| 24262 | //----------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected