1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

(Breaking) Fonts: removed ImFontFlags_DefaultToLegacySize.

This commit is contained in:
ocornut 2025-06-24 19:06:46 +02:00
parent 97e0d59619
commit 89b5a2c3d5
3 changed files with 3 additions and 14 deletions

View file

@ -80,10 +80,7 @@ Breaking changes:
- PushFont(font, 20.0f) // Change font and set size to 20.0f - PushFont(font, 20.0f) // Change font and set size to 20.0f
- PushFont(font, style.FontSizeBase * 2.0f) // Change font and set size to be twice bigger than current size. - PushFont(font, style.FontSizeBase * 2.0f) // Change font and set size to be twice bigger than current size.
- 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. - 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.
- To use old behavior: - To use old behavior use 'ImGui::PushFont(font, font->LegacySize)' at call site.
- use 'ImGui::PushFont(font, font->LegacySize)' at call site (preferred).
- or set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' in AddFont() call
(not desirable as it requires e.g. all third-party code to be aware of it).
We intentionally didn't add a default parameter because it would make the long-term We intentionally didn't add a default parameter because it would make the long-term
transition more difficult. transition more difficult.
- Kept inline redirection font. Will obsolete. - Kept inline redirection font. Will obsolete.
@ -290,8 +287,6 @@ Other changes:
window and other locations). window and other locations).
- Fonts: added ImFontFlags (currently needs to be passed through ImFontConfig until - Fonts: added ImFontFlags (currently needs to be passed through ImFontConfig until
we revamp font loading API): we revamp font loading API):
- ImFontFlags_DefaultToLegacySize: for legacy compatibility: make PushFont() calls
without explicit size use font->LegacySize instead of current font size.
- ImFontFlags_NoLoadError: disable erroring/assert when calling AddFontXXX() - ImFontFlags_NoLoadError: disable erroring/assert when calling AddFontXXX()
with missing file/data. Calling code is expected to check AddFontXXX() return value. with missing file/data. Calling code is expected to check AddFontXXX() return value.
- ImFontFlags_NoLoadGlyphs: disable loading new glyphs. - ImFontFlags_NoLoadGlyphs: disable loading new glyphs.

View file

@ -473,7 +473,7 @@ CODE
- PushFont() API now has a REQUIRED size parameter. - PushFont() API now has a REQUIRED size parameter.
- Before 1.92: PushFont() always used font "default" size specified in AddFont() call. It is equivalent to calling PushFont(font, font->LegacySize). - Before 1.92: PushFont() always used font "default" size specified in AddFont() call. It is equivalent to calling PushFont(font, font->LegacySize).
- Since 1.92: PushFont(font, 0.0f) preserve the current font size which is a shared value. - Since 1.92: PushFont(font, 0.0f) preserve the current font size which is a shared value.
- 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). - To use old behavior: use 'ImGui::PushFont(font, font->LegacySize)' at call site.
- Kept inline single parameter function. Will obsolete. - Kept inline single parameter function. Will obsolete.
- Fonts: **IMPORTANT** on Font Merging: - Fonts: **IMPORTANT** on Font Merging:
- 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! - 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!
@ -8911,12 +8911,7 @@ void ImGui::PushFont(ImFont* font, float font_size_base)
g.FontStack.push_back({ g.Font, g.FontSizeBase, g.FontSize }); g.FontStack.push_back({ g.Font, g.FontSizeBase, g.FontSize });
if (font_size_base == 0.0f) if (font_size_base == 0.0f)
{ font_size_base = g.FontSizeBase; // Keep current font size
if (font->Flags & ImFontFlags_DefaultToLegacySize)
font_size_base = font->LegacySize; // Legacy: use AddFont() specified font size. Same as doing PushFont(font, font->LegacySize)
else
font_size_base = g.FontSizeBase; // Keep current font size
}
SetCurrentFont(font, font_size_base, 0.0f); SetCurrentFont(font, font_size_base, 0.0f);
} }

View file

@ -3759,7 +3759,6 @@ struct ImFontBaked
enum ImFontFlags_ enum ImFontFlags_
{ {
ImFontFlags_None = 0, ImFontFlags_None = 0,
ImFontFlags_DefaultToLegacySize = 1 << 0, // Legacy compatibility: make `PushFont(font)` == `PushFont(font, font->LegacySize)`. Otherwise by default/shared current font size is used.
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_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_NoLoadGlyphs = 1 << 2, // [Internal] Disable loading new glyphs. ImFontFlags_NoLoadGlyphs = 1 << 2, // [Internal] Disable loading new glyphs.
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. 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.