mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Always keep all AXIS fonts in memory
This commit is contained in:
parent
14dfbf7bcf
commit
f5c75e4cd5
2 changed files with 32 additions and 16 deletions
|
|
@ -64,7 +64,7 @@ namespace Dalamud.Interface.Internal
|
|||
private readonly SwapChainVtableResolver address;
|
||||
private RawDX11Scene? scene;
|
||||
|
||||
private GameFontHandle? axisFontHandle;
|
||||
private GameFontHandle[] axisFontHandles;
|
||||
private bool overwriteAllNotoGlyphsWithAxis;
|
||||
|
||||
// can't access imgui IO before first present call
|
||||
|
|
@ -353,16 +353,17 @@ namespace Dalamud.Interface.Internal
|
|||
/// <returns>Requets handle.</returns>
|
||||
public SpecialGlyphRequest NewFontSizeRef(float size, List<Tuple<ushort, ushort>> ranges)
|
||||
{
|
||||
var allContained = true;
|
||||
var allContained = false;
|
||||
var fonts = ImGui.GetIO().Fonts.Fonts;
|
||||
ImFontPtr foundFont = null;
|
||||
unsafe
|
||||
{
|
||||
for (int i = 0, i_ = fonts.Size; allContained && i < i_; i++)
|
||||
for (int i = 0, i_ = fonts.Size; i < i_; i++)
|
||||
{
|
||||
if (!this.glyphRequests.Any(x => x.FontInternal.NativePtr == fonts[i].NativePtr))
|
||||
continue;
|
||||
|
||||
allContained = true;
|
||||
foreach (var range in ranges)
|
||||
{
|
||||
if (!allContained)
|
||||
|
|
@ -418,12 +419,16 @@ namespace Dalamud.Interface.Internal
|
|||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
this.overwriteAllNotoGlyphsWithAxis = configuration.UseAxisFontsFromGame;
|
||||
|
||||
var currentFamilyAndSize = GameFontStyle.GetRecommendedFamilyAndSize(GameFontFamily.Axis, this.axisFontHandle?.Style.Size ?? 0f);
|
||||
var expectedFamilyAndSize = GameFontStyle.GetRecommendedFamilyAndSize(GameFontFamily.Axis, DefaultFontSizePt * ImGui.GetIO().FontGlobalScale);
|
||||
if (currentFamilyAndSize != expectedFamilyAndSize)
|
||||
if (this.axisFontHandles == null)
|
||||
{
|
||||
this.axisFontHandle?.Dispose();
|
||||
this.axisFontHandle = Service<GameFontManager>.Get().NewFontRef(new(expectedFamilyAndSize));
|
||||
this.axisFontHandles = new GameFontHandle[]
|
||||
{
|
||||
Service<GameFontManager>.Get().NewFontRef(new(GameFontFamilyAndSize.Axis96)),
|
||||
Service<GameFontManager>.Get().NewFontRef(new(GameFontFamilyAndSize.Axis12)),
|
||||
Service<GameFontManager>.Get().NewFontRef(new(GameFontFamilyAndSize.Axis14)),
|
||||
Service<GameFontManager>.Get().NewFontRef(new(GameFontFamilyAndSize.Axis18)),
|
||||
Service<GameFontManager>.Get().NewFontRef(new(GameFontFamilyAndSize.Axis36)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -659,7 +664,7 @@ namespace Dalamud.Interface.Internal
|
|||
List<Tuple<ushort, ushort>> codepointRanges = new();
|
||||
codepointRanges.Add(Tuple.Create(Fallback1Codepoint, Fallback1Codepoint));
|
||||
codepointRanges.Add(Tuple.Create(Fallback2Codepoint, Fallback2Codepoint));
|
||||
|
||||
|
||||
// ImGui default ellipsis characters
|
||||
codepointRanges.Add(Tuple.Create<ushort, ushort>(0x2026, 0x2026));
|
||||
codepointRanges.Add(Tuple.Create<ushort, ushort>(0x0085, 0x0085));
|
||||
|
|
@ -736,14 +741,24 @@ namespace Dalamud.Interface.Internal
|
|||
if (font.NativePtr == MonoFont.NativePtr)
|
||||
continue;
|
||||
|
||||
if (this.overwriteAllNotoGlyphsWithAxis)
|
||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, font, false, false);
|
||||
else
|
||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, font, false, false, 0xE020, 0xE0DB);
|
||||
}
|
||||
var axisFont = this.axisFontHandles[^1];
|
||||
for (var i = this.axisFontHandles.Length - 2; i >= 0; i--)
|
||||
{
|
||||
if (this.axisFontHandles[i].Style.Size >= (font.FontSize - 1) * fontScale * 3 / 4)
|
||||
axisFont = this.axisFontHandles[i];
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// Fill missing glyphs in DefaultFont from Axis
|
||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, DefaultFont, true, false);
|
||||
if (this.overwriteAllNotoGlyphsWithAxis)
|
||||
GameFontManager.CopyGlyphsAcrossFonts(axisFont.ImFont, font, false, false);
|
||||
else
|
||||
GameFontManager.CopyGlyphsAcrossFonts(axisFont.ImFont, font, false, false, 0xE020, 0xE0DB);
|
||||
|
||||
// Fill missing glyphs in DefaultFont from Axis
|
||||
if (font.NativePtr == DefaultFont.NativePtr)
|
||||
GameFontManager.CopyGlyphsAcrossFonts(axisFont.ImFont, DefaultFont, true, false);
|
||||
}
|
||||
|
||||
// Fill missing glyphs in MonoFont from DefaultFont
|
||||
GameFontManager.CopyGlyphsAcrossFonts(DefaultFont, MonoFont, true, false);
|
||||
|
|
|
|||
|
|
@ -245,6 +245,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
this.specialGlyphRequests[entry.Name] = fontHandle = Service<InterfaceManager>.Get().NewFontSizeRef(TargetFontSizePx, entry.Name);
|
||||
|
||||
ImGui.PushFont(fontHandle.Font);
|
||||
ImGui.SetWindowFontScale(TargetFontSizePx / fontHandle.Size);
|
||||
|
||||
var scale = ImGui.GetIO().FontGlobalScale;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue