From fad5280d4c131f3ebbbc30f6d1dc0d4e8463df4c Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 11 May 2025 23:51:45 +0200 Subject: [PATCH] Fonts: fixed broken support for legacy backend due to a mismatch with initial pre-build baked id. --- imgui.cpp | 2 +- imgui.h | 2 +- imgui_draw.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 92f0f92bf..bd01afed5 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8657,7 +8657,7 @@ void ImGui::UpdateCurrentFontSize() // - We may support it better later and remove this rounding. final_size = GetRoundedFontSize(final_size); final_size = ImMax(1.0f, final_size); - if (g.Font != NULL) + if (g.Font != NULL && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures)) g.Font->CurrentRasterizerDensity = g.FontRasterizerDensity; g.FontBaked = (g.Font != NULL) ? g.Font->GetFontBaked(final_size) : NULL; g.FontSize = final_size; diff --git a/imgui.h b/imgui.h index 4639e2c2e..71e49efe4 100644 --- a/imgui.h +++ b/imgui.h @@ -3467,7 +3467,7 @@ struct ImFontConfig float GlyphExtraAdvanceX; // 0 // Extra spacing (in pixels) between glyphs. Please contact us if you are using this. unsigned int FontBuilderFlags; // 0 // Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure. float RasterizerMultiply; // 1.0f // Linearly brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable. This is a silly thing we may remove in the future. - float RasterizerDensity; // 1.0f // DPI scale multiplier for rasterization. Not altering other font metrics: makes it easy to swap between e.g. a 100% and a 400% fonts for a zooming display, or handle Retina screen. IMPORTANT: If you change this it is expected that you increase/decrease font scale roughly to the inverse of this, otherwise quality may look lowered. + float RasterizerDensity; // 1.0f // (Legacy: this only makes sense when ImGuiBackendFlags_RendererHasTextures is not supported). DPI scale multiplier for rasterization. Not altering other font metrics: makes it easy to swap between e.g. a 100% and a 400% fonts for a zooming display, or handle Retina screen. IMPORTANT: If you change this it is expected that you increase/decrease font scale roughly to the inverse of this, otherwise quality may look lowered. ImWchar EllipsisChar; // 0 // Explicitly specify Unicode codepoint of ellipsis character. When fonts are being merged first specified ellipsis will be used. // [Internal] diff --git a/imgui_draw.cpp b/imgui_draw.cpp index eaba28b06..65485fb20 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3002,6 +3002,7 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg_in) font->FontId = FontNextUniqueID++; font->Flags = font_cfg_in->Flags; font->DefaultSize = font_cfg_in->SizePixels; + font->CurrentRasterizerDensity = font_cfg_in->RasterizerDensity; Fonts.push_back(font); } else