mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 12:53:41 +01:00
Move PostPromotion modification functions to PostBuild
These changes are done to ensure that `IFontHandle.Lock` will be guaranteed to obtain a fully built font that will not be modified any further (unless `PostPromotion` is being used for modifying fonts, which should not be done by clients.)
* Moved `CopyGlyphsAcrossFonts` and `BuildLookupTable` from `PostPromotion` to `PostBuild` build toolkit.
* `IFontAtlasBuildToolkit`: Added `GetFont` to enable retrieving font corresponding to a handle being built.
* `InterfaceManager`: Use `OnPostBuild` for copying glyphs from Mono to Default.
* `FontAtlasBuildStep`:
* Removed `Invalid` to prevent an unnecessary switch-case warnings.
* Added contracts on when `IFontAtlas.BuildStepChanged` will be called.
This commit is contained in:
parent
5479149e79
commit
fb8beb9370
8 changed files with 180 additions and 136 deletions
|
|
@ -717,28 +717,28 @@ internal class InterfaceManager : IDisposable, IServiceType
|
|||
tk => tk.AddDalamudAssetFont(
|
||||
DalamudAsset.InconsolataRegular,
|
||||
new() { SizePx = DefaultFontSizePx })));
|
||||
this.dalamudAtlas.BuildStepChange += e => e.OnPostPromotion(
|
||||
tk =>
|
||||
{
|
||||
// Note: the first call of this function is done outside the main thread; this is expected.
|
||||
// Do not use DefaultFont, IconFont, and MonoFont.
|
||||
// Use font handles directly.
|
||||
|
||||
using var defaultFont = this.DefaultFontHandle.Lock();
|
||||
using var monoFont = this.MonoFontHandle.Lock();
|
||||
|
||||
// Fill missing glyphs in MonoFont from DefaultFont
|
||||
tk.CopyGlyphsAcrossFonts(defaultFont, monoFont, true);
|
||||
|
||||
// Update default font
|
||||
unsafe
|
||||
this.dalamudAtlas.BuildStepChange += e => e
|
||||
.OnPostBuild(
|
||||
tk =>
|
||||
{
|
||||
ImGui.GetIO().NativePtr->FontDefault = defaultFont;
|
||||
}
|
||||
// Fill missing glyphs in MonoFont from DefaultFont.
|
||||
tk.CopyGlyphsAcrossFonts(
|
||||
tk.GetFont(this.DefaultFontHandle),
|
||||
tk.GetFont(this.MonoFontHandle),
|
||||
missingOnly: true);
|
||||
})
|
||||
.OnPostPromotion(
|
||||
tk =>
|
||||
{
|
||||
// Update the ImGui default font.
|
||||
unsafe
|
||||
{
|
||||
ImGui.GetIO().NativePtr->FontDefault = tk.GetFont(this.DefaultFontHandle);
|
||||
}
|
||||
|
||||
// Broadcast to auto-rebuilding instances
|
||||
this.AfterBuildFonts?.Invoke();
|
||||
});
|
||||
// Broadcast to auto-rebuilding instances.
|
||||
this.AfterBuildFonts?.Invoke();
|
||||
});
|
||||
}
|
||||
|
||||
// This will wait for scene on its own. We just wait for this.dalamudAtlas.BuildTask in this.InitScene.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue