mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-25 14:16:06 +00:00
(Breaking) Fonts: PushFont() default to preserve current font size.
This commit is contained in:
11
imgui.cpp
11
imgui.cpp
@@ -8582,7 +8582,7 @@ void ImGui::UpdateFontsNewFrame()
|
||||
atlas->Locked = true;
|
||||
|
||||
// We do this really unusual thing of calling *push_front()*, the reason behind that we want to support the PushFont()/NewFrame()/PopFont() idiom.
|
||||
ImFontStackData font_stack_data = { ImGui::GetDefaultFont(), ImGui::GetDefaultFont()->Sources[0].SizePixels };
|
||||
ImFontStackData font_stack_data = { ImGui::GetDefaultFont(), ImGui::GetDefaultFont()->DefaultSize };
|
||||
g.FontStack.push_front(font_stack_data);
|
||||
if (g.FontStack.Size == 1)
|
||||
ImGui::SetCurrentFont(font_stack_data.Font, font_stack_data.FontSize);
|
||||
@@ -8647,8 +8647,13 @@ void ImGui::PushFont(ImFont* font, float font_size)
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (font == NULL)
|
||||
font = GetDefaultFont();
|
||||
if (font_size < 0.0f)
|
||||
font_size = font->Sources[0].SizePixels; // g.FontSize;
|
||||
if (font_size <= 0.0f)
|
||||
{
|
||||
if (font->Flags & ImFontFlags_UseDefaultSize)
|
||||
font_size = font->DefaultSize; // Legacy: use default font size. Same as doing PushFont(font, font->DefaultSize). // FIXME-NEWATLAS
|
||||
else
|
||||
font_size = g.FontSizeBeforeScaling; // Keep current font size
|
||||
}
|
||||
g.FontStack.push_back({ font, font_size });
|
||||
SetCurrentFont(font, font_size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user