mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 22:17:22 +01:00
use fixed width icon handle, update deps
This commit is contained in:
parent
694a88931a
commit
6054a7b7e8
2 changed files with 8 additions and 40 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue