Demo helper function to select among loaded fonts. Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
| 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. |
| 5979 | void 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. |
nothing calls this directly
no test coverage detected