mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +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 readonly SwapChainVtableResolver address;
|
||||||
private RawDX11Scene? scene;
|
private RawDX11Scene? scene;
|
||||||
|
|
||||||
private GameFontHandle? axisFontHandle;
|
private GameFontHandle[] axisFontHandles;
|
||||||
private bool overwriteAllNotoGlyphsWithAxis;
|
private bool overwriteAllNotoGlyphsWithAxis;
|
||||||
|
|
||||||
// can't access imgui IO before first present call
|
// can't access imgui IO before first present call
|
||||||
|
|
@ -353,16 +353,17 @@ namespace Dalamud.Interface.Internal
|
||||||
/// <returns>Requets handle.</returns>
|
/// <returns>Requets handle.</returns>
|
||||||
public SpecialGlyphRequest NewFontSizeRef(float size, List<Tuple<ushort, ushort>> ranges)
|
public SpecialGlyphRequest NewFontSizeRef(float size, List<Tuple<ushort, ushort>> ranges)
|
||||||
{
|
{
|
||||||
var allContained = true;
|
var allContained = false;
|
||||||
var fonts = ImGui.GetIO().Fonts.Fonts;
|
var fonts = ImGui.GetIO().Fonts.Fonts;
|
||||||
ImFontPtr foundFont = null;
|
ImFontPtr foundFont = null;
|
||||||
unsafe
|
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))
|
if (!this.glyphRequests.Any(x => x.FontInternal.NativePtr == fonts[i].NativePtr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
allContained = true;
|
||||||
foreach (var range in ranges)
|
foreach (var range in ranges)
|
||||||
{
|
{
|
||||||
if (!allContained)
|
if (!allContained)
|
||||||
|
|
@ -418,12 +419,16 @@ namespace Dalamud.Interface.Internal
|
||||||
var configuration = Service<DalamudConfiguration>.Get();
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
this.overwriteAllNotoGlyphsWithAxis = configuration.UseAxisFontsFromGame;
|
this.overwriteAllNotoGlyphsWithAxis = configuration.UseAxisFontsFromGame;
|
||||||
|
|
||||||
var currentFamilyAndSize = GameFontStyle.GetRecommendedFamilyAndSize(GameFontFamily.Axis, this.axisFontHandle?.Style.Size ?? 0f);
|
if (this.axisFontHandles == null)
|
||||||
var expectedFamilyAndSize = GameFontStyle.GetRecommendedFamilyAndSize(GameFontFamily.Axis, DefaultFontSizePt * ImGui.GetIO().FontGlobalScale);
|
|
||||||
if (currentFamilyAndSize != expectedFamilyAndSize)
|
|
||||||
{
|
{
|
||||||
this.axisFontHandle?.Dispose();
|
this.axisFontHandles = new GameFontHandle[]
|
||||||
this.axisFontHandle = Service<GameFontManager>.Get().NewFontRef(new(expectedFamilyAndSize));
|
{
|
||||||
|
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();
|
List<Tuple<ushort, ushort>> codepointRanges = new();
|
||||||
codepointRanges.Add(Tuple.Create(Fallback1Codepoint, Fallback1Codepoint));
|
codepointRanges.Add(Tuple.Create(Fallback1Codepoint, Fallback1Codepoint));
|
||||||
codepointRanges.Add(Tuple.Create(Fallback2Codepoint, Fallback2Codepoint));
|
codepointRanges.Add(Tuple.Create(Fallback2Codepoint, Fallback2Codepoint));
|
||||||
|
|
||||||
// ImGui default ellipsis characters
|
// ImGui default ellipsis characters
|
||||||
codepointRanges.Add(Tuple.Create<ushort, ushort>(0x2026, 0x2026));
|
codepointRanges.Add(Tuple.Create<ushort, ushort>(0x2026, 0x2026));
|
||||||
codepointRanges.Add(Tuple.Create<ushort, ushort>(0x0085, 0x0085));
|
codepointRanges.Add(Tuple.Create<ushort, ushort>(0x0085, 0x0085));
|
||||||
|
|
@ -736,14 +741,24 @@ namespace Dalamud.Interface.Internal
|
||||||
if (font.NativePtr == MonoFont.NativePtr)
|
if (font.NativePtr == MonoFont.NativePtr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (this.overwriteAllNotoGlyphsWithAxis)
|
var axisFont = this.axisFontHandles[^1];
|
||||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, font, false, false);
|
for (var i = this.axisFontHandles.Length - 2; i >= 0; i--)
|
||||||
else
|
{
|
||||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, font, false, false, 0xE020, 0xE0DB);
|
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
|
if (this.overwriteAllNotoGlyphsWithAxis)
|
||||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, DefaultFont, true, false);
|
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
|
// Fill missing glyphs in MonoFont from DefaultFont
|
||||||
GameFontManager.CopyGlyphsAcrossFonts(DefaultFont, MonoFont, true, false);
|
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);
|
this.specialGlyphRequests[entry.Name] = fontHandle = Service<InterfaceManager>.Get().NewFontSizeRef(TargetFontSizePx, entry.Name);
|
||||||
|
|
||||||
ImGui.PushFont(fontHandle.Font);
|
ImGui.PushFont(fontHandle.Font);
|
||||||
|
ImGui.SetWindowFontScale(TargetFontSizePx / fontHandle.Size);
|
||||||
|
|
||||||
var scale = ImGui.GetIO().FontGlobalScale;
|
var scale = ImGui.GetIO().FontGlobalScale;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue