From 6054a7b7e85c89639d4ed7d2c2ba4f124fee3f73 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Mon, 20 May 2024 11:40:56 +0200 Subject: [PATCH] use fixed width icon handle, update deps --- MareSynchronos/MareSynchronos.csproj | 14 ++++++------ MareSynchronos/UI/UISharedService.cs | 34 +--------------------------- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/MareSynchronos/MareSynchronos.csproj b/MareSynchronos/MareSynchronos.csproj index ab4c315..833774a 100644 --- a/MareSynchronos/MareSynchronos.csproj +++ b/MareSynchronos/MareSynchronos.csproj @@ -33,21 +33,21 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/MareSynchronos/UI/UISharedService.cs b/MareSynchronos/UI/UISharedService.cs index f1a1876..a7bc5c3 100644 --- a/MareSynchronos/UI/UISharedService.cs +++ b/MareSynchronos/UI/UISharedService.cs @@ -113,38 +113,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase })); }); GameFont = _pluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.Axis12)); - IconFont = _pluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e => - { - e.OnPreBuild(tk => tk.AddFontAwesomeIconFont(new() - { - SizePx = _pluginInterface.UiBuilder.DefaultFontSpec.SizePx, - GlyphMinAdvanceX = _pluginInterface.UiBuilder.DefaultFontSpec.SizePx, - GlyphMaxAdvanceX = _pluginInterface.UiBuilder.DefaultFontSpec.SizePx - })); - e.OnPostBuild(tk => - { - var font = tk.Font; - var nsize = font.FontSize; - var glyphs = font.GlyphsWrapped(); - foreach (ref var glyph in glyphs.DataSpan) - { - var ratio = 1f; - if (glyph.X1 - glyph.X0 > nsize) - ratio = Math.Max(ratio, (glyph.X1 - glyph.X0) / nsize); - if (glyph.Y1 - glyph.Y0 > nsize) - ratio = Math.Max(ratio, (glyph.Y1 - glyph.Y0) / nsize); - var w = MathF.Round((glyph.X1 - glyph.X0) / ratio, MidpointRounding.ToZero); - var h = MathF.Round((glyph.Y1 - glyph.Y0) / ratio, MidpointRounding.AwayFromZero); - glyph.X0 = MathF.Round((nsize - w) / 2f, MidpointRounding.ToZero); - glyph.Y0 = MathF.Round((nsize - h) / 2f, MidpointRounding.AwayFromZero); - glyph.X1 = glyph.X0 + w; - glyph.Y1 = glyph.Y0 + h; - glyph.AdvanceX = nsize; - } - - tk.BuildLookupTable(font); - }); - }); + IconFont = _pluginInterface.UiBuilder.IconFontFixedWidthHandle; } public ApiController ApiController => _apiController; @@ -872,7 +841,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase base.Dispose(disposing); - IconFont.Dispose(); UidFont.Dispose(); GameFont.Dispose(); }