소스 검색

Fonts: fixed dynamically changing font loader from losing Fallback and Ellipsis glyphs. (#8763)

Only the call to ImFontAtlasBuildSetupFontLoader() is the notable change. The change in ImFontAtlasFontInitOutput() is merely to use an existing helper function.
ocornut 2 달 전
부모
커밋
4ef1145241
2개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 0
      docs/CHANGELOG.txt
  2. 4 4
      imgui_draw.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -45,6 +45,8 @@ Other changes:
 
 
 - Fonts: added ImFontAtlas::SetFontLoader() to dynamically change font
 - Fonts: added ImFontAtlas::SetFontLoader() to dynamically change font
   loader at runtime without using internal API. (#8752, #8465)
   loader at runtime without using internal API. (#8752, #8465)
+- Fonts: fixed a bug where dynamically changing font loader would lose
+  the Fallback and Ellipsis glyphs under some circumstance. (#8763)
 - Fonts: for large size fonts, layout/size calculation only load glyphs metrics.
 - Fonts: for large size fonts, layout/size calculation only load glyphs metrics.
   Actual glyphs are renderer+packed when used by drawing functions. (#8758, #8465)
   Actual glyphs are renderer+packed when used by drawing functions. (#8758, #8465)
 - Fonts: set a maximum font size of 512.0f at ImGui:: API level to reduce
 - Fonts: set a maximum font size of 512.0f at ImGui:: API level to reduce

+ 4 - 4
imgui_draw.cpp

@@ -3410,6 +3410,9 @@ void ImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas, const ImFontLoader* fon
         atlas->FontLoader->LoaderInit(atlas);
         atlas->FontLoader->LoaderInit(atlas);
     for (ImFont* font : atlas->Fonts)
     for (ImFont* font : atlas->Fonts)
         ImFontAtlasFontInitOutput(atlas, font);
         ImFontAtlasFontInitOutput(atlas, font);
+    for (ImFont* font : atlas->Fonts)
+        for (ImFontConfig* src : font->Sources)
+            ImFontAtlasFontSourceAddToFont(atlas, font, src);
 }
 }
 
 
 // Preload all glyph ranges for legacy backends.
 // Preload all glyph ranges for legacy backends.
@@ -3576,11 +3579,8 @@ bool ImFontAtlasFontInitOutput(ImFontAtlas* atlas, ImFont* font)
 {
 {
     bool ret = true;
     bool ret = true;
     for (ImFontConfig* src : font->Sources)
     for (ImFontConfig* src : font->Sources)
-    {
-        const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
-        if (loader && loader->FontSrcInit != NULL && !loader->FontSrcInit(atlas, src))
+        if (!ImFontAtlasFontSourceInit(atlas, src))
             ret = false;
             ret = false;
-    }
     IM_ASSERT(ret); // Unclear how to react to this meaningfully. Assume that result will be same as initial AddFont() call.
     IM_ASSERT(ret); // Unclear how to react to this meaningfully. Assume that result will be same as initial AddFont() call.
     return ret;
     return ret;
 }
 }