Skip to content

Commit 739ab24

Browse files
committed
Fonts: internals: renamed g.FontSizeBeforeScaling to g.FontSizeBase for consistency.
1 parent 122d196 commit 739ab24

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

imgui.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,7 +4054,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
40544054
ConfigFlagsCurrFrame = ConfigFlagsLastFrame = ImGuiConfigFlags_None;
40554055
Font = NULL;
40564056
FontBaked = NULL;
4057-
FontSize = FontSizeBeforeScaling = FontBakedScale = CurrentDpiScale = 0.0f;
4057+
FontSize = FontSizeBase = FontBakedScale = CurrentDpiScale = 0.0f;
40584058
FontRasterizerDensity = 1.0f;
40594059
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
40604060
if (shared_font_atlas == NULL)
@@ -9262,7 +9262,7 @@ void ImGui::UpdateFontsNewFrame()
92629262

92639263
// Set initial font
92649264
g.Font = font;
9265-
g.FontSizeBeforeScaling = g.Style.FontSizeBase;
9265+
g.FontSizeBase = g.Style.FontSizeBase;
92669266
g.FontSize = 0.0f;
92679267
ImFontStackData font_stack_data = { font, g.Style.FontSizeBase, g.Style.FontSizeBase }; // <--- Will restore FontSize
92689268
SetCurrentFont(font_stack_data.Font, font_stack_data.FontSizeBeforeScaling, 0.0f); // <--- but use 0.0f to enable scale
@@ -9328,7 +9328,7 @@ void ImGui::SetCurrentFont(ImFont* font, float font_size_before_scaling, float f
93289328
{
93299329
ImGuiContext& g = *GImGui;
93309330
g.Font = font;
9331-
g.FontSizeBeforeScaling = font_size_before_scaling;
9331+
g.FontSizeBase = font_size_before_scaling;
93329332
UpdateCurrentFontSize(font_size_after_scaling);
93339333

93349334
if (font != NULL)
@@ -9349,15 +9349,15 @@ void ImGui::UpdateCurrentFontSize(float restore_font_size_after_scaling)
93499349
ImGuiContext& g = *GImGui;
93509350
ImGuiWindow* window = g.CurrentWindow;
93519351

9352-
g.Style.FontSizeBase = g.FontSizeBeforeScaling;
9352+
g.Style.FontSizeBase = g.FontSizeBase;
93539353
if (window != NULL && window->SkipItems)
93549354
return;
93559355

93569356
// Restoring is pretty much only used by PopFont()/PopFontSize()
93579357
float final_size = (restore_font_size_after_scaling > 0.0f) ? restore_font_size_after_scaling : 0.0f;
93589358
if (final_size == 0.0f)
93599359
{
9360-
final_size = g.FontSizeBeforeScaling;
9360+
final_size = g.FontSizeBase;
93619361

93629362
// External scale factors
93639363
final_size *= g.Style.FontScaleMain; // Main global scale factor
@@ -9407,15 +9407,15 @@ void ImGui::SetFontRasterizerDensity(float rasterizer_density)
94079407
void ImGui::PushFont(ImFont* font, float font_size_base)
94089408
{
94099409
ImGuiContext& g = *GImGui;
9410-
g.FontStack.push_back({ g.Font, g.FontSizeBeforeScaling, g.FontSize });
9410+
g.FontStack.push_back({ g.Font, g.FontSizeBase, g.FontSize });
94119411
if (font == NULL)
94129412
font = GetDefaultFont();
94139413
if (font_size_base <= 0.0f)
94149414
{
94159415
if (font->Flags & ImFontFlags_DefaultToLegacySize)
94169416
font_size_base = font->LegacySize; // Legacy: use AddFont() specified font size. Same as doing PushFont(font, font->LegacySize)
94179417
else
9418-
font_size_base = g.FontSizeBeforeScaling; // Keep current font size
9418+
font_size_base = g.FontSizeBase; // Keep current font size
94199419
}
94209420
SetCurrentFont(font, font_size_base, 0.0f);
94219421
}

imgui_draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3199,7 +3199,7 @@ static void ImFontAtlasBuildNotifySetFont(ImFontAtlas* atlas, ImFont* old_font,
31993199
bool need_bind_ctx = ctx != curr_ctx;
32003200
if (need_bind_ctx)
32013201
ImGui::SetCurrentContext(ctx);
3202-
ImGui::SetCurrentFont(new_font, ctx->FontSizeBeforeScaling, ctx->FontSize);
3202+
ImGui::SetCurrentFont(new_font, ctx->FontSizeBase, ctx->FontSize);
32033203
if (need_bind_ctx)
32043204
ImGui::SetCurrentContext(curr_ctx);
32053205
}

imgui_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,8 +2334,8 @@ struct ImGuiContext
23342334
ImVector<ImFontAtlas*> FontAtlases; // List of font atlases used by the context (generally only contains g.IO.Fonts aka the main font atlas)
23352335
ImFont* Font; // Currently bound font. (== FontStack.back().Font)
23362336
ImFontBaked* FontBaked; // Currently bound font at currently bound size. (== Font->GetFontBaked(FontSize))
2337-
float FontSize; // Currently bound font size == line height (== FontSizeBeforeScaling + externals scales applied in the UpdateCurrentFontSize() function).
2338-
float FontSizeBeforeScaling; // Font size before scaling == style.FontSizeBase == value passed to PushFont() / PushFontSize() when specified.
2337+
float FontSize; // Currently bound font size == line height (== FontSizeBase + externals scales applied in the UpdateCurrentFontSize() function).
2338+
float FontSizeBase; // Font size before scaling == style.FontSizeBase == value passed to PushFont() / PushFontSize() when specified.
23392339
float FontBakedScale; // == FontBaked->Size / FontSize. Scale factor over baked size. Rarely used nowadays, very often == 1.0f.
23402340
float FontRasterizerDensity; // Current font density. Used by all calls to GetFontBaked().
23412341
float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
@@ -2922,7 +2922,7 @@ struct IMGUI_API ImGuiWindow
29222922
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight; return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight); }
29232923

29242924
// [Obsolete] ImGuiWindow::CalcFontSize() was removed in 1.92.x because error-prone/misleading. You can use window->FontRefSize for a copy of g.FontSize at the time of the last Begin() call for this window.
2925-
//float CalcFontSize() const { ImGuiContext& g = *Ctx; return g.FontSizeBeforeScaling * FontWindowScale * FontDpiScale * FontWindowScaleParents;
2925+
//float CalcFontSize() const { ImGuiContext& g = *Ctx; return g.FontSizeBase * FontWindowScale * FontDpiScale * FontWindowScaleParents;
29262926
};
29272927

29282928
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)