From 65e60399794295d28b552941114f41da8be148a0 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 9 May 2025 22:46:39 +0200 Subject: [PATCH] Fonts: remove unnecessary ImDrawListSharedData::FontAtlas which is actually getting in the way of using multiple atlases. --- imgui_draw.cpp | 7 ++----- imgui_internal.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index a76767b9b..eaba28b06 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3865,16 +3865,14 @@ void ImFontAtlasBuildDiscardBakes(ImFontAtlas* atlas, int unused_frames) // Those functions are designed to facilitate changing the underlying structures for ImFontAtlas to store an array of ImDrawListSharedData* void ImFontAtlasAddDrawListSharedData(ImFontAtlas* atlas, ImDrawListSharedData* data) { - IM_ASSERT(!atlas->DrawListSharedDatas.contains(data) && data->FontAtlas == NULL); + IM_ASSERT(!atlas->DrawListSharedDatas.contains(data)); atlas->DrawListSharedDatas.push_back(data); - data->FontAtlas = atlas; } void ImFontAtlasRemoveDrawListSharedData(ImFontAtlas* atlas, ImDrawListSharedData* data) { - IM_ASSERT(atlas->DrawListSharedDatas.contains(data) && data->FontAtlas == atlas); + IM_ASSERT(atlas->DrawListSharedDatas.contains(data)); atlas->DrawListSharedDatas.find_erase(data); - data->FontAtlas = NULL; } // Update texture identifier in all active draw lists @@ -3902,7 +3900,6 @@ void ImFontAtlasUpdateDrawListsSharedData(ImFontAtlas* atlas) { for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas) { - shared_data->FontAtlas = atlas; shared_data->TexUvWhitePixel = atlas->TexUvWhitePixel; shared_data->TexUvLines = atlas->TexUvLines; } diff --git a/imgui_internal.h b/imgui_internal.h index 5f2a06fe4..f145fd012 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -838,7 +838,6 @@ struct IMGUI_API ImDrawListSharedData { ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas (== FontAtlas->TexUvWhitePixel) const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas (== FontAtlas->TexUvLines) - ImFontAtlas* FontAtlas; // Current font atlas ImFont* Font; // Current/default font (optional, for simplified AddText overload) float FontSize; // Current/default font size (optional, for simplified AddText overload) float FontScale; // Current/default font scale (== FontSize / Font->FontSize)