Преглед изворни кода

Fonts: fixed NewFrame() when atlas builder has been created but fonts not added. Fixed GetCustomRect() after atlas clear.

ocornut пре 2 месеци
родитељ
комит
e1481a731d
2 измењених фајлова са 3 додато и 1 уклоњено
  1. 1 1
      imgui.cpp
  2. 2 0
      imgui_draw.cpp

+ 1 - 1
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];
 }

+ 2 - 0
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;