From 7ac1bff482b6c982df4cc4a9a2e1b1503c6cfa88 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 11 Mar 2025 19:54:33 +0100 Subject: [PATCH] Fonts: fixed an issue calling legacy ImFontAtlas::Clear(). --- imgui_draw.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 88f623c8b..f6cf1f4a6 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -2637,8 +2637,6 @@ void ImFontAtlas::Clear() RendererHasTextures = false; // Full Clear() is supported, but ClearTexData() only isn't. ClearFonts(); ClearTexData(); - if (Builder != NULL) - ImFontAtlasBuildClearTexture(this); RendererHasTextures = backup_renderer_has_textures; } @@ -3374,8 +3372,6 @@ void ImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas, const ImFontLoader* fon atlas->FontLoader = font_loader; atlas->FontLoaderName = font_loader ? font_loader->Name : "NULL"; - if (atlas->FontLoader && atlas->FontLoader->LoaderInit) - atlas->FontLoader->LoaderInit(atlas); ImFontAtlasBuildAddTexture(atlas, new_tex_size.x, new_tex_size.y); ImFontAtlasBuildInit(atlas); @@ -4140,8 +4136,12 @@ void ImFontAtlasBuildInit(ImFontAtlas* atlas) return; // ImFontAtlasBuildSetupFontLoader() automatically call ImFontAtlasBuildInit() } + IM_ASSERT(atlas->FontLoaderData == NULL); + if (atlas->FontLoader && atlas->FontLoader->LoaderInit) + atlas->FontLoader->LoaderInit(atlas); + // Create initial texture size - if (atlas->TexData == NULL) + if (atlas->TexData == NULL || atlas->TexData->Pixels == NULL) ImFontAtlasBuildAddTexture(atlas, ImUpperPowerOfTwo(atlas->TexMinWidth), ImUpperPowerOfTwo(atlas->TexMinHeight)); ImFontAtlasBuilder* builder = atlas->Builder; // Do not move above