From e76cfe5aad93e52b00302f3a9182c64336ab7169 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 13 Mar 2025 16:30:20 +0100 Subject: [PATCH] Fonts: fixed implicit init when calling AddCustomRectRegular(). LoaderShutdown match BuildDestroy. --- imgui_draw.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index f6cf1f4a6..873e77508 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3231,6 +3231,9 @@ int ImFontAtlas::AddCustomRectRegular(int width, int height) IM_ASSERT(width > 0 && width <= 0xFFFF); IM_ASSERT(height > 0 && height <= 0xFFFF); + if (Builder == NULL) + ImFontAtlasBuildInit(this); + ImFontAtlasRectId r_id = ImFontAtlasPackAddRect(this, width, height); if (r_id < 0) return -1; @@ -4185,7 +4188,7 @@ void ImFontAtlasBuildDestroy(ImFontAtlas* atlas) if (loader && loader->FontSrcDestroy != NULL) loader->FontSrcDestroy(atlas, &font_cfg); } - if (atlas->FontLoader && atlas->FontLoader->LoaderShutdown) + if (atlas->Builder && atlas->FontLoader && atlas->FontLoader->LoaderShutdown) { atlas->FontLoader->LoaderShutdown(atlas); IM_ASSERT(atlas->FontLoaderData == NULL);