Browse Source

Fonts: fixed legacy backend path preloading all sources sizes erroneously + failing to use ellipsis.

ocornut 5 months ago
parent
commit
2de15dc64b
1 changed files with 9 additions and 3 deletions
  1. 9 3
      imgui_draw.cpp

+ 9 - 3
imgui_draw.cpp

@@ -3383,16 +3383,22 @@ void ImFontAtlasBuildPreloadAllGlyphRanges(ImFontAtlas* atlas)
 {
     atlas->Builder->PreloadedAllGlyphsRanges = true;
     for (ImFont* font : atlas->Fonts)
+    {
+        ImFontConfig* src = &font->Sources[0];
+        ImFontBaked* baked = font->GetFontBaked(src->SizePixels);
+        if (font->FallbackChar != 0)
+            baked->FindGlyph(font->FallbackChar);
+        if (font->EllipsisChar != 0)
+            baked->FindGlyph(font->EllipsisChar);
         for (int src_n = 0; src_n < font->SourcesCount; src_n++)
         {
-            ImFontConfig* src = &font->Sources[src_n];
-            ImFontBaked* baked = font->GetFontBaked(src->SizePixels);
+            src = &font->Sources[src_n];
             const ImWchar* ranges = src->GlyphRanges ? src->GlyphRanges : atlas->GetGlyphRangesDefault();
-            IM_ASSERT(ranges != NULL);
             for (; ranges[0]; ranges += 2)
                 for (unsigned int c = ranges[0]; c <= ranges[1] && c <= IM_UNICODE_CODEPOINT_MAX; c++) //-V560
                     baked->FindGlyph((ImWchar)c);
         }
+    }
 }
 
 void ImFontAtlasBuildUpdatePointers(ImFontAtlas* atlas)