use fixed width icon handle, update deps

This commit is contained in:
Stanley Dimant
2024-05-20 11:40:56 +02:00
parent 694a88931a
commit 6054a7b7e8
2 changed files with 8 additions and 40 deletions

View File

@@ -33,21 +33,21 @@
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="Downloader" Version="3.0.6" />
<PackageReference Include="lz4net" Version="1.0.15.93" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.152">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Penumbra.Api" Version="1.0.14" />
<PackageReference Include="Penumbra.Api" Version="5.0.0" />
<PackageReference Include="Penumbra.String" Version="1.0.4" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.3" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.21.0.86780">
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.25.0.90414">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.4.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.2" />
</ItemGroup>
<PropertyGroup>

View File

@@ -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();
}