mirror of
https://github.com/ocornut/imgui.git
synced 2026-08-21 06:41:09 +00:00
Fonts: AddFontDefault() uses framebuffer scale.
If running before DisplaySize is set, assume a different default on Apple.
This commit is contained in:
@@ -43,6 +43,11 @@ Breaking Changes:
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Fonts:
|
||||
- Reworked `AddFontDefault()` to use `io.DisplayFrameBufferScale` as part of the heuristic
|
||||
to select `AddFontDefaultVector()` by default, effectively using ProggyForever instead of
|
||||
ProggyClean on most Mac setups by default.
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.92.9b (Released 2026-07-31)
|
||||
|
||||
@@ -3168,11 +3168,15 @@ const char* ImGui_GetDefaultCompressedFontDataProggyForever(int* out_size);
|
||||
// This duplicates some of the logic in UpdateFontsNewFrame() which is a bit chicken-and-eggy/tricky to extract due to variety of codepaths and possible initialization ordering.
|
||||
static float GetExpectedContextFontSize(ImGuiContext* ctx)
|
||||
{
|
||||
return ((ctx->Style.FontSizeBase > 0.0f) ? ctx->Style.FontSizeBase : 13.0f) * ctx->Style.FontScaleMain * ctx->Style.FontScaleDpi;
|
||||
float fb_scale = (ctx->IO.DisplayFramebufferScale.x != 0.0f) ? ctx->IO.DisplayFramebufferScale.x : 1.0f;
|
||||
if (ctx->IO.DisplayFramebufferScale.x == 1.0f && ctx->IO.DisplaySize.x <= 0.0f && ctx->IO.ConfigMacOSXBehaviors)
|
||||
fb_scale = 2.0f; // If called before backend had a chance to init DisplayFramebufferScale. default to expecting Retina.
|
||||
float scale = ctx->Style.FontScaleMain * ctx->Style.FontScaleDpi * fb_scale;
|
||||
return ((ctx->Style.FontSizeBase > 0.0f) ? ctx->Style.FontSizeBase : 13.0f) * scale;
|
||||
}
|
||||
|
||||
// Legacy function with heuristic to select Pixel or Vector font.
|
||||
// The selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold at the time of adding the default font.
|
||||
// The selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi * io.DisplayFramebufferScale) reaching a small threshold at the time of adding the default font.
|
||||
// Prefer calling AddFontDefaultVector() or AddFontDefaultBitmap() based on your own logic.
|
||||
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user