You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- PushFont(font, 0.0f) // Change font and keep current size
79
+
- PushFont(NULL, 20.0f) // Keep font and change current size
80
+
- PushFont(font, 20.0f) // Change font and set size to 20.0f
81
+
- PushFont(font, style.FontSizeBase * 2.0f) // Change font and set size to be twice bigger than current size.
82
+
- PushFont(font, font->LegacySize) // Change font and set size to size passed to AddFontXXX() function. Same as pre-1.92 behavor, for fixed size fonts.
80
83
- To use old behavior:
81
84
- use 'ImGui::PushFont(font, font->LegacySize)' at call site (preferred).
82
85
- or set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' in AddFont() call
83
86
(not desirable as it requires e.g. all third-party code to be aware of it).
87
+
We intentionally didn't add a default parameter because it would make the long-term
88
+
transition more difficult.
89
+
- Kept inline redirection font. Will obsolete.
90
+
- External scale factors may be applied over the provided size.
91
+
This is why it is called 'FontSizeBase' in the style structure.
84
92
- ImFont::FontSize was removed and does not make sense anymore.
85
93
ImFont::LegacySize is the size passed to AddFont().
86
-
- Removed support for PushFont(NULL) which was a shortcut for "default font".
94
+
- Removed support for old PushFont(NULL) which was a shortcut for "revert to default font".
87
95
- Renamed/moved 'io.FontGlobalScale' to 'style.FontScaleMain'.
88
96
- Fonts: **IMPORTANT** on Font Merging:
89
97
- When searching for a glyph in multiple merged fonts: font inputs are now scanned in order
@@ -182,8 +190,8 @@ Breaking changes:
182
190
- renamed ImGuiFreeType::GetBuilderForFreeType() to ImGuiFreeType::GetFontLoader()
Copy file name to clipboardExpand all lines: imgui.cpp
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -470,10 +470,11 @@ CODE
470
470
- With a legacy backend (< 1.92): Instead of setting io.FontGlobalScale = 1.0f/N -> set ImFontCfg::RasterizerDensity = N. This already worked before, but is now pretty much required.
471
471
- With a new backend (1.92+): This should be all automatic. FramebufferScale is automatically used to set current font RasterizerDensity. FramebufferScale is a per-viewport property provided by backend through the Platform_GetWindowFramebufferScale() handler in 'docking' branch.
472
472
- Fonts: **IMPORTANT** on Font Sizing: Before 1.92, fonts were of a single size. They can now be dynamically sized.
473
-
- PushFont() API now has an optional size parameter. PushFontSize() was also added.
474
-
- Before 1.92: ImGui::PushFont() always used font "default" size specified in AddFont() call.
475
-
- Since 1.92: ImGui::PushFont() preserve the current font size which is a shared value.
473
+
- PushFont() API now has a REQUIRED size parameter. PushFontSize() was also added.
474
+
- Before 1.92: PushFont() always used font "default" size specified in AddFont() call. It is equivalent to calling PushFont(font, font->LegacySize).
475
+
- Since 1.92: PushFont(font, 0.0f) preserve the current font size which is a shared value.
476
476
- To use old behavior: (A) use 'ImGui::PushFont(font, font->LegacySize)' at call site (preferred). (B) Set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' in AddFont() call (not desirable as it requires e.g. third-party code to be aware of it).
477
+
- Kept inline single parameter function. Will obsolete.
477
478
- Fonts: **IMPORTANT** on Font Merging:
478
479
- When searching for a glyph in multiple merged fonts: font inputs are now scanned in orderfor the first font input which the desired glyph. This is technically a different behavior than before!
479
480
- e.g. If you are merging fonts you may have glyphs that you expected to load from Font Source 2 which exists in Font Source 1. After the update and when using a new backend, those glyphs may now loaded from Font Source 1!
Copy file name to clipboardExpand all lines: imgui.h
+18-12Lines changed: 18 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -493,21 +493,26 @@ namespace ImGui
493
493
IMGUI_API voidSetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.
494
494
495
495
// Parameters stacks (font)
496
+
// - PushFont(font, 0.0f) // Change font and keep current size
497
+
// - PushFont(NULL, 20.0f) // Keep font and change current size
498
+
// - PushFont(font, 20.0f) // Change font and set size to 20.0f
499
+
// - PushFont(font, style.FontSizeBase * 2.0f) // Change font and set size to be twice bigger than current size.
500
+
// - PushFont(font, font->LegacySize) // Change font and set size to size passed to AddFontXXX() function. Same as pre-1.92 behavior.
496
501
// *IMPORTANT* before 1.92, fonts had a single size. They can now be dynamically be adjusted.
497
-
//- Before 1.92: PushFont() always used font default size.
498
-
//- Since 1.92: PushFont() preserve the current shared font size.
499
-
//- To use old behavior (single size font, size specified in AddFontXXX() call:
500
-
// - Use 'PushFont(font, font->LegacySize)' at call site
501
-
// - Or set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' before calling AddFont(), and then 'PushFont(font)' will use this size.
502
-
//*IMPORTANT* External scale factors are applied over the provided value. If you want to scale an existing font size:
503
-
// - OK: PushFontSize(style.FontSizeBase * 2.0f) (= value before external scale factors applied).
504
-
// - NOT OK: PushFontSize(GetFontSize() * 2.0f) (= value after external scale factors applied. External scale factors are: 'style.FontScaleMain * style.FontScaleDpi * maybe more').
505
-
IMGUI_API voidPushFont(ImFont* font, floatfont_size_base = -1); //use NULL as a shortcut to push default font. Use <0.0f to keep current font size.
502
+
// - In 1.92 we have REMOVED the single parameter version of PushFont() because it seems like the easiest way to provide an error-proof transition.
503
+
// - PushFont(font) before 1.92 = PushFont(font, font->LegacySize) after 1.92 // Use default font size as passed to AddFontXXX() function.
504
+
//*IMPORTANT* external scale factors are applied over the provided size. If you want to scale an *existing* font size:
505
+
//- External scale factors are: 'style.FontScaleMain * style.FontScaleDpi' and maybe more.
506
+
//- CORRECT: PushFont(NULL, style.FontSizeBase) // use current unscaled size == does nothing
507
+
// - CORRECT: PushFont(NULL, style.FontSizeBase * 2.0f) // use current unscaled size x2 == make text twice bigger
508
+
//- INCORRECT: PushFont(NULL, GetFontSize()) // INCORRECT! use size after external factors applied == EXTERNAL SCALING FACTORS WILL APPLY TWICE!
509
+
//- INCORRECT: PushFont(NULL, GetFontSize() * 2.0f) // INCORRECT! use size after external factors applied == EXTERNAL SCALING FACTORS WILL APPLY TWICE!
510
+
IMGUI_API voidPushFont(ImFont* font, floatfont_size_base_unscaled); //Use NULL as a shortcut to keep current font. Use 0.0f to keep current size.
506
511
IMGUI_API voidPopFont();
507
512
IMGUI_API voidPushFontSize(float font_size_base); // keep current font, change its size. Final 'font size = font_size_base * external scale factors'.
508
513
IMGUI_API voidPopFontSize();
509
514
IMGUI_API ImFont* GetFont(); // get current font
510
-
IMGUI_API floatGetFontSize(); // get current font size (= height in pixels) AFTER external scale factors applied. *IMPORTANT* DO NOT PASS THIS VALUE TO PushFont()/PushFontSize()! Use ImGui::GetStyle().FontSizeBase to get value before external scale factors.
515
+
IMGUI_API floatGetFontSize(); // get current scaled font size (= height in pixels). AFTER external scale factors applied. *IMPORTANT* DO NOT PASS THIS VALUE TO PushFont()/PushFontSize()! Use ImGui::GetStyle().FontSizeBase to get value before external scale factors.
511
516
IMGUI_API ImFontBaked* GetFontBaked(); // get current font bound at current size // == GetFont()->GetFontBaked(GetFontSize())
512
517
513
518
// Parameters stacks (shared)
@@ -3756,7 +3761,7 @@ struct ImFontBaked
3756
3761
enum ImFontFlags_
3757
3762
{
3758
3763
ImFontFlags_None = 0,
3759
-
ImFontFlags_DefaultToLegacySize = 1 << 0, // Legacy compatibility: make PushFont() calls without explicit size use font->LegacySize instead of current font size.
3764
+
ImFontFlags_DefaultToLegacySize = 1 << 0, // Legacy compatibility: make `PushFont(font)` == `PushFont(font, font->LegacySize)`. Otherwise by default/shared current font size is used.
3760
3765
ImFontFlags_NoLoadError = 1 << 1, // Disable throwing an error/assert when calling AddFontXXX() with missing file/data. Calling code is expected to check AddFontXXX() return value.
ImFontFlags_LockBakedSizes = 1 << 3, // [Internal] Disable loading new baked sizes, disable garbage collecting current ones. e.g. if you want to lock a font to a single size. Important: if you use this to preload given sizes, consider the possibility of multiple font density used on Retina display.
@@ -3949,7 +3954,8 @@ struct ImGuiPlatformImeData
3949
3954
namespaceImGui
3950
3955
{
3951
3956
// OBSOLETED in 1.92.0 (from June 2025)
3952
-
IMGUI_API voidSetWindowFontScale(float scale); // Set font scale factor for current window. Prefer using PushFontSize(style.FontSizeBase * factor) or use style.FontScaleMain to scale all windows.
IMGUI_API voidSetWindowFontScale(float scale); // Set font scale factor for current window. Prefer using PushFont(NULL, style.FontSizeBase * factor) or use style.FontScaleMain to scale all windows.
3953
3959
// OBSOLETED in 1.91.9 (from February 2025)
3954
3960
IMGUI_API voidImage(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col); // <-- 'border_col' was removed in favor of ImGuiCol_ImageBorder. If you use 'tint_col', use ImageWithBg() instead.
0 commit comments