From 6d9b9a5edadd8c393f5ffab1c51df999f59389c7 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Tue, 8 Sep 2020 20:55:37 +0200 Subject: [PATCH] add some verbose logging for font loading --- Dalamud/Interface/InterfaceManager.cs | 17 +++++++++++++++++ Dalamud/Interface/UiBuilder.cs | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/InterfaceManager.cs b/Dalamud/Interface/InterfaceManager.cs index e4a311ec4..4d24cd8b8 100644 --- a/Dalamud/Interface/InterfaceManager.cs +++ b/Dalamud/Interface/InterfaceManager.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Numerics; using System.Runtime.InteropServices; using System.Text; +using System.Threading; using CheapLoc; using Dalamud.Game; using Dalamud.Game.Internal.DXGI; @@ -207,9 +208,13 @@ namespace Dalamud.Interface // Sets up a deferred invocation of font rebuilding, before the next render frame public void RebuildFonts() { + Log.Verbose("[FONT] RebuildFonts() called"); + // don't invoke this multiple times per frame, in case multiple plugins call it if (!this.isRebuildingFonts) { + Log.Verbose("[FONT] RebuildFonts() trigger"); + this.isRebuildingFonts = true; this.scene.OnNewRenderFrame += RebuildFontsInternal; } @@ -300,10 +305,18 @@ namespace Dalamud.Interface }, GCHandleType.Pinned); IconFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathIcon, 17.0f, null, iconRangeHandle.AddrOfPinnedObject()); + Log.Verbose("[FONT] Invoke OnBuildFonts"); this.OnBuildFonts?.Invoke(); + Log.Verbose("[FONT] OnBuildFonts OK!"); + + for (var i = 0; i < ImGui.GetIO().Fonts.Fonts.Size; i++) { + Log.Verbose("{0} - {1}", i, ImGui.GetIO().Fonts.Fonts[i].GetDebugName()); + } ImGui.GetIO().Fonts.Build(); + Log.Verbose("[FONT] Fonts built!"); + fontConfig.Destroy(); japaneseRangeHandle.Free(); gameRangeHandle.Free(); @@ -313,11 +326,15 @@ namespace Dalamud.Interface // This is intended to only be called as a handler attached to scene.OnNewRenderFrame private void RebuildFontsInternal() { + Log.Verbose("[FONT] RebuildFontsInternal() called"); SetupFonts(); + Log.Verbose("[FONT] RebuildFontsInternal() detaching"); this.scene.OnNewRenderFrame -= RebuildFontsInternal; this.scene.InvalidateFonts(); + Log.Verbose("[FONT] Font Rebuild OK!"); + this.isRebuildingFonts = false; } diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index 5cb58dc64..b94474483 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -120,8 +120,11 @@ namespace Dalamud.Interface /// This will invoke any handlers and ensure that any loaded fonts are /// ready to be used on the next UI frame. /// - public void RebuildFonts() => + public void RebuildFonts() + { + Log.Verbose("[FONT] {0} plugin is initiating FONT REBUILD", this.namespaceName); this.dalamud.InterfaceManager.RebuildFonts(); + } /// /// Event that is fired when the plugin should open its configuration interface.