diff --git a/imgui.cpp b/imgui.cpp index e97f5e6fb..ff2d18a67 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8668,7 +8668,7 @@ ImFont* ImGui::GetDefaultFont() { ImGuiContext& g = *GImGui; ImFontAtlas* atlas = g.IO.Fonts; - if (atlas->Builder == NULL) + if (atlas->Builder == NULL || atlas->Fonts.Size == 0) ImFontAtlasBuildMain(atlas); return g.IO.FontDefault ? g.IO.FontDefault : atlas->Fonts[0]; } diff --git a/imgui_draw.cpp b/imgui_draw.cpp index b208b6836..195f5bece 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -4362,6 +4362,8 @@ ImTextureRect* ImFontAtlasPackGetRectSafe(ImFontAtlas* atlas, ImFontAtlasRectId if (id == ImFontAtlasRectId_Invalid) return NULL; int index_idx = ImFontAtlasRectId_GetIndex(id); + if (atlas->Builder == NULL) + ImFontAtlasBuildInit(atlas); ImFontAtlasBuilder* builder = (ImFontAtlasBuilder*)atlas->Builder; if (index_idx >= builder->RectsIndex.Size) return NULL;