mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 21:24:16 +01:00
Add italic/bold to font settings and make AXIS as a checkbox in settings window
This commit is contained in:
parent
f3588dfe23
commit
17c77e6bfd
10 changed files with 598 additions and 262 deletions
|
|
@ -57,8 +57,7 @@ namespace Dalamud.Interface.Internal
|
|||
private readonly SwapChainVtableResolver address;
|
||||
private RawDX11Scene? scene;
|
||||
|
||||
private GameFont overwriteDefaultFontFromGameFont = GameFont.Undefined;
|
||||
private GameFontHandle? overwriteDefaultFontFromGameFontHandle;
|
||||
private GameFontHandle? axisFontHandle;
|
||||
|
||||
// can't access imgui IO before first present call
|
||||
private bool lastWantCapture = false;
|
||||
|
|
@ -313,16 +312,7 @@ namespace Dalamud.Interface.Internal
|
|||
if (!this.isRebuildingFonts)
|
||||
{
|
||||
Log.Verbose("[FONT] RebuildFonts() trigger");
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
if (this.overwriteDefaultFontFromGameFont != configuration.DefaultFontFromGame)
|
||||
{
|
||||
this.overwriteDefaultFontFromGameFont = configuration.DefaultFontFromGame;
|
||||
this.overwriteDefaultFontFromGameFontHandle?.Dispose();
|
||||
if (configuration.DefaultFontFromGame == GameFont.Undefined)
|
||||
this.overwriteDefaultFontFromGameFontHandle = null;
|
||||
else
|
||||
this.overwriteDefaultFontFromGameFontHandle = Service<GameFontManager>.Get().NewFontRef(configuration.DefaultFontFromGame);
|
||||
}
|
||||
this.SetAxisFonts();
|
||||
|
||||
this.isRebuildingFonts = true;
|
||||
this.scene.OnNewRenderFrame += this.RebuildFontsInternal;
|
||||
|
|
@ -342,6 +332,26 @@ namespace Dalamud.Interface.Internal
|
|||
Util.Fatal($"One or more files required by XIVLauncher were not found.\nPlease restart and report this error if it occurs again.\n\n{path}", "Error");
|
||||
}
|
||||
|
||||
private void SetAxisFonts()
|
||||
{
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
if (configuration.UseAxisFontsFromGame)
|
||||
{
|
||||
var currentFamilyAndSize = GameFontStyle.GetRecommendedFamilyAndSize(GameFontFamily.Axis, this.axisFontHandle?.Style.Size ?? 0f);
|
||||
var expectedFamilyAndSize = GameFontStyle.GetRecommendedFamilyAndSize(GameFontFamily.Axis, 12 * ImGui.GetIO().FontGlobalScale);
|
||||
if (currentFamilyAndSize == expectedFamilyAndSize)
|
||||
return;
|
||||
|
||||
this.axisFontHandle?.Dispose();
|
||||
this.axisFontHandle = Service<GameFontManager>.Get().NewFontRef(new(expectedFamilyAndSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.axisFontHandle?.Dispose();
|
||||
this.axisFontHandle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE(goat): When hooking ReShade DXGISwapChain::runtime_present, this is missing the syncInterval arg.
|
||||
* Seems to work fine regardless, I guess, so whatever.
|
||||
|
|
@ -403,15 +413,7 @@ namespace Dalamud.Interface.Internal
|
|||
this.scene.OnBuildUI += this.Display;
|
||||
this.scene.OnNewInputFrame += this.OnNewInputFrame;
|
||||
|
||||
if (this.overwriteDefaultFontFromGameFont != configuration.DefaultFontFromGame)
|
||||
{
|
||||
this.overwriteDefaultFontFromGameFont = configuration.DefaultFontFromGame;
|
||||
this.overwriteDefaultFontFromGameFontHandle?.Dispose();
|
||||
if (configuration.DefaultFontFromGame == GameFont.Undefined)
|
||||
this.overwriteDefaultFontFromGameFontHandle = null;
|
||||
else
|
||||
this.overwriteDefaultFontFromGameFontHandle = Service<GameFontManager>.Get().NewFontRef(configuration.DefaultFontFromGame);
|
||||
}
|
||||
this.SetAxisFonts();
|
||||
|
||||
this.SetupFonts();
|
||||
|
||||
|
|
@ -591,7 +593,7 @@ namespace Dalamud.Interface.Internal
|
|||
ImGui.GetIO().Fonts.Build();
|
||||
|
||||
gameFontManager.AfterBuildFonts();
|
||||
GameFontManager.CopyGlyphsAcrossFonts(this.overwriteDefaultFontFromGameFontHandle?.Get(), DefaultFont, false, true);
|
||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, DefaultFont, false, true);
|
||||
|
||||
Log.Verbose("[FONT] Invoke OnAfterBuildFonts");
|
||||
this.AfterBuildFonts?.Invoke();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue