MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / SetCurrentFont

Method SetCurrentFont

imgui_tiny_app/imgui/imgui.cpp:9663–9683  ·  view source on GitHub ↗

Use ImDrawList::_SetTexture(), making our shared g.FontStack[] authoritative against window-local ImDrawList. - Whereas ImDrawList::PushTexture()/PopTexture() is not to be used across Begin() calls. - Note that we don't propagate current texture id when e.g. Begin()-ing into a new window, we never really did... - Some code paths never really fully worked with multiple atlas textures. - The right-i

Source from the content-addressed store, hash-verified

9661// because we have a concrete need and a test bed for multiple atlas textures.
9662// FIXME-NEWATLAS-V2: perhaps we can now leverage ImFontAtlasUpdateDrawListsTextures() ?
9663void ImGui::SetCurrentFont(ImFont* font, float font_size_before_scaling, float font_size_after_scaling)
9664{
9665 ImGuiContext& g = *GImGui;
9666 g.Font = font;
9667 g.FontSizeBase = font_size_before_scaling;
9668 UpdateCurrentFontSize(font_size_after_scaling);
9669
9670 if (font != NULL)
9671 {
9672 IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?
9673#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
9674 IM_ASSERT(font->Scale > 0.0f);
9675#endif
9676 ImFontAtlas* atlas = font->OwnerAtlas;
9677 g.DrawListSharedData.FontAtlas = atlas;
9678 g.DrawListSharedData.Font = font;
9679 ImFontAtlasUpdateDrawListsSharedData(atlas);
9680 if (g.CurrentWindow != NULL)
9681 g.CurrentWindow->DrawList->_SetTexture(atlas->TexRef);
9682 }
9683}
9684
9685void ImGui::UpdateCurrentFontSize(float restore_font_size_after_scaling)
9686{

Callers

nothing calls this directly

Calls 3

IsLoadedMethod · 0.80
_SetTextureMethod · 0.80

Tested by

no test coverage detected