mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-16 21:07:43 +01:00
chore: add only-monospace font mode to exclude fonts as a failure source
This commit is contained in:
parent
641c7d7fc0
commit
37cbdb7b3e
3 changed files with 321 additions and 200 deletions
|
|
@ -37,6 +37,11 @@ namespace Dalamud.Configuration.Internal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool DalamudDoContextMenu { get; } = GetEnvironmentVariable("DALAMUD_ENABLE_CONTEXTMENU");
|
public static bool DalamudDoContextMenu { get; } = GetEnvironmentVariable("DALAMUD_ENABLE_CONTEXTMENU");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether or not Dalamud context menus should be disabled.
|
||||||
|
/// </summary>
|
||||||
|
public static bool DalamudFontFallback { get; } = GetEnvironmentVariable("DALAMUD_FONT_FALLBACK");
|
||||||
|
|
||||||
private static bool GetEnvironmentVariable(string name)
|
private static bool GetEnvironmentVariable(string name)
|
||||||
=> bool.Parse(Environment.GetEnvironmentVariable(name) ?? "false");
|
=> bool.Parse(Environment.GetEnvironmentVariable(name) ?? "false");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Data;
|
using Dalamud.Data;
|
||||||
using Dalamud.Interface.Internal;
|
using Dalamud.Interface.Internal;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
@ -315,23 +315,30 @@ namespace Dalamud.Interface.GameFonts
|
||||||
|
|
||||||
var font = io.Fonts.AddFontDefault(fontConfig);
|
var font = io.Fonts.AddFontDefault(fontConfig);
|
||||||
|
|
||||||
this.fonts[style] = font;
|
if (EnvironmentConfiguration.DalamudFontFallback)
|
||||||
foreach (var glyph in fdt.Glyphs)
|
|
||||||
{
|
{
|
||||||
var c = glyph.Char;
|
this.fonts[style] = InterfaceManager.MonoFont;
|
||||||
if (c < 32 || c >= 0xFFFF)
|
}
|
||||||
continue;
|
else
|
||||||
|
{
|
||||||
|
this.fonts[style] = font;
|
||||||
|
foreach (var glyph in fdt.Glyphs)
|
||||||
|
{
|
||||||
|
var c = glyph.Char;
|
||||||
|
if (c < 32 || c >= 0xFFFF)
|
||||||
|
continue;
|
||||||
|
|
||||||
var widthAdjustment = style.CalculateBaseWidthAdjustment(fdt, glyph);
|
var widthAdjustment = style.CalculateBaseWidthAdjustment(fdt, glyph);
|
||||||
rectIds[c] = Tuple.Create(
|
rectIds[c] = Tuple.Create(
|
||||||
io.Fonts.AddCustomRectFontGlyph(
|
io.Fonts.AddCustomRectFontGlyph(
|
||||||
font,
|
font,
|
||||||
c,
|
c,
|
||||||
glyph.BoundingWidth + widthAdjustment + 1,
|
glyph.BoundingWidth + widthAdjustment + 1,
|
||||||
glyph.BoundingHeight + 1,
|
glyph.BoundingHeight + 1,
|
||||||
glyph.AdvanceWidth,
|
glyph.AdvanceWidth,
|
||||||
new Vector2(0, glyph.CurrentOffsetY)),
|
new Vector2(0, glyph.CurrentOffsetY)),
|
||||||
glyph);
|
glyph);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.ClientState.GamePad;
|
using Dalamud.Game.ClientState.GamePad;
|
||||||
|
|
@ -26,6 +25,8 @@ using ImGuiScene;
|
||||||
using PInvoke;
|
using PInvoke;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using SharpDX.Direct3D11;
|
using SharpDX.Direct3D11;
|
||||||
|
using Silk.NET.SDL;
|
||||||
|
using Thread = System.Threading.Thread;
|
||||||
|
|
||||||
// general dev notes, here because it's easiest
|
// general dev notes, here because it's easiest
|
||||||
/*
|
/*
|
||||||
|
|
@ -45,11 +46,14 @@ namespace Dalamud.Interface.Internal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class InterfaceManager : IDisposable
|
internal class InterfaceManager : IDisposable
|
||||||
{
|
{
|
||||||
private const float MinimumFallbackFontSizePt = 9.6f; // Game's minimum AXIS font size
|
private const float MinimumFallbackFontSizePt = 9.6f; // Game's minimum AXIS font size
|
||||||
private const float MinimumFallbackFontSizePx = MinimumFallbackFontSizePt * 4.0f / 3.0f;
|
private const float MinimumFallbackFontSizePx = MinimumFallbackFontSizePt * 4.0f / 3.0f;
|
||||||
private const float DefaultFontSizePt = 12.0f;
|
private const float DefaultFontSizePt = 12.0f;
|
||||||
private const float DefaultFontSizePx = DefaultFontSizePt * 4.0f / 3.0f;
|
private const float DefaultFontSizePx = DefaultFontSizePt * 4.0f / 3.0f;
|
||||||
private const ushort Fallback1Codepoint = 0x3013; // Geta mark; FFXIV uses this to indicate that a glyph is missing.
|
|
||||||
|
private const ushort
|
||||||
|
Fallback1Codepoint = 0x3013; // Geta mark; FFXIV uses this to indicate that a glyph is missing.
|
||||||
|
|
||||||
private const ushort Fallback2Codepoint = '-'; // FFXIV uses dash if Geta mark is unavailable.
|
private const ushort Fallback2Codepoint = '-'; // FFXIV uses dash if Geta mark is unavailable.
|
||||||
|
|
||||||
private readonly string rtssPath;
|
private readonly string rtssPath;
|
||||||
|
|
@ -105,9 +109,11 @@ namespace Dalamud.Interface.Internal
|
||||||
Log.Error(e, "RTSS Free failed");
|
Log.Error(e, "RTSS Free failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setCursorHook = Hook<SetCursorDelegate>.FromSymbol("user32.dll", "SetCursor", this.SetCursorDetour, true);
|
this.setCursorHook =
|
||||||
|
Hook<SetCursorDelegate>.FromSymbol("user32.dll", "SetCursor", this.SetCursorDetour, true);
|
||||||
this.presentHook = new Hook<PresentDelegate>(this.address.Present, this.PresentDetour);
|
this.presentHook = new Hook<PresentDelegate>(this.address.Present, this.PresentDetour);
|
||||||
this.resizeBuffersHook = new Hook<ResizeBuffersDelegate>(this.address.ResizeBuffers, this.ResizeBuffersDetour);
|
this.resizeBuffersHook =
|
||||||
|
new Hook<ResizeBuffersDelegate>(this.address.ResizeBuffers, this.ResizeBuffersDetour);
|
||||||
|
|
||||||
var setCursorAddress = this.setCursorHook?.Address ?? IntPtr.Zero;
|
var setCursorAddress = this.setCursorHook?.Address ?? IntPtr.Zero;
|
||||||
|
|
||||||
|
|
@ -121,7 +127,8 @@ namespace Dalamud.Interface.Internal
|
||||||
private delegate IntPtr PresentDelegate(IntPtr swapChain, uint syncInterval, uint presentFlags);
|
private delegate IntPtr PresentDelegate(IntPtr swapChain, uint syncInterval, uint presentFlags);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||||
private delegate IntPtr ResizeBuffersDelegate(IntPtr swapChain, uint bufferCount, uint width, uint height, uint newFormat, uint swapChainFlags);
|
private delegate IntPtr ResizeBuffersDelegate(
|
||||||
|
IntPtr swapChain, uint bufferCount, uint width, uint height, uint newFormat, uint swapChainFlags);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||||
private delegate IntPtr SetCursorDelegate(IntPtr hCursor);
|
private delegate IntPtr SetCursorDelegate(IntPtr hCursor);
|
||||||
|
|
@ -236,7 +243,9 @@ namespace Dalamud.Interface.Internal
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the font gamma value to use.
|
/// Gets the font gamma value to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float FontGamma => Math.Max(0.1f, this.FontGammaOverride.GetValueOrDefault(Service<DalamudConfiguration>.Get().FontGammaLevel));
|
public float FontGamma =>
|
||||||
|
Math.Max(
|
||||||
|
0.1f, this.FontGammaOverride.GetValueOrDefault(Service<DalamudConfiguration>.Get().FontGammaLevel));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether to override configuration for FontResolutionLevel.
|
/// Gets or sets a value indicating whether to override configuration for FontResolutionLevel.
|
||||||
|
|
@ -246,7 +255,8 @@ namespace Dalamud.Interface.Internal
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating the level of font resolution.
|
/// Gets a value indicating the level of font resolution.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int FontResolutionLevel => this.FontResolutionLevelOverride ?? Service<DalamudConfiguration>.Get().FontResolutionLevel;
|
public int FontResolutionLevel =>
|
||||||
|
this.FontResolutionLevelOverride ?? Service<DalamudConfiguration>.Get().FontResolutionLevel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enable this module.
|
/// Enable this module.
|
||||||
|
|
@ -450,7 +460,9 @@ namespace Dalamud.Interface.Internal
|
||||||
|
|
||||||
private static void ShowFontError(string path)
|
private static void ShowFontError(string path)
|
||||||
{
|
{
|
||||||
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");
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -476,7 +488,8 @@ namespace Dalamud.Interface.Internal
|
||||||
IntPtr.Zero,
|
IntPtr.Zero,
|
||||||
"Dalamud plugins require the Microsoft Visual C++ Redistributable to be installed.\nPlease install the runtime from the official Microsoft website or disable Dalamud.\n\nDo you want to download the redistributable now?",
|
"Dalamud plugins require the Microsoft Visual C++ Redistributable to be installed.\nPlease install the runtime from the official Microsoft website or disable Dalamud.\n\nDo you want to download the redistributable now?",
|
||||||
"Dalamud Error",
|
"Dalamud Error",
|
||||||
User32.MessageBoxOptions.MB_YESNO | User32.MessageBoxOptions.MB_TOPMOST | User32.MessageBoxOptions.MB_ICONERROR);
|
User32.MessageBoxOptions.MB_YESNO | User32.MessageBoxOptions.MB_TOPMOST |
|
||||||
|
User32.MessageBoxOptions.MB_ICONERROR);
|
||||||
|
|
||||||
if (res == User32.MessageBoxResult.IDYES)
|
if (res == User32.MessageBoxResult.IDYES)
|
||||||
{
|
{
|
||||||
|
|
@ -494,14 +507,16 @@ namespace Dalamud.Interface.Internal
|
||||||
var startInfo = Service<DalamudStartInfo>.Get();
|
var startInfo = Service<DalamudStartInfo>.Get();
|
||||||
var configuration = Service<DalamudConfiguration>.Get();
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
|
|
||||||
var iniFileInfo = new FileInfo(Path.Combine(Path.GetDirectoryName(startInfo.ConfigurationPath), "dalamudUI.ini"));
|
var iniFileInfo =
|
||||||
|
new FileInfo(Path.Combine(Path.GetDirectoryName(startInfo.ConfigurationPath), "dalamudUI.ini"));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (iniFileInfo.Length > 1200000)
|
if (iniFileInfo.Length > 1200000)
|
||||||
{
|
{
|
||||||
Log.Warning("dalamudUI.ini was over 1mb, deleting");
|
Log.Warning("dalamudUI.ini was over 1mb, deleting");
|
||||||
iniFileInfo.CopyTo(Path.Combine(iniFileInfo.DirectoryName, $"dalamudUI-{DateTimeOffset.Now.ToUnixTimeSeconds()}.ini"));
|
iniFileInfo.CopyTo(Path.Combine(iniFileInfo.DirectoryName,
|
||||||
|
$"dalamudUI-{DateTimeOffset.Now.ToUnixTimeSeconds()}.ini"));
|
||||||
iniFileInfo.Delete();
|
iniFileInfo.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -518,9 +533,11 @@ namespace Dalamud.Interface.Internal
|
||||||
|
|
||||||
StyleModel.TransferOldModels();
|
StyleModel.TransferOldModels();
|
||||||
|
|
||||||
if (configuration.SavedStyles == null || configuration.SavedStyles.All(x => x.Name != StyleModelV1.DalamudStandard.Name))
|
if (configuration.SavedStyles == null ||
|
||||||
|
configuration.SavedStyles.All(x => x.Name != StyleModelV1.DalamudStandard.Name))
|
||||||
{
|
{
|
||||||
configuration.SavedStyles = new List<StyleModel> { StyleModelV1.DalamudStandard, StyleModelV1.DalamudClassic };
|
configuration.SavedStyles = new List<StyleModel>
|
||||||
|
{ StyleModelV1.DalamudStandard, StyleModelV1.DalamudClassic };
|
||||||
configuration.ChosenStyle = StyleModelV1.DalamudStandard.Name;
|
configuration.ChosenStyle = StyleModelV1.DalamudStandard.Name;
|
||||||
}
|
}
|
||||||
else if (configuration.SavedStyles.Count == 1)
|
else if (configuration.SavedStyles.Count == 1)
|
||||||
|
|
@ -608,7 +625,8 @@ namespace Dalamud.Interface.Internal
|
||||||
{
|
{
|
||||||
var configuration = Service<DalamudConfiguration>.Get();
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
|
|
||||||
if (configuration.IsDisableViewport || this.scene.SwapChain.IsFullScreen || ImGui.GetPlatformIO().Monitors.Size == 1)
|
if (configuration.IsDisableViewport || this.scene.SwapChain.IsFullScreen ||
|
||||||
|
ImGui.GetPlatformIO().Monitors.Size == 1)
|
||||||
{
|
{
|
||||||
ImGui.GetIO().ConfigFlags &= ~ImGuiConfigFlags.ViewportsEnable;
|
ImGui.GetIO().ConfigFlags &= ~ImGuiConfigFlags.ViewportsEnable;
|
||||||
return;
|
return;
|
||||||
|
|
@ -623,6 +641,8 @@ namespace Dalamud.Interface.Internal
|
||||||
/// <param name="disableBigFonts">If set, then glyphs will be loaded in smaller resolution to make all glyphs fit into given constraints.</param>
|
/// <param name="disableBigFonts">If set, then glyphs will be loaded in smaller resolution to make all glyphs fit into given constraints.</param>
|
||||||
private unsafe void SetupFonts(bool disableBigFonts = false)
|
private unsafe void SetupFonts(bool disableBigFonts = false)
|
||||||
{
|
{
|
||||||
|
var onlyLoadMono = EnvironmentConfiguration.DalamudFontFallback;
|
||||||
|
|
||||||
var gameFontManager = Service<GameFontManager>.Get();
|
var gameFontManager = Service<GameFontManager>.Get();
|
||||||
var dalamud = Service<Dalamud>.Get();
|
var dalamud = Service<Dalamud>.Get();
|
||||||
var io = ImGui.GetIO();
|
var io = ImGui.GetIO();
|
||||||
|
|
@ -670,145 +690,215 @@ namespace Dalamud.Interface.Internal
|
||||||
fontPathKr = null;
|
fontPathKr = null;
|
||||||
Log.Verbose("[FONT] fontPathKr = {0}", fontPathKr);
|
Log.Verbose("[FONT] fontPathKr = {0}", fontPathKr);
|
||||||
|
|
||||||
// Default font
|
if (onlyLoadMono)
|
||||||
Log.Verbose("[FONT] SetupFonts - Default font");
|
|
||||||
var fontInfo = new TargetFontModification(
|
|
||||||
"Default",
|
|
||||||
this.UseAxis ? TargetFontModification.AxisMode.Overwrite : TargetFontModification.AxisMode.GameGlyphsOnly,
|
|
||||||
this.UseAxis ? DefaultFontSizePx : DefaultFontSizePx + 1,
|
|
||||||
io.FontGlobalScale,
|
|
||||||
disableBigFonts);
|
|
||||||
Log.Verbose("[FONT] SetupFonts - Default corresponding AXIS size: {0}pt ({1}px)", fontInfo.SourceAxis.Style.BaseSizePt, fontInfo.SourceAxis.Style.BaseSizePx);
|
|
||||||
fontConfig.SizePixels = disableBigFonts ? Math.Min(MinimumFallbackFontSizePx, fontInfo.TargetSizePx) : fontInfo.TargetSizePx * io.FontGlobalScale;
|
|
||||||
if (this.UseAxis)
|
|
||||||
{
|
{
|
||||||
fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject();
|
// Monospace font
|
||||||
fontConfig.PixelSnapH = false;
|
Log.Verbose("[FONT] SetupFonts - Monospace font");
|
||||||
DefaultFont = ioFonts.AddFontDefault(fontConfig);
|
{
|
||||||
this.loadedFontInfo[DefaultFont] = fontInfo;
|
var fontPathMono =
|
||||||
|
Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "Inconsolata-Regular.ttf");
|
||||||
|
if (!File.Exists(fontPathMono))
|
||||||
|
ShowFontError(fontPathMono);
|
||||||
|
|
||||||
|
fontConfig.GlyphRanges = IntPtr.Zero;
|
||||||
|
fontConfig.PixelSnapH = true;
|
||||||
|
MonoFont = ioFonts.AddFontFromFileTTF(fontPathMono,
|
||||||
|
disableBigFonts
|
||||||
|
? Math.Min(MinimumFallbackFontSizePx,
|
||||||
|
DefaultFontSizePx)
|
||||||
|
: DefaultFontSizePx * io.FontGlobalScale, fontConfig);
|
||||||
|
this.loadedFontInfo[MonoFont] = new("Mono", TargetFontModification.AxisMode.GameGlyphsOnly,
|
||||||
|
DefaultFontSizePx, io.FontGlobalScale, disableBigFonts);
|
||||||
|
|
||||||
|
DefaultFont = MonoFont;
|
||||||
|
IconFont = MonoFont;
|
||||||
|
|
||||||
|
Dictionary<float, List<SpecialGlyphRequest>> extraFontRequests = new();
|
||||||
|
foreach (var extraFontRequest in this.glyphRequests)
|
||||||
|
{
|
||||||
|
if (!extraFontRequests.ContainsKey(extraFontRequest.Size))
|
||||||
|
extraFontRequests[extraFontRequest.Size] = new();
|
||||||
|
extraFontRequests[extraFontRequest.Size].Add(extraFontRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (fontSize, requests) in extraFontRequests)
|
||||||
|
{
|
||||||
|
foreach (var request in requests)
|
||||||
|
{
|
||||||
|
request.FontInternal = MonoFont;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var japaneseRangeHandle = GCHandle.Alloc(GlyphRangesJapanese.GlyphRanges, GCHandleType.Pinned);
|
// Default font
|
||||||
garbageList.Add(japaneseRangeHandle);
|
Log.Verbose("[FONT] SetupFonts - Default font");
|
||||||
|
var fontInfo = new TargetFontModification(
|
||||||
fontConfig.GlyphRanges = japaneseRangeHandle.AddrOfPinnedObject();
|
"Default",
|
||||||
fontConfig.PixelSnapH = true;
|
this.UseAxis
|
||||||
DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, fontConfig.SizePixels, fontConfig);
|
? TargetFontModification.AxisMode.Overwrite
|
||||||
this.loadedFontInfo[DefaultFont] = fontInfo;
|
: TargetFontModification.AxisMode.GameGlyphsOnly,
|
||||||
}
|
this.UseAxis ? DefaultFontSizePx : DefaultFontSizePx + 1,
|
||||||
|
io.FontGlobalScale,
|
||||||
if (fontPathKr != null && Service<DalamudConfiguration>.Get().EffectiveLanguage == "ko")
|
disableBigFonts);
|
||||||
{
|
Log.Verbose("[FONT] SetupFonts - Default corresponding AXIS size: {0}pt ({1}px)",
|
||||||
fontConfig.MergeMode = true;
|
fontInfo.SourceAxis.Style.BaseSizePt, fontInfo.SourceAxis.Style.BaseSizePx);
|
||||||
fontConfig.GlyphRanges = ioFonts.GetGlyphRangesKorean();
|
fontConfig.SizePixels = disableBigFonts
|
||||||
fontConfig.PixelSnapH = true;
|
? Math.Min(MinimumFallbackFontSizePx, fontInfo.TargetSizePx)
|
||||||
ioFonts.AddFontFromFileTTF(fontPathKr, fontConfig.SizePixels, fontConfig);
|
: fontInfo.TargetSizePx * io.FontGlobalScale;
|
||||||
fontConfig.MergeMode = false;
|
if (this.UseAxis)
|
||||||
}
|
|
||||||
|
|
||||||
// FontAwesome icon font
|
|
||||||
Log.Verbose("[FONT] SetupFonts - FontAwesome icon font");
|
|
||||||
{
|
|
||||||
var fontPathIcon = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "FontAwesome5FreeSolid.otf");
|
|
||||||
if (!File.Exists(fontPathIcon))
|
|
||||||
ShowFontError(fontPathIcon);
|
|
||||||
|
|
||||||
var iconRangeHandle = GCHandle.Alloc(new ushort[] { 0xE000, 0xF8FF, 0, }, GCHandleType.Pinned);
|
|
||||||
garbageList.Add(iconRangeHandle);
|
|
||||||
|
|
||||||
fontConfig.GlyphRanges = iconRangeHandle.AddrOfPinnedObject();
|
|
||||||
fontConfig.PixelSnapH = true;
|
|
||||||
IconFont = ioFonts.AddFontFromFileTTF(fontPathIcon, disableBigFonts ? Math.Min(MinimumFallbackFontSizePx, DefaultFontSizePx) : DefaultFontSizePx * io.FontGlobalScale, fontConfig);
|
|
||||||
this.loadedFontInfo[IconFont] = new("Icon", TargetFontModification.AxisMode.GameGlyphsOnly, DefaultFontSizePx, io.FontGlobalScale, disableBigFonts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Monospace font
|
|
||||||
Log.Verbose("[FONT] SetupFonts - Monospace font");
|
|
||||||
{
|
|
||||||
var fontPathMono = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "Inconsolata-Regular.ttf");
|
|
||||||
if (!File.Exists(fontPathMono))
|
|
||||||
ShowFontError(fontPathMono);
|
|
||||||
|
|
||||||
fontConfig.GlyphRanges = IntPtr.Zero;
|
|
||||||
fontConfig.PixelSnapH = true;
|
|
||||||
MonoFont = ioFonts.AddFontFromFileTTF(fontPathMono, disableBigFonts ? Math.Min(MinimumFallbackFontSizePx, DefaultFontSizePx) : DefaultFontSizePx * io.FontGlobalScale, fontConfig);
|
|
||||||
this.loadedFontInfo[MonoFont] = new("Mono", TargetFontModification.AxisMode.GameGlyphsOnly, DefaultFontSizePx, io.FontGlobalScale, disableBigFonts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default font but in requested size for requested glyphs
|
|
||||||
Log.Verbose("[FONT] SetupFonts - Default font but in requested size for requested glyphs");
|
|
||||||
{
|
|
||||||
Dictionary<float, List<SpecialGlyphRequest>> extraFontRequests = new();
|
|
||||||
foreach (var extraFontRequest in this.glyphRequests)
|
|
||||||
{
|
{
|
||||||
if (!extraFontRequests.ContainsKey(extraFontRequest.Size))
|
fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject();
|
||||||
extraFontRequests[extraFontRequest.Size] = new();
|
fontConfig.PixelSnapH = false;
|
||||||
extraFontRequests[extraFontRequest.Size].Add(extraFontRequest);
|
DefaultFont = ioFonts.AddFontDefault(fontConfig);
|
||||||
|
this.loadedFontInfo[DefaultFont] = fontInfo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var japaneseRangeHandle = GCHandle.Alloc(GlyphRangesJapanese.GlyphRanges, GCHandleType.Pinned);
|
||||||
|
garbageList.Add(japaneseRangeHandle);
|
||||||
|
|
||||||
|
fontConfig.GlyphRanges = japaneseRangeHandle.AddrOfPinnedObject();
|
||||||
|
fontConfig.PixelSnapH = true;
|
||||||
|
DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, fontConfig.SizePixels, fontConfig);
|
||||||
|
this.loadedFontInfo[DefaultFont] = fontInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var (fontSize, requests) in extraFontRequests)
|
if (fontPathKr != null && Service<DalamudConfiguration>.Get().EffectiveLanguage == "ko")
|
||||||
{
|
{
|
||||||
List<Tuple<ushort, ushort>> codepointRanges = new();
|
fontConfig.MergeMode = true;
|
||||||
codepointRanges.Add(Tuple.Create(Fallback1Codepoint, Fallback1Codepoint));
|
fontConfig.GlyphRanges = ioFonts.GetGlyphRangesKorean();
|
||||||
codepointRanges.Add(Tuple.Create(Fallback2Codepoint, Fallback2Codepoint));
|
fontConfig.PixelSnapH = true;
|
||||||
|
ioFonts.AddFontFromFileTTF(fontPathKr, fontConfig.SizePixels, fontConfig);
|
||||||
|
fontConfig.MergeMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
// ImGui default ellipsis characters
|
// FontAwesome icon font
|
||||||
codepointRanges.Add(Tuple.Create<ushort, ushort>(0x2026, 0x2026));
|
Log.Verbose("[FONT] SetupFonts - FontAwesome icon font");
|
||||||
codepointRanges.Add(Tuple.Create<ushort, ushort>(0x0085, 0x0085));
|
{
|
||||||
|
var fontPathIcon =
|
||||||
|
Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "FontAwesome5FreeSolid.otf");
|
||||||
|
if (!File.Exists(fontPathIcon))
|
||||||
|
ShowFontError(fontPathIcon);
|
||||||
|
|
||||||
foreach (var request in requests)
|
var iconRangeHandle = GCHandle.Alloc(new ushort[] { 0xE000, 0xF8FF, 0, }, GCHandleType.Pinned);
|
||||||
|
garbageList.Add(iconRangeHandle);
|
||||||
|
|
||||||
|
fontConfig.GlyphRanges = iconRangeHandle.AddrOfPinnedObject();
|
||||||
|
fontConfig.PixelSnapH = true;
|
||||||
|
IconFont = ioFonts.AddFontFromFileTTF(fontPathIcon,
|
||||||
|
disableBigFonts
|
||||||
|
? Math.Min(MinimumFallbackFontSizePx,
|
||||||
|
DefaultFontSizePx)
|
||||||
|
: DefaultFontSizePx * io.FontGlobalScale, fontConfig);
|
||||||
|
this.loadedFontInfo[IconFont] = new("Icon", TargetFontModification.AxisMode.GameGlyphsOnly,
|
||||||
|
DefaultFontSizePx, io.FontGlobalScale, disableBigFonts);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monospace font
|
||||||
|
Log.Verbose("[FONT] SetupFonts - Monospace font");
|
||||||
|
{
|
||||||
|
var fontPathMono =
|
||||||
|
Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "Inconsolata-Regular.ttf");
|
||||||
|
if (!File.Exists(fontPathMono))
|
||||||
|
ShowFontError(fontPathMono);
|
||||||
|
|
||||||
|
fontConfig.GlyphRanges = IntPtr.Zero;
|
||||||
|
fontConfig.PixelSnapH = true;
|
||||||
|
MonoFont = ioFonts.AddFontFromFileTTF(fontPathMono,
|
||||||
|
disableBigFonts
|
||||||
|
? Math.Min(MinimumFallbackFontSizePx,
|
||||||
|
DefaultFontSizePx)
|
||||||
|
: DefaultFontSizePx * io.FontGlobalScale, fontConfig);
|
||||||
|
this.loadedFontInfo[MonoFont] = new("Mono", TargetFontModification.AxisMode.GameGlyphsOnly,
|
||||||
|
DefaultFontSizePx, io.FontGlobalScale, disableBigFonts);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default font but in requested size for requested glyphs
|
||||||
|
Log.Verbose("[FONT] SetupFonts - Default font but in requested size for requested glyphs");
|
||||||
|
{
|
||||||
|
Dictionary<float, List<SpecialGlyphRequest>> extraFontRequests = new();
|
||||||
|
foreach (var extraFontRequest in this.glyphRequests)
|
||||||
{
|
{
|
||||||
foreach (var range in request.CodepointRanges)
|
if (!extraFontRequests.ContainsKey(extraFontRequest.Size))
|
||||||
codepointRanges.Add(range);
|
extraFontRequests[extraFontRequest.Size] = new();
|
||||||
|
extraFontRequests[extraFontRequest.Size].Add(extraFontRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
codepointRanges.Sort((x, y) => (x.Item1 == y.Item1 ? (x.Item2 < y.Item2 ? -1 : (x.Item2 == y.Item2 ? 0 : 1)) : (x.Item1 < y.Item1 ? -1 : 1)));
|
foreach (var (fontSize, requests) in extraFontRequests)
|
||||||
|
|
||||||
List<ushort> flattenedRanges = new();
|
|
||||||
foreach (var range in codepointRanges)
|
|
||||||
{
|
{
|
||||||
if (flattenedRanges.Any() && flattenedRanges[^1] >= range.Item1 - 1)
|
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));
|
||||||
|
|
||||||
|
foreach (var request in requests)
|
||||||
{
|
{
|
||||||
flattenedRanges[^1] = Math.Max(flattenedRanges[^1], range.Item2);
|
foreach (var range in request.CodepointRanges)
|
||||||
|
codepointRanges.Add(range);
|
||||||
|
}
|
||||||
|
|
||||||
|
codepointRanges.Sort((x, y) => (x.Item1 == y.Item1
|
||||||
|
? (x.Item2 < y.Item2
|
||||||
|
? -1
|
||||||
|
: (x.Item2 == y.Item2 ? 0 : 1))
|
||||||
|
: (x.Item1 < y.Item1 ? -1 : 1)));
|
||||||
|
|
||||||
|
List<ushort> flattenedRanges = new();
|
||||||
|
foreach (var range in codepointRanges)
|
||||||
|
{
|
||||||
|
if (flattenedRanges.Any() && flattenedRanges[^1] >= range.Item1 - 1)
|
||||||
|
{
|
||||||
|
flattenedRanges[^1] = Math.Max(flattenedRanges[^1], range.Item2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flattenedRanges.Add(range.Item1);
|
||||||
|
flattenedRanges.Add(range.Item2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flattenedRanges.Add(0);
|
||||||
|
|
||||||
|
fontInfo = new(
|
||||||
|
$"Requested({fontSize}px)",
|
||||||
|
this.UseAxis
|
||||||
|
? TargetFontModification.AxisMode.Overwrite
|
||||||
|
: TargetFontModification.AxisMode.GameGlyphsOnly,
|
||||||
|
fontSize,
|
||||||
|
io.FontGlobalScale,
|
||||||
|
disableBigFonts);
|
||||||
|
if (this.UseAxis)
|
||||||
|
{
|
||||||
|
fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject();
|
||||||
|
fontConfig.SizePixels = fontInfo.SourceAxis.Style.BaseSizePx;
|
||||||
|
fontConfig.PixelSnapH = false;
|
||||||
|
|
||||||
|
var sizedFont = ioFonts.AddFontDefault(fontConfig);
|
||||||
|
this.loadedFontInfo[sizedFont] = fontInfo;
|
||||||
|
foreach (var request in requests)
|
||||||
|
request.FontInternal = sizedFont;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flattenedRanges.Add(range.Item1);
|
var rangeHandle = GCHandle.Alloc(flattenedRanges.ToArray(), GCHandleType.Pinned);
|
||||||
flattenedRanges.Add(range.Item2);
|
garbageList.Add(rangeHandle);
|
||||||
|
fontConfig.PixelSnapH = true;
|
||||||
|
|
||||||
|
var sizedFont = ioFonts.AddFontFromFileTTF(
|
||||||
|
fontPathJp,
|
||||||
|
disableBigFonts
|
||||||
|
? Math.Min(MinimumFallbackFontSizePx, fontSize)
|
||||||
|
: fontSize * io.FontGlobalScale, fontConfig, rangeHandle.AddrOfPinnedObject());
|
||||||
|
this.loadedFontInfo[sizedFont] = fontInfo;
|
||||||
|
foreach (var request in requests)
|
||||||
|
request.FontInternal = sizedFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flattenedRanges.Add(0);
|
|
||||||
|
|
||||||
fontInfo = new(
|
|
||||||
$"Requested({fontSize}px)",
|
|
||||||
this.UseAxis ? TargetFontModification.AxisMode.Overwrite : TargetFontModification.AxisMode.GameGlyphsOnly,
|
|
||||||
fontSize,
|
|
||||||
io.FontGlobalScale,
|
|
||||||
disableBigFonts);
|
|
||||||
if (this.UseAxis)
|
|
||||||
{
|
|
||||||
fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject();
|
|
||||||
fontConfig.SizePixels = fontInfo.SourceAxis.Style.BaseSizePx;
|
|
||||||
fontConfig.PixelSnapH = false;
|
|
||||||
|
|
||||||
var sizedFont = ioFonts.AddFontDefault(fontConfig);
|
|
||||||
this.loadedFontInfo[sizedFont] = fontInfo;
|
|
||||||
foreach (var request in requests)
|
|
||||||
request.FontInternal = sizedFont;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var rangeHandle = GCHandle.Alloc(flattenedRanges.ToArray(), GCHandleType.Pinned);
|
|
||||||
garbageList.Add(rangeHandle);
|
|
||||||
fontConfig.PixelSnapH = true;
|
|
||||||
|
|
||||||
var sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, disableBigFonts ? Math.Min(MinimumFallbackFontSizePx, fontSize) : fontSize * io.FontGlobalScale, fontConfig, rangeHandle.AddrOfPinnedObject());
|
|
||||||
this.loadedFontInfo[sizedFont] = fontInfo;
|
|
||||||
foreach (var request in requests)
|
|
||||||
request.FontInternal = sizedFont;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -880,13 +970,18 @@ namespace Dalamud.Interface.Internal
|
||||||
|
|
||||||
if (possibilityForScaling && !disableBigFonts)
|
if (possibilityForScaling && !disableBigFonts)
|
||||||
{
|
{
|
||||||
Log.Information("[FONT] Atlas size is {0}x{1} which is bigger than allowed {2}x{3}. Retrying with minimized font sizes.", ioFonts.TexWidth, ioFonts.TexHeight, maxTexDimension, maxTexDimension);
|
Log.Information(
|
||||||
|
"[FONT] Atlas size is {0}x{1} which is bigger than allowed {2}x{3}. Retrying with minimized font sizes.",
|
||||||
|
ioFonts.TexWidth, ioFonts.TexHeight, maxTexDimension, maxTexDimension);
|
||||||
this.SetupFonts(true);
|
this.SetupFonts(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Warning("[FONT] Atlas size is {0}x{1} which is bigger than allowed {2}x{3} even when font sizes are minimized up to {4}px. This may result in crash.", ioFonts.TexWidth, ioFonts.TexHeight, maxTexDimension, maxTexDimension, MinimumFallbackFontSizePx);
|
Log.Warning(
|
||||||
|
"[FONT] Atlas size is {0}x{1} which is bigger than allowed {2}x{3} even when font sizes are minimized up to {4}px. This may result in crash.",
|
||||||
|
ioFonts.TexWidth, ioFonts.TexHeight, maxTexDimension, maxTexDimension,
|
||||||
|
MinimumFallbackFontSizePx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -900,54 +995,62 @@ namespace Dalamud.Interface.Internal
|
||||||
texPixels[i] = (byte)(Math.Pow(texPixels[i] / 255.0f, 1.0f / fontGamma) * 255.0f);
|
texPixels[i] = (byte)(Math.Pow(texPixels[i] / 255.0f, 1.0f / fontGamma) * 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
gameFontManager.AfterBuildFonts(disableBigFonts);
|
if (!onlyLoadMono)
|
||||||
|
|
||||||
foreach (var (font, mod) in this.loadedFontInfo)
|
|
||||||
{
|
{
|
||||||
// I have no idea what's causing NPE, so just to be safe
|
gameFontManager.AfterBuildFonts(disableBigFonts);
|
||||||
try
|
|
||||||
|
foreach (var (font, mod) in this.loadedFontInfo)
|
||||||
{
|
{
|
||||||
if (font.NativePtr != null && font.NativePtr->ConfigData != null)
|
// I have no idea what's causing NPE, so just to be safe
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var nameBytes = Encoding.UTF8.GetBytes($"{mod.Name}\0");
|
if (font.NativePtr != null && font.NativePtr->ConfigData != null)
|
||||||
Marshal.Copy(nameBytes, 0, (IntPtr)font.ConfigData.Name.Data, Math.Min(nameBytes.Length, font.ConfigData.Name.Count));
|
{
|
||||||
|
var nameBytes = Encoding.UTF8.GetBytes($"{mod.Name}\0");
|
||||||
|
Marshal.Copy(nameBytes, 0, (IntPtr)font.ConfigData.Name.Data,
|
||||||
|
Math.Min(nameBytes.Length, font.ConfigData.Name.Count));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (NullReferenceException)
|
||||||
catch (NullReferenceException)
|
{
|
||||||
{
|
// do nothing
|
||||||
// do nothing
|
}
|
||||||
|
|
||||||
|
Log.Verbose("[FONT] {0}: Unscale with scale value of {1}", mod.Name, mod.Scale);
|
||||||
|
GameFontManager.UnscaleFont(font, mod.Scale, false);
|
||||||
|
|
||||||
|
if (mod.Axis == TargetFontModification.AxisMode.Overwrite)
|
||||||
|
{
|
||||||
|
Log.Verbose("[FONT] {0}: Overwrite from AXIS of size {1}px (was {2}px)", mod.Name,
|
||||||
|
mod.SourceAxis.ImFont.FontSize, font.FontSize);
|
||||||
|
font.FontSize = mod.SourceAxis.ImFont.FontSize;
|
||||||
|
font.Ascent = mod.SourceAxis.ImFont.Ascent;
|
||||||
|
font.Descent = mod.SourceAxis.ImFont.Descent;
|
||||||
|
font.FallbackChar = mod.SourceAxis.ImFont.FallbackChar;
|
||||||
|
font.EllipsisChar = mod.SourceAxis.ImFont.EllipsisChar;
|
||||||
|
GameFontManager.CopyGlyphsAcrossFonts(mod.SourceAxis.ImFont, font, false, false);
|
||||||
|
}
|
||||||
|
else if (mod.Axis == TargetFontModification.AxisMode.GameGlyphsOnly)
|
||||||
|
{
|
||||||
|
Log.Verbose("[FONT] {0}: Overwrite game specific glyphs from AXIS of size {1}px", mod.Name,
|
||||||
|
mod.SourceAxis.ImFont.FontSize, font.FontSize);
|
||||||
|
if (!this.UseAxis && font.NativePtr == DefaultFont.NativePtr)
|
||||||
|
mod.SourceAxis.ImFont.FontSize -= 1;
|
||||||
|
GameFontManager.CopyGlyphsAcrossFonts(mod.SourceAxis.ImFont, font, true, false, 0xE020,
|
||||||
|
0xE0DB);
|
||||||
|
if (!this.UseAxis && font.NativePtr == DefaultFont.NativePtr)
|
||||||
|
mod.SourceAxis.ImFont.FontSize += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Verbose("[FONT] {0}: Resize from {1}px to {2}px", mod.Name, font.FontSize,
|
||||||
|
mod.TargetSizePx);
|
||||||
|
GameFontManager.UnscaleFont(font, font.FontSize / mod.TargetSizePx, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.Verbose("[FONT] {0}: Unscale with scale value of {1}", mod.Name, mod.Scale);
|
// Fill missing glyphs in MonoFont from DefaultFont
|
||||||
GameFontManager.UnscaleFont(font, mod.Scale, false);
|
GameFontManager.CopyGlyphsAcrossFonts(DefaultFont, MonoFont, true, false);
|
||||||
|
|
||||||
if (mod.Axis == TargetFontModification.AxisMode.Overwrite)
|
|
||||||
{
|
|
||||||
Log.Verbose("[FONT] {0}: Overwrite from AXIS of size {1}px (was {2}px)", mod.Name, mod.SourceAxis.ImFont.FontSize, font.FontSize);
|
|
||||||
font.FontSize = mod.SourceAxis.ImFont.FontSize;
|
|
||||||
font.Ascent = mod.SourceAxis.ImFont.Ascent;
|
|
||||||
font.Descent = mod.SourceAxis.ImFont.Descent;
|
|
||||||
font.FallbackChar = mod.SourceAxis.ImFont.FallbackChar;
|
|
||||||
font.EllipsisChar = mod.SourceAxis.ImFont.EllipsisChar;
|
|
||||||
GameFontManager.CopyGlyphsAcrossFonts(mod.SourceAxis.ImFont, font, false, false);
|
|
||||||
}
|
|
||||||
else if (mod.Axis == TargetFontModification.AxisMode.GameGlyphsOnly)
|
|
||||||
{
|
|
||||||
Log.Verbose("[FONT] {0}: Overwrite game specific glyphs from AXIS of size {1}px", mod.Name, mod.SourceAxis.ImFont.FontSize, font.FontSize);
|
|
||||||
if (!this.UseAxis && font.NativePtr == DefaultFont.NativePtr)
|
|
||||||
mod.SourceAxis.ImFont.FontSize -= 1;
|
|
||||||
GameFontManager.CopyGlyphsAcrossFonts(mod.SourceAxis.ImFont, font, true, false, 0xE020, 0xE0DB);
|
|
||||||
if (!this.UseAxis && font.NativePtr == DefaultFont.NativePtr)
|
|
||||||
mod.SourceAxis.ImFont.FontSize += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.Verbose("[FONT] {0}: Resize from {1}px to {2}px", mod.Name, font.FontSize, mod.TargetSizePx);
|
|
||||||
GameFontManager.UnscaleFont(font, font.FontSize / mod.TargetSizePx, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill missing glyphs in MonoFont from DefaultFont
|
|
||||||
GameFontManager.CopyGlyphsAcrossFonts(DefaultFont, MonoFont, true, false);
|
|
||||||
|
|
||||||
for (int i = 0, i_ = ioFonts.Fonts.Size; i < i_; i++)
|
for (int i = 0, i_ = ioFonts.Fonts.Size; i < i_; i++)
|
||||||
{
|
{
|
||||||
var font = ioFonts.Fonts[i];
|
var font = ioFonts.Fonts[i];
|
||||||
|
|
@ -964,8 +1067,7 @@ namespace Dalamud.Interface.Internal
|
||||||
this.fontBuildSignal.Set();
|
this.fontBuildSignal.Set();
|
||||||
|
|
||||||
this.FontsReady = true;
|
this.FontsReady = true;
|
||||||
}
|
} finally
|
||||||
finally
|
|
||||||
{
|
{
|
||||||
if (fontConfig.NativePtr != null)
|
if (fontConfig.NativePtr != null)
|
||||||
fontConfig.Destroy();
|
fontConfig.Destroy();
|
||||||
|
|
@ -997,10 +1099,12 @@ namespace Dalamud.Interface.Internal
|
||||||
this.isRebuildingFonts = false;
|
this.isRebuildingFonts = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntPtr ResizeBuffersDetour(IntPtr swapChain, uint bufferCount, uint width, uint height, uint newFormat, uint swapChainFlags)
|
private IntPtr ResizeBuffersDetour(
|
||||||
|
IntPtr swapChain, uint bufferCount, uint width, uint height, uint newFormat, uint swapChainFlags)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.Verbose($"Calling resizebuffers swap@{swapChain.ToInt64():X}{bufferCount} {width} {height} {newFormat} {swapChainFlags}");
|
Log.Verbose(
|
||||||
|
$"Calling resizebuffers swap@{swapChain.ToInt64():X}{bufferCount} {width} {height} {newFormat} {swapChainFlags}");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this.ResizeBuffers?.Invoke();
|
this.ResizeBuffers?.Invoke();
|
||||||
|
|
@ -1008,7 +1112,8 @@ namespace Dalamud.Interface.Internal
|
||||||
// We have to ensure we're working with the main swapchain,
|
// We have to ensure we're working with the main swapchain,
|
||||||
// as viewports might be resizing as well
|
// as viewports might be resizing as well
|
||||||
if (this.scene == null || swapChain != this.scene.SwapChain.NativePointer)
|
if (this.scene == null || swapChain != this.scene.SwapChain.NativePointer)
|
||||||
return this.resizeBuffersHook.Original(swapChain, bufferCount, width, height, newFormat, swapChainFlags);
|
return this.resizeBuffersHook.Original(swapChain, bufferCount, width, height, newFormat,
|
||||||
|
swapChainFlags);
|
||||||
|
|
||||||
this.scene?.OnPreResize();
|
this.scene?.OnPreResize();
|
||||||
|
|
||||||
|
|
@ -1025,7 +1130,8 @@ namespace Dalamud.Interface.Internal
|
||||||
|
|
||||||
private IntPtr SetCursorDetour(IntPtr hCursor)
|
private IntPtr SetCursorDetour(IntPtr hCursor)
|
||||||
{
|
{
|
||||||
if (this.lastWantCapture == true && (!this.scene?.IsImGuiCursor(hCursor) ?? false) && this.OverrideGameCursor)
|
if (this.lastWantCapture == true && (!this.scene?.IsImGuiCursor(hCursor) ?? false) &&
|
||||||
|
this.OverrideGameCursor)
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
||||||
return this.setCursorHook.Original(hCursor);
|
return this.setCursorHook.Original(hCursor);
|
||||||
|
|
@ -1196,13 +1302,16 @@ namespace Dalamud.Interface.Internal
|
||||||
/// <param name="sizePx">Target font size in pixels, which will not be considered for further scaling.</param>
|
/// <param name="sizePx">Target font size in pixels, which will not be considered for further scaling.</param>
|
||||||
/// <param name="globalFontScale">Font scale to be referred for loading AXIS font of appropriate size.</param>
|
/// <param name="globalFontScale">Font scale to be referred for loading AXIS font of appropriate size.</param>
|
||||||
/// <param name="disableBigFonts">Whether to enable loading big AXIS fonts.</param>
|
/// <param name="disableBigFonts">Whether to enable loading big AXIS fonts.</param>
|
||||||
internal TargetFontModification(string name, AxisMode axis, float sizePx, float globalFontScale, bool disableBigFonts)
|
internal TargetFontModification(
|
||||||
|
string name, AxisMode axis, float sizePx, float globalFontScale, bool disableBigFonts)
|
||||||
{
|
{
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.Axis = axis;
|
this.Axis = axis;
|
||||||
this.TargetSizePx = sizePx;
|
this.TargetSizePx = sizePx;
|
||||||
this.Scale = disableBigFonts ? MinimumFallbackFontSizePx / sizePx : globalFontScale;
|
this.Scale = disableBigFonts ? MinimumFallbackFontSizePx / sizePx : globalFontScale;
|
||||||
this.SourceAxis = Service<GameFontManager>.Get().NewFontRef(new(GameFontFamily.Axis, this.TargetSizePx * this.Scale));
|
this.SourceAxis = Service<GameFontManager>.Get()
|
||||||
|
.NewFontRef(
|
||||||
|
new(GameFontFamily.Axis, this.TargetSizePx * this.Scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum AxisMode
|
internal enum AxisMode
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue