From b666be53f9a3eb50d50f223b9c59a4380f501398 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Mon, 5 Sep 2022 10:20:10 +0900 Subject: [PATCH] do not call BuildLookupTable if for whatever reason a font has no glyphs --- Dalamud/Interface/GameFonts/GameFontManager.cs | 2 +- Dalamud/Interface/ImGuiHelpers.cs | 2 +- Dalamud/Interface/Internal/InterfaceManager.cs | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Dalamud/Interface/GameFonts/GameFontManager.cs b/Dalamud/Interface/GameFonts/GameFontManager.cs index af71fe67f..efa390e46 100644 --- a/Dalamud/Interface/GameFonts/GameFontManager.cs +++ b/Dalamud/Interface/GameFonts/GameFontManager.cs @@ -163,7 +163,7 @@ namespace Dalamud.Interface.GameFonts font->FrequentKerningPairs.Ref(i) /= fontScale; } - if (rebuildLookupTable) + if (rebuildLookupTable && fontPtr.Glyphs.Size > 0) fontPtr.BuildLookupTable(); } diff --git a/Dalamud/Interface/ImGuiHelpers.cs b/Dalamud/Interface/ImGuiHelpers.cs index 0ae672253..ec2236695 100644 --- a/Dalamud/Interface/ImGuiHelpers.cs +++ b/Dalamud/Interface/ImGuiHelpers.cs @@ -220,7 +220,7 @@ namespace Dalamud.Interface } } - if (rebuildLookupTable) + if (rebuildLookupTable && target.Value!.Glyphs.Size > 0) target.Value!.BuildLookupTable(); } diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index b1f25db9b..53bcfcf3d 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -816,7 +816,7 @@ namespace Dalamud.Interface.Internal for (int i = 0, i_ = ioFonts.ConfigData.Size; i < i_; i++) { var config = ioFonts.ConfigData[i]; - config.RasterizerGamma = config.RasterizerGamma * fontGamma; + config.RasterizerGamma *= fontGamma; } Log.Verbose("[FONT] ImGui.IO.Build will be called."); @@ -876,7 +876,15 @@ namespace Dalamud.Interface.Internal for (int i = 0, i_ = ioFonts.Fonts.Size; i < i_; i++) { var font = ioFonts.Fonts[i]; - font.FallbackChar = Fallback1Codepoint; + if (font.Glyphs.Size == 0) + { + Log.Warning("[FONT] Font has no glyph: {0}", font.GetDebugName()); + continue; + } + + if (font.FindGlyphNoFallback(Fallback1Codepoint).NativePtr != null) + font.FallbackChar = Fallback1Codepoint; + font.BuildLookupTable(); }