From 2315f10d91fbb17788a3730ddcf66e364d7db058 Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Sun, 17 May 2026 17:01:17 +0200 Subject: [PATCH] refactor(fonts): reuse Dalamud IconFontFixedWidthHandle for FontAwesome Drop the custom NewDelegateFontHandle that built our own FontAwesome atlas slot and reuse Dalamud's UiBuilder.IconFontFixedWidthHandle instead. One less delegate-build step in the ctor, and the handle is host-managed so Dispose() leaves it alone. The pre-cycle icon inventory verified that every site we push the FontAwesome font for renders an icon that is present in the host's fixed-width handle glyph range, so no rendering site changes. --- HellionChat/FontManager.cs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/HellionChat/FontManager.cs b/HellionChat/FontManager.cs index 88d9a42..1ceb3ea 100644 --- a/HellionChat/FontManager.cs +++ b/HellionChat/FontManager.cs @@ -13,15 +13,17 @@ namespace HellionChat; // AddFontWithFallback); a ctor-injected ILogger would not be reachable // from those scopes, so the class stays on Plugin.LogProxy. // -// Hybrid handle model: Axis, AxisItalic and FontAwesome are tied to the -// game's current font state and never change for the lifetime of the -// plugin, so they are init-only. RegularFont and ItalicFont depend on -// user-toggleable settings and get replaced live via RebuildDelegateFonts -// when those settings change; they stay as mutable nullable fields. +// Hybrid handle model: Axis and AxisItalic mirror the game's current +// font state and are init-only. FontAwesome reuses Dalamud's UiBuilder +// fixed-width icon handle and is likewise init-only. RegularFont and +// ItalicFont depend on user-toggleable settings and get replaced live +// via RebuildDelegateFonts when those settings change; they stay as +// mutable nullable fields. // -// All five handles register inside a single SuppressAutoRebuild block in -// the ctor so the font atlas only rebuilds once for the whole plugin start -// instead of once per handle. +// The four atlas-owned handles register inside a single +// SuppressAutoRebuild block so the font atlas only rebuilds once for the +// whole plugin start instead of once per handle. FontAwesome lives +// outside that accounting because the UiBuilder already owns it. public sealed class FontManager : IDisposable { private readonly IDalamudPluginInterface _pluginInterface; @@ -83,13 +85,7 @@ public sealed class FontManager : IDisposable } ); - FontAwesome = atlas.NewDelegateFontHandle(e => - { - e.OnPreBuild(tk => - tk.AddFontAwesomeIconFont(new SafeFontConfig { SizePx = GetFontSize() }) - ); - e.OnPostBuild(tk => tk.FitRatio(tk.Font)); - }); + FontAwesome = _pluginInterface.UiBuilder.IconFontFixedWidthHandle; RegularFont = BuildRegularFontHandle(atlas); @@ -181,7 +177,8 @@ public sealed class FontManager : IDisposable { Axis.Dispose(); AxisItalic.Dispose(); - FontAwesome.Dispose(); + // FontAwesome is shared with the UiBuilder; the host owns its + // lifetime, so the plugin must not dispose it. RegularFont?.Dispose(); ItalicFont?.Dispose(); }