From afe20dc9b608e29b2e75964327287cf5588c1d2d Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 20 Jun 2025 15:23:52 +0200 Subject: [PATCH 1/8] Backends: warning fix. --- backends/imgui_impl_dx9.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/imgui_impl_dx9.cpp b/backends/imgui_impl_dx9.cpp index 5f3f3bd1c..b0159bf37 100644 --- a/backends/imgui_impl_dx9.cpp +++ b/backends/imgui_impl_dx9.cpp @@ -374,7 +374,7 @@ static void ImGui_ImplDX9_CopyTextureRegion(bool tex_use_colors, const ImU32* sr #endif for (int y = 0; y < h; y++) { - const ImU32* src_p = (const ImU32*)(void*)((const unsigned char*)src + src_pitch * y); + const ImU32* src_p = (const ImU32*)(const void*)((const unsigned char*)src + src_pitch * y); ImU32* dst_p = (ImU32*)(void*)((unsigned char*)dst + dst_pitch * y); if (convert_rgba_to_bgra) for (int x = w; x > 0; x--, src_p++, dst_p++) // Convert copy From 0dc2885f3e0890585a0fa61a1ea041df9609b0ab Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 22 Jun 2025 13:04:06 +0200 Subject: [PATCH 2/8] InputText: fix for InsertChars() to work on read-only buffer. (#8714, #8689, #8242) Ill defined feature but memory editor use InsertChars etc on a read-only buffer. `if (init_state)` block of InputTextEx() intentionally does not resize TextA, as unneeded. Amend b2c73596aeaf63b46b66a615ec02fce1b87f4248 Amend e900571 --- imgui_widgets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 43d98bb88..d7214b6c2 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4289,7 +4289,7 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons // Grow internal buffer if needed const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0; const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)ImStrlen(new_text); - if (new_text_len + BufTextLen + 1 > obj->TextA.Size) + if (new_text_len + BufTextLen + 1 > obj->TextA.Size && (Flags & ImGuiInputTextFlags_ReadOnly) == 0) { if (!is_resizable) return; From 613a6a964c9183c1fcdffde792ae96bc9fdfb944 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jun 2025 10:27:24 +0200 Subject: [PATCH 3/8] Fonts: AddFontDefault() adds to GlyphOffset.y instead of overriding it. --- imgui_draw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 5a67b239a..0b4175126 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3102,7 +3102,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) if (font_cfg.Name[0] == '\0') ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf"); font_cfg.EllipsisChar = (ImWchar)0x0085; - font_cfg.GlyphOffset.y = 1.0f * IM_TRUNC(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units + font_cfg.GlyphOffset.y += 1.0f * IM_TRUNC(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units int ttf_compressed_size = 0; const char* ttf_compressed = GetDefaultCompressedFontDataTTF(&ttf_compressed_size); From a49ddaac897538aee7b8dffe4f7cc537ac9e8e9a Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jun 2025 10:50:30 +0200 Subject: [PATCH 4/8] Fonts: add comments and examples for GlyphExcludeRanges[]. --- docs/CHANGELOG.txt | 22 +++++++++++++++++++++- docs/FONTS.md | 39 +++++++++++++++++++++++++++++++++++++++ imgui.cpp | 19 +++++++++++++++++-- imgui.h | 2 +- 4 files changed, 78 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 71549deb5..4b879a6cb 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -62,7 +62,7 @@ Breaking changes: - Fonts: **IMPORTANT**: if your app was solving the OSX/iOS Retina screen specific logical vs display scale problem by setting io.DisplayFramebufferScale (e.g. to 2.0f) + setting io.FontGlobalScale (e.g. to 1.0f/2.0f) + loading fonts at scaled sizes (e.g. size X * 2.0f): - This WILL NOT map correctly to the new system! Because font will rasterize as requested size. + - This WILL NOT map correctly to the new system! Because font will rasterize as requested size. - 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. @@ -84,6 +84,26 @@ Breaking changes: - ImFont::FontSize was removed and does not make sense anymore. ImFont::LegacySize is the size passed to AddFont(). - Renamed/moved 'io.FontGlobalScale' to 'style.FontScaleMain'. +- Fonts: **IMPORTANT** on Font Merging: + - When searching for a glyph in multiple merged fonts: font inputs are now scanned in order + for the first font input which the desired glyph. This is technically a different behavior + than before! + - 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! + - You can use `ImFontConfig::GlyphExcludeRanges[]` to specify ranges to ignore in given Input: + // Add Font Source 1 but ignore ICON_MIN_FA..ICON_MAX_FA range + static ImWchar exclude_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; + ImFontConfig cfg1; + cfg1.GlyphExcludeRanges = exclude_ranges; + io.Fonts->AddFontFromFileTTF("segoeui.ttf", 0.0f, &cfg1); + // Add Font Source 2, which expects to use the range above + ImFontConfig cfg2; + cfg2.MergeMode = true; + io.Fonts->AddFontFromFileTTF("FontAwesome4.ttf", 0.0f, &cfg2); + - You can use `Metrics/Debugger->Fonts->Font->Input Glyphs Overlap Detection Tool` to + see list of glyphs available in multiple font sources. This can facilitate understanding + which font input is providing which glyph. - Textures: - All API functions taking a 'ImTextureID' parameter are now taking a 'ImTextureRef': diff --git a/docs/FONTS.md b/docs/FONTS.md index 95538f97d..8edfbd33b 100644 --- a/docs/FONTS.md +++ b/docs/FONTS.md @@ -18,6 +18,7 @@ In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) fo - [Loading Font Data from Memory](#loading-font-data-from-memory) - [Loading Font Data Embedded In Source Code](#loading-font-data-embedded-in-source-code) - [Using Icon Fonts](#using-icon-fonts) + - [Excluding Overlapping Ranges](#excluding-overlapping-ranges) - [Using FreeType Rasterizer (imgui_freetype)](#using-freetype-rasterizer-imgui_freetype) - [Using Colorful Glyphs/Emojis](#using-colorful-glyphsemojis) - [Using Custom Glyph Ranges](#using-custom-glyph-ranges) @@ -313,6 +314,44 @@ Here's an application using icons ("Avoyd", https://www.avoyd.com): --------------------------------------- +### Excluding Overlapping Ranges + +🆕 **Since 1.92, with an up to date backend: glyphs ranges are ignored**: when loading a glyph, input fonts in the merge list are queried in order. The first font which has the glyph loads it. +
‼️ **If you are merging several fonts, you may have undesirable overlapping ranges.** You can use `ImFontConfig::GlyphExcludeRanges[] `to specify ranges to ignore in a given Input. + +```cpp +// Add Font Source 1 but ignore ICON_MIN_FA..ICON_MAX_FA range +static ImWchar exclude_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; +ImFontConfig cfg1; +cfg1.GlyphExcludeRanges = exclude_ranges; +io.Fonts->AddFontFromFileTTF("segoeui.ttf", 0.0f, &cfg1); + +// Add Font Source 2, which expects to use the range above +ImFontConfig cfg2; +cfg2.MergeMode = true; +io.Fonts->AddFontFromFileTTF("FontAwesome4.ttf", 0.0f, &cfg2); +``` +Another (silly) example: +```cpp +// Remove 'A'-'Z' from first font +static ImWchar exclude_ranges[] = { 'A', 'Z', 0 }; +ImFontConfig cfg1; +cfg1.GlyphExcludeRanges = exclude_ranges; +io.Fonts->AddFontFromFileTTF("segoeui.ttf", 0.0f, &cfg1); + +// Load another font to fill the gaps +ImFontConfig cfg2; +cfg2.MergeMode = true; +io.Fonts->AddFontFromFileTTF("Roboto-Medium.ttf", 0.0f, &cfg2); +``` +![image](https://github.com/user-attachments/assets/f3d751d3-1aee-4698-bd9b-f511902f56bb) + +You can use `Metrics/Debugger->Fonts->Font->Input Glyphs Overlap Detection Tool` to see list of glyphs available in multiple font sources. This can facilitate understanding which font input is providing which glyph. + +##### [Return to Index](#index) + +--------------------------------------- + ## Using FreeType Rasterizer (imgui_freetype) - Dear ImGui uses [stb_truetype.h](https://github.com/nothings/stb/) to rasterize fonts (with optional oversampling). This technique and its implementation are not ideal for fonts rendered at small sizes, which may appear a little blurry or hard to read. diff --git a/imgui.cpp b/imgui.cpp index af22c37fa..2b4a98802 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -474,6 +474,20 @@ CODE - Before 1.92: ImGui::PushFont() always used font "default" size specified in AddFont() call. - Since 1.92: ImGui::PushFont() 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). + - 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! + - 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! + - You can use `ImFontConfig::GlyphExcludeRanges[]` to specify ranges to ignore in given Input: + // Add Font Source 1 but ignore ICON_MIN_FA..ICON_MAX_FA range + static ImWchar exclude_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; + ImFontConfig cfg1; + cfg1.GlyphExcludeRanges = exclude_ranges; + io.Fonts->AddFontFromFileTTF("segoeui.ttf", 0.0f, &cfg1); + // Add Font Source 2, which expects to use the range above + ImFontConfig cfg2; + cfg2.MergeMode = true; + io.Fonts->AddFontFromFileTTF("FontAwesome4.ttf", 0.0f, &cfg2); + - You can use `Metrics/Debugger->Fonts->Font->Input Glyphs Overlap Detection Tool` to see list of glyphs available in multiple font sources. This can facilitate unde - Fonts: ImFont::FontSize was removed and does not make sense anymore. ImFont::LegacySize is the size passed to AddFont(). - Fonts: Renamed/moved 'io.FontGlobalScale' to 'style.FontScaleMain'. - Textures: all API functions taking a 'ImTextureID' parameter are now taking a 'ImTextureRef'. Affected functions are: ImGui::Image(), ImGui::ImageWithBg(), ImGui::ImageButton(), ImDrawList::AddImage(), ImDrawList::AddImageQuad(), ImDrawList::AddImageRounded(). @@ -3932,7 +3946,7 @@ void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCurso ImGuiContext& g = *GImGui; if (mouse_cursor <= ImGuiMouseCursor_None || mouse_cursor >= ImGuiMouseCursor_COUNT) // We intentionally accept out of bound values. mouse_cursor = ImGuiMouseCursor_Arrow; - ImFontAtlas* font_atlas = g.DrawListSharedData.FontAtlas; + ImFontAtlas* font_atlas = g.DrawListSharedData.FontAtlas; for (ImGuiViewportP* viewport : g.Viewports) { // We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor. @@ -16958,7 +16972,8 @@ void ImGui::DebugNodeFont(ImFont* font) } if (font->Sources.Size > 1 && TreeNode("Input Glyphs Overlap Detection Tool")) { - TextWrapped("- First Input that contains the glyph is used.\n- Use ImFontConfig::GlyphExcludeRanges[] to specify ranges to ignore glyph in given Input.\n- This tool doesn't cache results and is slow, don't keep it open!"); + TextWrapped("- First Input that contains the glyph is used.\n" + "- Use ImFontConfig::GlyphExcludeRanges[] to specify ranges to ignore glyph in given Input.\n- Prefer using a small number of ranges as the list is scanned every time a new glyph is loaded,\n - e.g. GlyphExcludeRanges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };\n- This tool doesn't cache results and is slow, don't keep it open!"); if (BeginTable("table", 2)) { for (unsigned int c = 0; c < 0x10000; c++) diff --git a/imgui.h b/imgui.h index 061e6a9eb..ba8001d87 100644 --- a/imgui.h +++ b/imgui.h @@ -3474,7 +3474,7 @@ struct ImFontConfig ImS8 OversampleV; // 0 (1) // Rasterize at higher quality for sub-pixel positioning. 0 == auto == 1. This is not really useful as we don't use sub-pixel positions on the Y axis. float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height). const ImWchar* GlyphRanges; // NULL // *LEGACY* THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). - const ImWchar* GlyphExcludeRanges; // NULL // Pointer to a VERY SHORT user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). This is very close to GlyphRanges[] but designed to exclude ranges from a font source, when merging fonts with overlapping glyphs. Use "Input Glyphs Overlap Detection Tool" to find about your overlapping ranges. + const ImWchar* GlyphExcludeRanges; // NULL // Pointer to a small user-provided list of Unicode ranges (2 value per range, values are inclusive, zero-terminated list). This is very close to GlyphRanges[] but designed to exclude ranges from a font source, when merging fonts with overlapping glyphs. Use "Input Glyphs Overlap Detection Tool" to find about your overlapping ranges. //ImVec2 GlyphExtraSpacing; // 0, 0 // (REMOVED AT IT SEEMS LARGELY OBSOLETE. PLEASE REPORT IF YOU WERE USING THIS). Extra spacing (in pixels) between glyphs when rendered: essentially add to glyph->AdvanceX. Only X axis is supported for now. ImVec2 GlyphOffset; // 0, 0 // Offset (in pixels) all glyphs from this font input. Absolute value for default size, other sizes will scale this value. float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font. Absolute value for default size, other sizes will scale this value. From 608dd96de654b9831c9d2c7d31fd0806df4b358e Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jun 2025 12:21:07 +0200 Subject: [PATCH 5/8] Fonts: fixed RenderText() asserting when crossing VtxOffset change boundaries. (#8720, #8465) --- imgui_draw.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 0b4175126..8d56c0178 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -5581,7 +5581,6 @@ begin: return; // Reserve vertices for remaining worse case (over-reserving is useful and easily amortized) - const int cmd_count = draw_list->CmdBuffer.Size; const int vtx_count_max = (int)(text_end - s) * 4; const int idx_count_max = (int)(text_end - s) * 6; const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max; @@ -5589,6 +5588,7 @@ begin: ImDrawVert* vtx_write = draw_list->_VtxWritePtr; ImDrawIdx* idx_write = draw_list->_IdxWritePtr; unsigned int vtx_index = draw_list->_VtxCurrentIdx; + const int cmd_count = draw_list->CmdBuffer.Size; const ImU32 col_untinted = col | ~IM_COL32_A_MASK; const char* word_wrap_eol = NULL; @@ -5711,6 +5711,8 @@ begin: draw_list->CmdBuffer.pop_back(); draw_list->PrimUnreserve(idx_count_max, vtx_count_max); draw_list->AddDrawCmd(); + //IMGUI_DEBUG_LOG("RenderText: cancel and retry to missing glyphs.\n"); // [DEBUG] + //draw_list->AddRectFilled(pos, pos + ImVec2(10, 10), IM_COL32(255, 0, 0, 255)); // [DEBUG] goto begin; //RenderText(draw_list, size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip); // FIXME-OPT: Would a 'goto begin' be better for code-gen? //return; From 6e846c56b4823110269eb6530468eaf5b106019c Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jun 2025 12:25:04 +0200 Subject: [PATCH 6/8] Demo: fixed ID conflicts. (#8723) --- imgui_demo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index a979b9e92..8a4c4584e 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -4444,11 +4444,11 @@ static void DemoWindowLayout() ImGui::Text("SetNextItemWidth/PushItemWidth(-Min(GetContentRegionAvail().x * 0.40f, GetFontSize() * 12))"); ImGui::PushItemWidth(-IM_MIN(ImGui::GetFontSize() * 12, ImGui::GetContentRegionAvail().x * 0.40f)); - ImGui::DragFloat("float##4a", &f); + ImGui::DragFloat("float##5a", &f); if (show_indented_items) { ImGui::Indent(); - ImGui::DragFloat("float (indented)##4b", &f); + ImGui::DragFloat("float (indented)##5b", &f); ImGui::Unindent(); } ImGui::PopItemWidth(); @@ -4458,11 +4458,11 @@ static void DemoWindowLayout() ImGui::Text("SetNextItemWidth/PushItemWidth(-FLT_MIN)"); ImGui::SameLine(); HelpMarker("Align to right edge"); ImGui::PushItemWidth(-FLT_MIN); - ImGui::DragFloat("##float5a", &f); + ImGui::DragFloat("##float6a", &f); if (show_indented_items) { ImGui::Indent(); - ImGui::DragFloat("float (indented)##5b", &f); + ImGui::DragFloat("float (indented)##6b", &f); ImGui::Unindent(); } ImGui::PopItemWidth(); From 6722d789e91b78f8c1565dbeabfbacd8a1ce87a7 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jun 2025 14:44:38 +0200 Subject: [PATCH 7/8] (Breaking) Fonts: Removed support for PushFont(NULL) which was a shortcut for "default font". --- docs/CHANGELOG.txt | 1 + imgui.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4b879a6cb..1f166b629 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -83,6 +83,7 @@ Breaking changes: (not desirable as it requires e.g. all third-party code to be aware of it). - ImFont::FontSize was removed and does not make sense anymore. ImFont::LegacySize is the size passed to AddFont(). + - Removed support for PushFont(NULL) which was a shortcut for "default font". - Renamed/moved 'io.FontGlobalScale' to 'style.FontScaleMain'. - Fonts: **IMPORTANT** on Font Merging: - When searching for a glyph in multiple merged fonts: font inputs are now scanned in order diff --git a/imgui.cpp b/imgui.cpp index 2b4a98802..1234bce4d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -489,6 +489,7 @@ CODE io.Fonts->AddFontFromFileTTF("FontAwesome4.ttf", 0.0f, &cfg2); - You can use `Metrics/Debugger->Fonts->Font->Input Glyphs Overlap Detection Tool` to see list of glyphs available in multiple font sources. This can facilitate unde - Fonts: ImFont::FontSize was removed and does not make sense anymore. ImFont::LegacySize is the size passed to AddFont(). + - Fonts: Removed support for PushFont(NULL) which was a shortcut for "default font". - Fonts: Renamed/moved 'io.FontGlobalScale' to 'style.FontScaleMain'. - Textures: all API functions taking a 'ImTextureID' parameter are now taking a 'ImTextureRef'. Affected functions are: ImGui::Image(), ImGui::ImageWithBg(), ImGui::ImageButton(), ImDrawList::AddImage(), ImDrawList::AddImageQuad(), ImDrawList::AddImageRounded(). - Fonts: obsoleted ImFontAtlas::GetTexDataAsRGBA32(), GetTexDataAsAlpha8(), Build(), SetTexID(), IsBuilt() functions. The new protocol for backends to handle textures doesn't need them. Kept redirection functions (will obsolete). @@ -8906,9 +8907,11 @@ void ImGui::SetFontRasterizerDensity(float rasterizer_density) void ImGui::PushFont(ImFont* font, float font_size_base) { ImGuiContext& g = *GImGui; + //if (font == NULL) // Before 1.92 (June 2025), PushFont(NULL) == PushFont(GetDefaultFont()) + // font = g.Font; + IM_ASSERT(font != NULL); + g.FontStack.push_back({ g.Font, g.FontSizeBase, g.FontSize }); - if (font == NULL) - font = GetDefaultFont(); if (font_size_base <= 0.0f) { if (font->Flags & ImFontFlags_DefaultToLegacySize) From 0218ddd5753f0b028ad65a5a1a6b4ce0fdc41168 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jun 2025 15:00:42 +0200 Subject: [PATCH 8/8] Fonts: moved GetFont(), GetFontSize(), GetFontBaked() to higher section. --- imgui.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/imgui.h b/imgui.h index ba8001d87..b73089d66 100644 --- a/imgui.h +++ b/imgui.h @@ -499,14 +499,16 @@ namespace ImGui // - To use old behavior (single size font, size specified in AddFontXXX() call: // - Use 'PushFont(font, font->LegacySize)' at call site // - Or set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' before calling AddFont(), and then 'PushFont(font)' will use this size. - // - External scale factors are applied over the provided value. - // *IMPORTANT* If you want to scale an existing font size: - // - OK: PushFontSize(style.FontSizeBase * factor) (= value before external scale factors applied). - // - KO: PushFontSize(GetFontSize() * factor) (= value after external scale factors applied. external scale factors are style.FontScaleMain + per-viewport scales.). + // *IMPORTANT* External scale factors are applied over the provided value. If you want to scale an existing font size: + // - OK: PushFontSize(style.FontSizeBase * 2.0f) (= value before external scale factors applied). + // - NOT OK: PushFontSize(GetFontSize() * 2.0f) (= value after external scale factors applied. External scale factors are: 'style.FontScaleMain * style.FontScaleDpi * maybe more'). IMGUI_API void PushFont(ImFont* font, float font_size_base = -1); // use NULL as a shortcut to push default font. Use <0.0f to keep current font size. IMGUI_API void PopFont(); - IMGUI_API void PushFontSize(float font_size_base); + IMGUI_API void PushFontSize(float font_size_base); // keep current font, change its size. Final 'font size = font_size_base * external scale factors'. IMGUI_API void PopFontSize(); + IMGUI_API ImFont* GetFont(); // get current font + IMGUI_API float GetFontSize(); // 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. + IMGUI_API ImFontBaked* GetFontBaked(); // get current font bound at current size // == GetFont()->GetFontBaked(GetFontSize()) // Parameters stacks (shared) IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); // modify a style color. always use this if you modify the style after NewFrame(). @@ -530,10 +532,7 @@ namespace ImGui // Style read access // - Use the ShowStyleEditor() function to interactively see/edit the colors. - IMGUI_API ImFont* GetFont(); // get current font - IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with external scale factors applied. Use ImGui::GetStyle().FontSizeBase to get value before external scale factors. IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a white pixel, useful to draw custom shapes via the ImDrawList API - IMGUI_API ImFontBaked* GetFontBaked(); // get current font bound at current size // == GetFont()->GetFontBaked(GetFontSize()) IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier, packed as a 32-bit value suitable for ImDrawList IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList IMGUI_API ImU32 GetColorU32(ImU32 col, float alpha_mul = 1.0f); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList