From 0448428322780d34599e30e5267b4a063374d691 Mon Sep 17 00:00:00 2001 From: Matthew Pohlmann Date: Sat, 5 Jul 2025 08:51:58 -0700 Subject: [PATCH 01/15] Fonts: Change ImFontConfig::FontNo back to int from S8 (#8775) When used with FreeType this value is passed as `face_index` which needs to be 32-bits. # Conflicts: # docs/CHANGELOG.txt --- docs/CHANGELOG.txt | 4 ++++ imgui.h | 4 ++-- misc/freetype/imgui_freetype.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 625a5b927..00c66b8d5 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -50,6 +50,10 @@ Other changes: - Fonts: set a maximum font size of 512.0f at ImGui:: API level to reduce edge cases (e.g. out of memory errors). ImDrawList:: API doesn't have the constraint. (#8758) +- Fonts: Restore ImFontConfig::FontNo being a 32-bits value as this is needed + to pass full range of information into e.g. FreeType's face_index, as higher + bits are used from FreeType 2.6.1. (#8775) [@Valakor] + (the field has been erroneously reduced from 32-bits to 8-bit in 1.92.0) - Textures: Fixed support for `#define ImTextureID_Invalid` to non-zero value: ImTextureData() was incorrectly cleared with zeroes. (#8745) [@rachit7645] - Demo: Added "Text -> Font Size" demo section. (#8738) [@Demonese] diff --git a/imgui.h b/imgui.h index 153ce5cad..e605cb676 100644 --- a/imgui.h +++ b/imgui.h @@ -3473,9 +3473,9 @@ struct ImFontConfig bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights. bool PixelSnapH; // false // Align every glyph AdvanceX to pixel boundaries. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1. bool PixelSnapV; // true // Align Scaled GlyphOffset.y to pixel boundaries. - ImS8 FontNo; // 0 // Index of font within TTF/OTF file ImS8 OversampleH; // 0 (2) // Rasterize at higher quality for sub-pixel positioning. 0 == auto == 1 or 2 depending on size. Note the difference between 2 and 3 is minimal. You can reduce this to 1 for large glyphs save memory. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details. 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. + ImWchar EllipsisChar; // 0 // Explicitly specify Unicode codepoint of ellipsis character. When fonts are being merged first specified ellipsis will be used. 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 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. @@ -3484,11 +3484,11 @@ struct ImFontConfig 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. float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs float GlyphExtraAdvanceX; // 0 // Extra spacing (in pixels) between glyphs. Please contact us if you are using this. // FIXME-NEWATLAS: Intentionally unscaled + ImU32 FontNo; // 0 // Index of font within TTF/OTF file unsigned int FontLoaderFlags; // 0 // Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure. //unsigned int FontBuilderFlags; // -- // [Renamed in 1.92] Ue FontLoaderFlags. 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 // [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] ImFontFlags Flags; // Font flags (don't use just yet, will be exposed in upcoming 1.92.X updates) diff --git a/misc/freetype/imgui_freetype.cpp b/misc/freetype/imgui_freetype.cpp index 33f259365..7a9468375 100644 --- a/misc/freetype/imgui_freetype.cpp +++ b/misc/freetype/imgui_freetype.cpp @@ -174,7 +174,7 @@ struct ImGui_ImplFreeType_FontSrcBakedData bool ImGui_ImplFreeType_FontSrcData::InitFont(FT_Library ft_library, ImFontConfig* src, ImGuiFreeTypeLoaderFlags extra_font_loader_flags) { - FT_Error error = FT_New_Memory_Face(ft_library, (uint8_t*)src->FontData, (uint32_t)src->FontDataSize, (uint32_t)src->FontNo, &FtFace); + FT_Error error = FT_New_Memory_Face(ft_library, (uint8_t*)src->FontData, (FT_Long)src->FontDataSize, (FT_Long)src->FontNo, &FtFace); if (error != 0) return false; error = FT_Select_Charmap(FtFace, FT_ENCODING_UNICODE); From be6303765425ac3fd3b0ab59b673d90200f87a8f Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 10:34:59 +0200 Subject: [PATCH 02/15] CI: Updated to use latest Windows image + VS2022. (Untested) --- .github/workflows/build.yml | 10 +++++----- docs/CHANGELOG.txt | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc58e25bb..edf37ef9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,10 +17,10 @@ on: jobs: Windows: - runs-on: windows-2019 + runs-on: windows-2025 env: - VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\ - MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\ + VS_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\ + MSBUILD_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\ steps: - uses: actions/checkout@v4 @@ -40,8 +40,8 @@ jobs: run: | # CI workers do not supporter older Visual Studio versions. Fix projects to target newer available version. gci -recurse -filter "*.vcxproj" | ForEach-Object { - (Get-Content $_.FullName) -Replace "v\d{3}","v142" | Set-Content -Path $_.FullName - (Get-Content $_.FullName) -Replace "[\d\.]+","10.0.18362.0" | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -Replace "v\d{3}","v143" | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -Replace "[\d\.]+","$(LatestTargetPlatformVersion)" | Set-Content -Path $_.FullName } # Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long. diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 00c66b8d5..cdb7da4e6 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -58,6 +58,7 @@ Other changes: ImTextureData() was incorrectly cleared with zeroes. (#8745) [@rachit7645] - Demo: Added "Text -> Font Size" demo section. (#8738) [@Demonese] - CI: Fixed dllimport/dllexport tests. (#8757) [@AidanSun05] +- CI: Updated to use latest Windows image + VS2022. - Backends: SDL3: avoid calling SDL_StartTextInput() again if already active. (#8727) [@morrazzzz] - Backends: OSX: added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress From 497ebec01dba0d981f99fa4c6a7c43c72e7d8bd1 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 10:36:49 +0200 Subject: [PATCH 03/15] CI: Fix/amend be63037. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index edf37ef9e..5efd6f389 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: # CI workers do not supporter older Visual Studio versions. Fix projects to target newer available version. gci -recurse -filter "*.vcxproj" | ForEach-Object { (Get-Content $_.FullName) -Replace "v\d{3}","v143" | Set-Content -Path $_.FullName - (Get-Content $_.FullName) -Replace "[\d\.]+","$(LatestTargetPlatformVersion)" | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -Replace "[\d\.]+","\$(LatestTargetPlatformVersion)" | Set-Content -Path $_.FullName } # Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long. From 4441aa8b605524bb0806d39a22a251491bc18535 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 10:41:01 +0200 Subject: [PATCH 04/15] CI: Fix/amend be63037. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5efd6f389..21d059913 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: # CI workers do not supporter older Visual Studio versions. Fix projects to target newer available version. gci -recurse -filter "*.vcxproj" | ForEach-Object { (Get-Content $_.FullName) -Replace "v\d{3}","v143" | Set-Content -Path $_.FullName - (Get-Content $_.FullName) -Replace "[\d\.]+","\$(LatestTargetPlatformVersion)" | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -Replace "[\d\.]+","\\$(LatestTargetPlatformVersion)" | Set-Content -Path $_.FullName } # Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long. From 68971223aa47a5a62dc7ff783c826315276a45dc Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 10:42:45 +0200 Subject: [PATCH 05/15] CI: Fix/amend be63037. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21d059913..95bcf3e76 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: # CI workers do not supporter older Visual Studio versions. Fix projects to target newer available version. gci -recurse -filter "*.vcxproj" | ForEach-Object { (Get-Content $_.FullName) -Replace "v\d{3}","v143" | Set-Content -Path $_.FullName - (Get-Content $_.FullName) -Replace "[\d\.]+","\\$(LatestTargetPlatformVersion)" | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -Replace "[\d\.]+",'$(LatestTargetPlatformVersion)' | Set-Content -Path $_.FullName } # Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long. From 495d6f1e39acf46b6ee4b1d6d16912940d1a8d58 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 14:51:42 +0200 Subject: [PATCH 06/15] Undef 'Status' in main header file. (#8751, #8765) --- backends/imgui_impl_sdl2.cpp | 4 +--- backends/imgui_impl_vulkan.cpp | 1 + imgui.h | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backends/imgui_impl_sdl2.cpp b/backends/imgui_impl_sdl2.cpp index 18035d24f..4dc2dea6e 100644 --- a/backends/imgui_impl_sdl2.cpp +++ b/backends/imgui_impl_sdl2.cpp @@ -118,9 +118,7 @@ #ifdef __EMSCRIPTEN__ #include #endif -#ifdef Status // X11 headers -#undef Status -#endif +#undef Status // X11 headers are leaking this. #if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__) #define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1 diff --git a/backends/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp index 059e8c9ed..52ad716b7 100644 --- a/backends/imgui_impl_vulkan.cpp +++ b/backends/imgui_impl_vulkan.cpp @@ -97,6 +97,7 @@ #ifndef IM_MAX #define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B)) #endif +#undef Status // X11 headers are leaking this. // Visual Studio warnings #ifdef _MSC_VER diff --git a/imgui.h b/imgui.h index e605cb676..0833e1c82 100644 --- a/imgui.h +++ b/imgui.h @@ -3385,6 +3385,8 @@ struct ImDrawData // FOR ALL OTHER ImTextureXXXX TYPES: ONLY CORE LIBRARY AND RENDERER BACKENDS NEED TO KNOW AND CARE ABOUT THEM. //----------------------------------------------------------------------------- +#undef Status // X11 headers are leaking this. + // We intentionally support a limited amount of texture formats to limit burden on CPU-side code and extension. // Most standard backends only support RGBA32 but we provide a single channel option for low-resource/embedded systems. enum ImTextureFormat From 94c888ebda6f0123dbf89b27f109298d0818d757 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 15:27:47 +0200 Subject: [PATCH 07/15] Docs: update 1.92.0 changelogs to cover more internal fields. (#8764) --- docs/CHANGELOG.txt | 6 ++++++ imgui.cpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index cdb7da4e6..d53af355d 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -196,6 +196,7 @@ Breaking changes: While in theory a vast majority of users shouldn't be affected, some use cases or extensions might be. Among other things: - ImDrawCmd::TextureId has been changed to ImDrawCmd::TexRef. + - ImFontAtlas::TexID has been changed to ImFontAtlas::TexRef. - ImFontAtlas::ConfigData[] has been renamed to ImFontAtlas::Sources[]. - ImFont::ConfigData[], ConfigDataCount has been renamed to Sources[], SourceCount. - Each ImFont has a number of ImFontBaked instances corresponding to actively used @@ -213,6 +214,11 @@ Breaking changes: g.Font == ImGui::GetFont() g.FontSize == ImGui::GetFontSize() g.FontBaked == ImGui::GetFontBaked() == ImGui::GetFont()->GetFontBaked(ImGui::GetFontSize()) + - Fields moved from ImFontAtlas to ImTextureData + - ImFontAtlas->TexWidth -> ImFontAtlas->TexData->Width + - ImFontAtlas->TexHeight -> ImFontAtlas->TexData->Height + - ImFontAtlas->TexPixelsAlpha8 -> ImFontAtlas->TexData->GetPixels() (when ImFontAtlas::TexDesiredFormat == ImTextureFormat_Alpha8) + - ImFontAtlas->TexPixelsRGBA32 -> ImFontAtlas->TexData->GetPixels() (when ImFontAtlas::TexDesiredFormat == ImTextureFormat_RGBA32) Please report if you are affected! - Fonts: (users of imgui_freetype) - renamed ImFontAtlas::FontBuilderFlags to ImFontAtlas::FontLoaderFlags. diff --git a/imgui.cpp b/imgui.cpp index f34ad7969..0a8582686 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -445,10 +445,12 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures: - Fonts: obsoleted ImFont::Scale which is not useful anymore. - Fonts: generally reworked Internals of ImFontAtlas and ImFont. While in theory a vast majority of users shouldn't be affected, some use cases or extensions might be. Among other things: - ImDrawCmd::TextureId has been changed to ImDrawCmd::TexRef. + - ImFontAtlas::TexID has been changed to ImFontAtlas::TexRef. - ImFontAtlas::ConfigData[] has been renamed to ImFontAtlas::Sources[] - ImFont::ConfigData[], ConfigDataCount has been renamed to Sources[], SourceCount. - Each ImFont has a number of ImFontBaked instances corresponding to actively used sizes. ImFont::GetFontBaked(size) retrieves the one for a given size. - Fields moved from ImFont to ImFontBaked: IndexAdvanceX[], Glyphs[], Ascent, Descent, FindGlyph(), FindGlyphNoFallback(), GetCharAdvance(). + - Fields moved from ImFontAtlas to ImFontAtlas->Tex: ImFontAtlas::TexWidth => TexData->Width, ImFontAtlas::TexHeight => TexData->Height, ImFontAtlas::TexPixelsAlpha8/TexPixelsRGBA32 => TexData->GetPixels(). - Widget code may use ImGui::GetFontBaked() instead of ImGui::GetFont() to access font data for current font at current font size (and you may use font->GetFontBaked(size) to access it for any other size.) - Fonts: (users of imgui_freetype): renamed ImFontAtlas::FontBuilderFlags to ImFontAtlas::FontLoaderFlags. Renamed ImFontConfig::FontBuilderFlags to ImFontConfig::FontLoaderFlags. Renamed ImGuiFreeTypeBuilderFlags to ImGuiFreeTypeLoaderFlags. If you used runtime imgui_freetype selection rather than the default IMGUI_ENABLE_FREETYPE compile-time option: Renamed/reworked ImFontBuilderIO into ImFontLoader. Renamed ImGuiFreeType::GetBuilderForFreeType() to ImGuiFreeType::GetFontLoader(). From 57a93e1a19892ae194351766b59b0992ba55c7e5 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 15:36:24 +0200 Subject: [PATCH 08/15] Backends: Allegro5: fixed texture update broken on some platforms where ALLEGRO_LOCK_WRITEONLY needed all texels to be rewritten. (#8770) --- backends/imgui_impl_allegro5.cpp | 11 +++++------ docs/CHANGELOG.txt | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backends/imgui_impl_allegro5.cpp b/backends/imgui_impl_allegro5.cpp index bd7f10c64..5cbb89365 100644 --- a/backends/imgui_impl_allegro5.cpp +++ b/backends/imgui_impl_allegro5.cpp @@ -21,6 +21,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2025-07-07: Fixed texture update broken on some platforms where ALLEGRO_LOCK_WRITEONLY needed all texels to be rewritten. // 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLGPU3_CreateFontsTexture() and ImGui_ImplSDLGPU3_DestroyFontsTexture(). // 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support. // 2025-01-06: Avoid calling al_set_mouse_cursor() repeatedly since it appears to leak on on X11 (#8256). @@ -291,14 +292,12 @@ void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex) { // Update selected blocks. We only ever write to textures regions which have never been used before! // This backend choose to use tex->Updates[] but you can use tex->UpdateRect to upload a single region. - ImTextureRect r_bb = tex->UpdateRect; // Bounding box encompassing all individual updates + ImTextureRect r = tex->UpdateRect; // Bounding box encompassing all individual updates ALLEGRO_BITMAP* gpu_bitmap = (ALLEGRO_BITMAP*)(intptr_t)tex->TexID; - ALLEGRO_LOCKED_REGION* locked_region = al_lock_bitmap_region(gpu_bitmap, r_bb.x, r_bb.y, r_bb.w, r_bb.h, al_get_bitmap_format(gpu_bitmap), ALLEGRO_LOCK_WRITEONLY); + ALLEGRO_LOCKED_REGION* locked_region = al_lock_bitmap_region(gpu_bitmap, r.x, r.y, r.w, r.h, al_get_bitmap_format(gpu_bitmap), ALLEGRO_LOCK_WRITEONLY); IM_ASSERT(locked_region && "Backend failed to update texture!"); - for (ImTextureRect& r : tex->Updates) - for (int y = 0; y < r.h; y++) - memcpy((unsigned char*)locked_region->data + locked_region->pitch * (r.y - r_bb.y + y) + (r.x - r_bb.x) * tex->BytesPerPixel, // dst - tex->GetPixelsAt(r.x, r.y + y), r.w * tex->BytesPerPixel); // src, block pitch + for (int y = 0; y < r.h; y++) + memcpy((unsigned char*)locked_region->data + locked_region->pitch * y, tex->GetPixelsAt(r.x, r.y + y), r.w * tex->BytesPerPixel); // dst, src, block pitch al_unlock_bitmap(gpu_bitmap); tex->SetStatus(ImTextureStatus_OK); } diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index d53af355d..6e9c71f8d 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -63,6 +63,8 @@ Other changes: (#8727) [@morrazzzz] - Backends: OSX: added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support. (#8739) [@cfillion] +- Backends: Allegro5: fixed texture update broken on some platforms where + ALLEGRO_LOCK_WRITEONLY needed all texels to be rewritten. (#8770) - Backends: Vulkan: use nonCoherentAtomSize to align upload_size, fixing validation error on some setups. (#8743, #8744) [@tquante] From 4ef11452416b1b99179b2d3076ef451484de078e Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 16:50:50 +0200 Subject: [PATCH 09/15] Fonts: fixed dynamically changing font loader from losing Fallback and Ellipsis glyphs. (#8763) Only the call to ImFontAtlasBuildSetupFontLoader() is the notable change. The change in ImFontAtlasFontInitOutput() is merely to use an existing helper function. --- docs/CHANGELOG.txt | 2 ++ imgui_draw.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 6e9c71f8d..0cf39ca51 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -45,6 +45,8 @@ Other changes: - Fonts: added ImFontAtlas::SetFontLoader() to dynamically change font loader at runtime without using internal API. (#8752, #8465) +- Fonts: fixed a bug where dynamically changing font loader would lose + the Fallback and Ellipsis glyphs under some circumstance. (#8763) - Fonts: for large size fonts, layout/size calculation only load glyphs metrics. Actual glyphs are renderer+packed when used by drawing functions. (#8758, #8465) - Fonts: set a maximum font size of 512.0f at ImGui:: API level to reduce diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 374088573..bce905420 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3410,6 +3410,9 @@ void ImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas, const ImFontLoader* fon atlas->FontLoader->LoaderInit(atlas); for (ImFont* font : atlas->Fonts) ImFontAtlasFontInitOutput(atlas, font); + for (ImFont* font : atlas->Fonts) + for (ImFontConfig* src : font->Sources) + ImFontAtlasFontSourceAddToFont(atlas, font, src); } // Preload all glyph ranges for legacy backends. @@ -3576,11 +3579,8 @@ bool ImFontAtlasFontInitOutput(ImFontAtlas* atlas, ImFont* font) { bool ret = true; for (ImFontConfig* src : font->Sources) - { - const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader; - if (loader && loader->FontSrcInit != NULL && !loader->FontSrcInit(atlas, src)) + if (!ImFontAtlasFontSourceInit(atlas, src)) ret = false; - } IM_ASSERT(ret); // Unclear how to react to this meaningfully. Assume that result will be same as initial AddFont() call. return ret; } From c2d9b075339346881b92c3ddb614f9305e93194b Mon Sep 17 00:00:00 2001 From: Moses Miller Date: Fri, 4 Jul 2025 02:33:55 -0700 Subject: [PATCH 10/15] Backends: Vulkan: fixed texture synchronization. (#8772) --- backends/imgui_impl_vulkan.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp index 52ad716b7..38eaabe90 100644 --- a/backends/imgui_impl_vulkan.cpp +++ b/backends/imgui_impl_vulkan.cpp @@ -27,6 +27,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2025-07-07: Vulkan: Fixed texture synchronization issue introduced on 2025-06-11. (#8772) // 2025-06-27: Vulkan: Fixed validation errors during texture upload/update by aligning upload size to 'nonCoherentAtomSize'. (#8743, #8744) // 2025-06-11: Vulkan: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplVulkan_CreateFontsTexture() and ImGui_ImplVulkan_DestroyFontsTexture(). // 2025-05-07: Vulkan: Fixed validation errors during window detach in multi-viewport mode. (#8600, #8176) @@ -808,6 +809,7 @@ void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex) { VkImageMemoryBarrier copy_barrier[1] = {}; copy_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + copy_barrier[0].srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; copy_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; copy_barrier[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; copy_barrier[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; @@ -817,7 +819,7 @@ void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex) copy_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; copy_barrier[0].subresourceRange.levelCount = 1; copy_barrier[0].subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(bd->TexCommandBuffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, copy_barrier); + vkCmdPipelineBarrier(bd->TexCommandBuffer, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, copy_barrier); VkBufferImageCopy region = {}; region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; From 032e1397d9e728106e6e03e819419e29370b2106 Mon Sep 17 00:00:00 2001 From: Moses Miller Date: Fri, 4 Jul 2025 03:21:54 -0700 Subject: [PATCH 11/15] Backends: Vulkan: use separate barrier for buffer. (#8772) --- backends/imgui_impl_vulkan.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backends/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp index 38eaabe90..a5dd75c8e 100644 --- a/backends/imgui_impl_vulkan.cpp +++ b/backends/imgui_impl_vulkan.cpp @@ -807,9 +807,18 @@ void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex) // Copy to Image: { + VkBufferMemoryBarrier upload_barrier[1] = {}; + upload_barrier[0].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; + upload_barrier[0].srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; + upload_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + upload_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + upload_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + upload_barrier[0].buffer = upload_buffer; + upload_barrier[0].offset = 0; + upload_barrier[0].size = upload_size; + VkImageMemoryBarrier copy_barrier[1] = {}; copy_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - copy_barrier[0].srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; copy_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; copy_barrier[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; copy_barrier[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; @@ -819,7 +828,7 @@ void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex) copy_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; copy_barrier[0].subresourceRange.levelCount = 1; copy_barrier[0].subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(bd->TexCommandBuffer, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, copy_barrier); + vkCmdPipelineBarrier(bd->TexCommandBuffer, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 1, upload_barrier, 1, copy_barrier); VkBufferImageCopy region = {}; region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; From c0d02e5ae42d26dbe9b31f76233f1c96c3407162 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Jul 2025 17:02:07 +0200 Subject: [PATCH 12/15] Backends: Vulkan: forgot to update Changelog. (#8772) --- docs/CHANGELOG.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 0cf39ca51..b70e47a73 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -69,6 +69,8 @@ Other changes: ALLEGRO_LOCK_WRITEONLY needed all texels to be rewritten. (#8770) - Backends: Vulkan: use nonCoherentAtomSize to align upload_size, fixing validation error on some setups. (#8743, #8744) [@tquante] +- Backends: Vulkan: fixed texture synchronization issue introduced in 1.92.0, + leading to validation layers reacting. (#8772) [@Majora320] ----------------------------------------------------------------------- From 7c51c0e3de2b04216b9562f5e5d55de943650388 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 8 Jul 2025 11:58:50 +0200 Subject: [PATCH 13/15] Docs: misc update. (#8727, #8764) --- docs/BACKENDS.md | 2 ++ docs/CHANGELOG.txt | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/BACKENDS.md b/docs/BACKENDS.md index ae5e91b0e..fa05d55ea 100644 --- a/docs/BACKENDS.md +++ b/docs/BACKENDS.md @@ -298,6 +298,8 @@ Version [1.92.0](https://github.com/ocornut/imgui/releases/tag/v1.92.0) (June 20 **In order to move forward and take advantage of all new features, support for `ImGuiBackendFlags_RendererHasTextures` will likely be REQUIRED for all backends before June 2026.** +`ImFontAtlas` functions such as `Build()`, `GetTexDataAsRGBA32()`, `GetTexDataAsAlpha8()`, `SetTexID()`, `IsBuilt()` were obsoleted in favor if iterating a `Textures[]` array and updating their state when requested by Dear ImGui. + **TD;DR: List of commits which added support for `ImGuiBackendFlags_RendererHasTextures` in standard backends:** - Allegro5: [ee8941e](https://github.com/ocornut/imgui/commit/ee8941e) (+35 lines) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index b70e47a73..0a3523621 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -62,7 +62,8 @@ Other changes: - CI: Fixed dllimport/dllexport tests. (#8757) [@AidanSun05] - CI: Updated to use latest Windows image + VS2022. - Backends: SDL3: avoid calling SDL_StartTextInput() again if already active. - (#8727) [@morrazzzz] + (fixes e.g.: an issue on iOS where the keyboard animation will popup every + time the user types a key + probably other things) (#8727) [@morrazzzz] - Backends: OSX: added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support. (#8739) [@cfillion] - Backends: Allegro5: fixed texture update broken on some platforms where @@ -168,6 +169,8 @@ Breaking changes: and IsBuilt() functions. The new protocol for backends to handle textures doesn't need them. Kept redirection functions (will obsolete). - A majority of old backends should still work with new code (behaving like they did before). + - For instructions to upgrade your custom backend: + https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md - Calling ImFontAtlas::Build() before initializing new backends will erroneously trigger preloading all glyphs. Will be detected with an assertion after the backend is initialized. - Fonts: ImFontConfig::OversampleH/OversampleV default to automatic (== 0) From 18dca11dd0428dc1de424bc5b71a4cecaf1d889f Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Fri, 27 Jun 2025 13:40:48 +0200 Subject: [PATCH 14/15] Backends: GLFW, SDL2: ImplXXX_GetContentScaleXXX() helpers return 1.0f on emscripten / apple / android (#8742, #8733) We can divide platforms into two cases based on how they report screen geometry: - Case 1: Platforms which report screen size in "physical pixels": Windows (for "Dpi aware" apps), Linux (with Wayland) - Case 2: Platforms which report screen size in "density-independent pixels": macOS, iOS, Android, emscripten As a consequence, there are two important things we need to know: - FramebufferScale: The scaling factor FrameBufferSize / ScreenSize - In case 1, the framebuffer size is equal to the screen size and DisplayFramebufferScale=1. - In case 2, the framebuffer size is equal to the screen size multiplied by a factor, for example DisplayFramebufferScale=2. - ContentScale The scaling factor for the content that we will display - In case 1, the content scale will often need to be > 1 (e.g., 2), because we will need to display bigger elements so that they show with a correct physical size on the screen. - In case 2, the content scale is equal to 1 This commit fixes ContentScale for platforms in case 2. --- backends/imgui_impl_glfw.cpp | 5 +++-- backends/imgui_impl_sdl2.cpp | 3 ++- docs/CHANGELOG.txt | 3 +++ imgui.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backends/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp index d0a75ac78..98e07ce5c 100644 --- a/backends/imgui_impl_glfw.cpp +++ b/backends/imgui_impl_glfw.cpp @@ -29,6 +29,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2025-07-08: Made ImGui_ImplGlfw_GetContentScaleForWindow(), ImGui_ImplGlfw_GetContentScaleForMonitor() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733) // 2025-06-18: Added support for multiple Dear ImGui contexts. (#8676, #8239, #8069) // 2025-06-11: Added ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) and ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor) helper to facilitate making DPI-aware apps. // 2025-03-10: Map GLFW_KEY_WORLD_1 and GLFW_KEY_WORLD_2 into ImGuiKey_Oem102. @@ -876,7 +877,7 @@ static void ImGui_ImplGlfw_UpdateGamepads() // - Some accessibility applications are declaring virtual monitors with a DPI of 0.0f, see #7902. We preserve this value for caller to handle. float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) { -#if GLFW_HAS_PER_MONITOR_DPI && !defined(__APPLE__) +#if GLFW_HAS_PER_MONITOR_DPI && !(defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__)) float x_scale, y_scale; glfwGetWindowContentScale(window, &x_scale, &y_scale); return x_scale; @@ -888,7 +889,7 @@ float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) float ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor) { -#if GLFW_HAS_PER_MONITOR_DPI && !defined(__APPLE__) +#if GLFW_HAS_PER_MONITOR_DPI && !(defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__)) float x_scale, y_scale; glfwGetMonitorContentScale(monitor, &x_scale, &y_scale); return x_scale; diff --git a/backends/imgui_impl_sdl2.cpp b/backends/imgui_impl_sdl2.cpp index 4dc2dea6e..291edb811 100644 --- a/backends/imgui_impl_sdl2.cpp +++ b/backends/imgui_impl_sdl2.cpp @@ -21,6 +21,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2025-07-08: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733) // 2025-06-11: Added ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window) and ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index) helper to facilitate making DPI-aware apps. // 2025-04-09: Don't attempt to call SDL_CaptureMouse() on drivers where we don't call SDL_GetGlobalMouseState(). (#8561) // 2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set. @@ -719,7 +720,7 @@ float ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window) float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index) { #if SDL_HAS_PER_MONITOR_DPI -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) float dpi = 0.0f; if (SDL_GetDisplayDPI(display_index, &dpi, nullptr, nullptr) == 0) return dpi / 96.0f; diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 0a3523621..d412df107 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -61,6 +61,9 @@ Other changes: - Demo: Added "Text -> Font Size" demo section. (#8738) [@Demonese] - CI: Fixed dllimport/dllexport tests. (#8757) [@AidanSun05] - CI: Updated to use latest Windows image + VS2022. +- Backends: GLFW, SDL2 made ImGui_ImplGLFW_GetContentScaleXXX() and + ImGui_ImplSDL2_GetContentScaleXXXX() helpers return 1.0f on Emscripten + and Android platforms, matching macOS logic. (#8742, #8733) [@pthom] - Backends: SDL3: avoid calling SDL_StartTextInput() again if already active. (fixes e.g.: an issue on iOS where the keyboard animation will popup every time the user types a key + probably other things) (#8727) [@morrazzzz] diff --git a/imgui.h b/imgui.h index 0833e1c82..89c2c2e5d 100644 --- a/imgui.h +++ b/imgui.h @@ -29,7 +29,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.92.1 WIP" -#define IMGUI_VERSION_NUM 19201 +#define IMGUI_VERSION_NUM 19202 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 From ed7d965818f9a7d04de0d5ec76ea9809b49a78e7 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Fri, 27 Jun 2025 16:36:43 +0200 Subject: [PATCH 15/15] Examples: GLFW+OpenGL3, GLFW+WGPU: Emscripten Makefiles uses port contrib.glfw3 (#8742) This unofficial port offers a better support for HighDPI. See - https://emscripten.org/docs/compiling/Contrib-Ports.html - https://github.com/pongasoft/emscripten-glfw --- docs/CHANGELOG.txt | 2 ++ examples/example_glfw_opengl3/Makefile.emscripten | 5 +++-- examples/example_glfw_wgpu/Makefile.emscripten | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index d412df107..2cab3f6c5 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -61,6 +61,8 @@ Other changes: - Demo: Added "Text -> Font Size" demo section. (#8738) [@Demonese] - CI: Fixed dllimport/dllexport tests. (#8757) [@AidanSun05] - CI: Updated to use latest Windows image + VS2022. +- Examples: GLFW+OpenGL3, GLFW+WGPU: Emscripten Makefiles uses GLFW port + 'contrib.glfw3' which offers better HiDPI support. (#8742) [@pthom] - Backends: GLFW, SDL2 made ImGui_ImplGLFW_GetContentScaleXXX() and ImGui_ImplSDL2_GetContentScaleXXXX() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733) [@pthom] diff --git a/examples/example_glfw_opengl3/Makefile.emscripten b/examples/example_glfw_opengl3/Makefile.emscripten index bba4ac9dc..8d2f6e7bd 100644 --- a/examples/example_glfw_opengl3/Makefile.emscripten +++ b/examples/example_glfw_opengl3/Makefile.emscripten @@ -32,8 +32,9 @@ EMS = ##--------------------------------------------------------------------- # ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only) -EMS += -s DISABLE_EXCEPTION_CATCHING=1 -LDFLAGS += -s USE_GLFW=3 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 +# Note: For glfw, we use emscripten-glfw port (contrib.glfw3) instead of ('-s USE_GLFW=3' in LDFLAGS) to get a better support for High DPI displays. +EMS += -s DISABLE_EXCEPTION_CATCHING=1 --use-port=contrib.glfw3 +LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 # Build as single file (binary text encoded in .html file) #LDFLAGS += -sSINGLE_FILE diff --git a/examples/example_glfw_wgpu/Makefile.emscripten b/examples/example_glfw_wgpu/Makefile.emscripten index 78d64b4d3..8ee398bc8 100644 --- a/examples/example_glfw_wgpu/Makefile.emscripten +++ b/examples/example_glfw_wgpu/Makefile.emscripten @@ -32,8 +32,9 @@ EMS = ##--------------------------------------------------------------------- # ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only) -EMS += -s DISABLE_EXCEPTION_CATCHING=1 -LDFLAGS += -s USE_GLFW=3 -s USE_WEBGPU=1 +# Note: For glfw, we use emscripten-glfw port (contrib.glfw3) instead of (-s USE_GLFW=3) to get a better support for High DPI displays. +EMS += -s DISABLE_EXCEPTION_CATCHING=1 --use-port=contrib.glfw3 +LDFLAGS += -s USE_WEBGPU=1 LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 # Build as single file (binary text encoded in .html file)