From 31436cabfdcef2ac8c762895fee75da0c093f4d9 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Tue, 5 Apr 2022 15:33:21 +0900 Subject: [PATCH 1/3] Add atlas texture size opportunistic limiter --- .../Internal/DalamudConfiguration.cs | 5 +- .../Interface/GameFonts/GameFontManager.cs | 3 +- Dalamud/Interface/GameFonts/GameFontStyle.cs | 43 ++++++------ .../Interface/Internal/InterfaceManager.cs | 65 ++++++++++++++----- .../Internal/Windows/SettingsWindow.cs | 63 +++++++++++++++--- 5 files changed, 131 insertions(+), 48 deletions(-) diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs index e9209e2d0..8975bf1a0 100644 --- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs +++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs @@ -144,9 +144,10 @@ namespace Dalamud.Configuration.Internal public float FontGamma { get; set; } = 1.4f; /// - /// Gets or sets a value indicating whether to allow big font atlas. + /// Gets or sets a value indicating the level of font resolution between 1 to 5. + /// 0(1024x1024), 1(2048x2048), 2(4096x4096), 3(8192x8192), 4(16384x16384). /// - public bool AllowBigFontAtlas { get; set; } = false; + public int FontResolutionLevel { get; set; } = 2; /// /// Gets or sets a value indicating whether or not plugin UI should be hidden. diff --git a/Dalamud/Interface/GameFonts/GameFontManager.cs b/Dalamud/Interface/GameFonts/GameFontManager.cs index adbe6dfa4..056b22912 100644 --- a/Dalamud/Interface/GameFonts/GameFontManager.cs +++ b/Dalamud/Interface/GameFonts/GameFontManager.cs @@ -289,7 +289,7 @@ namespace Dalamud.Interface.GameFonts ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig(); fontConfig.OversampleH = 1; fontConfig.OversampleV = 1; - fontConfig.PixelSnapH = true; + fontConfig.PixelSnapH = false; var io = ImGui.GetIO(); @@ -305,6 +305,7 @@ namespace Dalamud.Interface.GameFonts continue; var font = io.Fonts.AddFontDefault(fontConfig); + this.fonts[style] = font; foreach (var glyph in fdt.Glyphs) { diff --git a/Dalamud/Interface/GameFonts/GameFontStyle.cs b/Dalamud/Interface/GameFonts/GameFontStyle.cs index 8a713f1cf..8636f128e 100644 --- a/Dalamud/Interface/GameFonts/GameFontStyle.cs +++ b/Dalamud/Interface/GameFonts/GameFontStyle.cs @@ -87,9 +87,9 @@ namespace Dalamud.Interface.GameFonts }; /// - /// Gets the font size. + /// Gets the font size in point unit. /// - public float Size => this.FamilyAndSize switch + public float SizePt => this.FamilyAndSize switch { GameFontFamilyAndSize.Undefined => 0, GameFontFamilyAndSize.Axis96 => 9.6f, @@ -118,6 +118,11 @@ namespace Dalamud.Interface.GameFonts _ => throw new InvalidOperationException(), }; + /// + /// Gets the font size in pixel unit. + /// + public float SizePx => this.SizePt * 4 / 3; + /// /// Gets or sets a value indicating whether this font is bold. /// @@ -153,59 +158,59 @@ namespace Dalamud.Interface.GameFonts return GameFontFamilyAndSize.Undefined; case GameFontFamily.Axis: - if (size <= 9.6) + if (size <= 9.601) return GameFontFamilyAndSize.Axis96; - else if (size <= 12) + else if (size <= 12.001) return GameFontFamilyAndSize.Axis12; - else if (size <= 14) + else if (size <= 14.001) return GameFontFamilyAndSize.Axis14; - else if (size <= 18) + else if (size <= 18.001) return GameFontFamilyAndSize.Axis18; else return GameFontFamilyAndSize.Axis36; case GameFontFamily.Jupiter: - if (size <= 16) + if (size <= 16.001) return GameFontFamilyAndSize.Jupiter16; - else if (size <= 20) + else if (size <= 20.001) return GameFontFamilyAndSize.Jupiter20; - else if (size <= 23) + else if (size <= 23.001) return GameFontFamilyAndSize.Jupiter23; else return GameFontFamilyAndSize.Jupiter46; case GameFontFamily.JupiterNumeric: - if (size <= 45) + if (size <= 45.001) return GameFontFamilyAndSize.Jupiter45; else return GameFontFamilyAndSize.Jupiter90; case GameFontFamily.Meidinger: - if (size <= 16) + if (size <= 16.001) return GameFontFamilyAndSize.Meidinger16; - else if (size <= 20) + else if (size <= 20.001) return GameFontFamilyAndSize.Meidinger20; else return GameFontFamilyAndSize.Meidinger40; case GameFontFamily.MiedingerMid: - if (size <= 10) + if (size <= 10.001) return GameFontFamilyAndSize.MiedingerMid10; - else if (size <= 12) + else if (size <= 12.001) return GameFontFamilyAndSize.MiedingerMid12; - else if (size <= 14) + else if (size <= 14.001) return GameFontFamilyAndSize.MiedingerMid14; - else if (size <= 18) + else if (size <= 18.001) return GameFontFamilyAndSize.MiedingerMid18; else return GameFontFamilyAndSize.MiedingerMid36; case GameFontFamily.TrumpGothic: - if (size <= 18.4) + if (size <= 18.401) return GameFontFamilyAndSize.TrumpGothic184; - else if (size <= 23) + else if (size <= 23.001) return GameFontFamilyAndSize.TrumpGothic23; - else if (size <= 34) + else if (size <= 34.001) return GameFontFamilyAndSize.TrumpGothic34; else return GameFontFamilyAndSize.TrumpGothic68; diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index c19a32601..fee865af3 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -216,14 +216,14 @@ namespace Dalamud.Interface.Internal public float FontGamma => Math.Max(0.1f, this.FontGammaOverride.GetValueOrDefault(Service.Get().FontGamma)); /// - /// Gets or sets a value indicating whether to override configuration for AllowBigFontAtlas. + /// Gets or sets a value indicating whether to override configuration for FontResolutionLevel. /// - public bool? AllowBigFontAtlasOverride { get; set; } = null; + public int? FontResolutionLevelOverride { get; set; } = null; /// - /// Gets a value indicating whether to allow big font atlas. + /// Gets a value indicating the level of font resolution. /// - public bool AllowBigFontAtlas => this.AllowBigFontAtlasOverride ?? Service.Get().AllowBigFontAtlas; + public int FontResolutionLevel => this.FontResolutionLevelOverride ?? Service.Get().FontResolutionLevel; /// /// Enable this module. @@ -594,21 +594,24 @@ namespace Dalamud.Interface.Internal ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.ViewportsEnable; } - private unsafe void SetupFonts() + private unsafe void SetupFonts(int scaler = 0) { var gameFontManager = Service.Get(); var dalamud = Service.Get(); var io = ImGui.GetIO(); var ioFonts = io.Fonts; - var fontLoadScale = this.AllowBigFontAtlas ? io.FontGlobalScale : 1; - var fontGamma = this.FontGamma; List fontsToUnscale = new(); List fontsToOverwriteFromAxis = new(); List fontsToReassignSizes = new(); + var maxTexDimension = 1 << (10 + Math.Max(0, Math.Min(4, this.FontResolutionLevel))); + var disableBigFonts = scaler != 0; + var fontLoadScale = disableBigFonts ? Math.Min(io.FontGlobalScale, 1.0f / scaler) : io.FontGlobalScale; + var fontGamma = this.FontGamma; + this.fontBuildSignal.Reset(); ioFonts.Clear(); - ioFonts.TexDesiredWidth = this.AllowBigFontAtlas ? 4096 : 2048; + ioFonts.TexDesiredWidth = maxTexDimension; Log.Verbose("[FONT] SetupFonts - 1"); @@ -633,7 +636,6 @@ namespace Dalamud.Interface.Internal fontConfig = ImGuiNative.ImFontConfig_ImFontConfig(); fontConfig.OversampleH = 1; fontConfig.OversampleV = 1; - fontConfig.PixelSnapH = true; var fontPathJp = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "NotoSansCJKjp-Medium.otf"); if (!File.Exists(fontPathJp)) @@ -641,15 +643,17 @@ namespace Dalamud.Interface.Internal // Default font Log.Verbose("[FONT] SetupFonts - Default font"); - this.axisFontHandles.Add(gameFontManager.NewFontRef(this.AllowBigFontAtlas ? new(GameFontFamily.Axis, DefaultFontSizePt * fontLoadScale) : new(GameFontFamilyAndSize.Axis12))); + this.axisFontHandles.Add(gameFontManager.NewFontRef(new(GameFontFamily.Axis, DefaultFontSizePt * fontLoadScale))); + Log.Verbose("[FONT] SetupFonts - Default corresponding AXIS size: {0}pt ({1}px)", this.axisFontHandles.Last().Style.SizePt, this.axisFontHandles.Last().Style.SizePx); if (this.UseAxis) { fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject(); fontConfig.SizePixels = DefaultFontSizePx * fontLoadScale; + fontConfig.PixelSnapH = false; DefaultFont = ioFonts.AddFontDefault(fontConfig); fontsToUnscale.Add(DefaultFont); fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(null); + fontsToReassignSizes.Add(disableBigFonts ? DefaultFontSizePx * fontLoadScale : null); } else { @@ -657,6 +661,7 @@ namespace Dalamud.Interface.Internal garbageList.Add(japaneseRangeHandle); fontConfig.GlyphRanges = japaneseRangeHandle.AddrOfPinnedObject(); + fontConfig.PixelSnapH = true; DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, (DefaultFontSizePx + 1) * fontLoadScale, fontConfig); fontsToUnscale.Add(DefaultFont); fontsToOverwriteFromAxis.Add(false); @@ -674,6 +679,7 @@ namespace Dalamud.Interface.Internal garbageList.Add(iconRangeHandle); fontConfig.GlyphRanges = iconRangeHandle.AddrOfPinnedObject(); + fontConfig.PixelSnapH = true; IconFont = ioFonts.AddFontFromFileTTF(fontPathIcon, DefaultFontSizePx * fontLoadScale, fontConfig); fontsToUnscale.Add(IconFont); this.axisFontHandles.Add(null); @@ -689,6 +695,7 @@ namespace Dalamud.Interface.Internal ShowFontError(fontPathMono); fontConfig.GlyphRanges = IntPtr.Zero; + fontConfig.PixelSnapH = true; MonoFont = ioFonts.AddFontFromFileTTF(fontPathMono, DefaultFontSizePx * fontLoadScale, fontConfig); fontsToUnscale.Add(MonoFont); this.axisFontHandles.Add(null); @@ -742,24 +749,26 @@ namespace Dalamud.Interface.Internal flattenedRanges.Add(0); ImFontPtr sizedFont; - this.axisFontHandles.Add(gameFontManager.NewFontRef(this.AllowBigFontAtlas ? new(GameFontFamily.Axis, fontSize * 3 / 4 * fontLoadScale) : new(GameFontFamilyAndSize.Axis12))); + this.axisFontHandles.Add(gameFontManager.NewFontRef(new(GameFontFamily.Axis, (disableBigFonts ? DefaultFontSizePt : fontSize * 3 / 4) * fontLoadScale))); if (this.UseAxis) { fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject(); - fontConfig.SizePixels = (this.AllowBigFontAtlas ? fontSize : DefaultFontSizePx) * fontLoadScale; + fontConfig.SizePixels = this.axisFontHandles.Last().Style.SizePx; + fontConfig.PixelSnapH = false; sizedFont = ioFonts.AddFontDefault(fontConfig); fontsToUnscale.Add(sizedFont); fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(this.AllowBigFontAtlas ? null : fontSize); + fontsToReassignSizes.Add(disableBigFonts ? fontLoadScale * fontSize : null); } else { var rangeHandle = GCHandle.Alloc(flattenedRanges.ToArray(), GCHandleType.Pinned); garbageList.Add(rangeHandle); - sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (this.AllowBigFontAtlas ? fontSize : DefaultFontSizePx + 1) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); + fontConfig.PixelSnapH = true; + sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (disableBigFonts ? fontSize : DefaultFontSizePx + 1) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); fontsToUnscale.Add(sizedFont); fontsToOverwriteFromAxis.Add(false); - fontsToReassignSizes.Add(this.AllowBigFontAtlas ? null : fontSize); + fontsToReassignSizes.Add(disableBigFonts ? fontSize : null); } foreach (var request in requests) @@ -769,17 +778,37 @@ namespace Dalamud.Interface.Internal gameFontManager.BuildFonts(); + var customFontFirstConfigIndex = ioFonts.ConfigData.Size; + Log.Verbose("[FONT] Invoke OnBuildFonts"); this.BuildFonts?.Invoke(); Log.Verbose("[FONT] OnBuildFonts OK!"); - for (var i = 0; i < ImGui.GetIO().Fonts.Fonts.Size; i++) + for (int i = customFontFirstConfigIndex, i_ = ioFonts.ConfigData.Size; i < i_; i++) { - Log.Verbose("{0} - {1}", i, ImGui.GetIO().Fonts.Fonts[i].GetDebugName()); + var configPtr = ioFonts.ConfigData[i].NativePtr; + configPtr->OversampleH = 1; + configPtr->OversampleV = 1; + if (disableBigFonts) + configPtr->SizePixels = DefaultFontSizePx * fontLoadScale; } ioFonts.Build(); + if (ioFonts.TexHeight > maxTexDimension) + { + if (scaler < 4) + { + Log.Information("[FONT] Atlas size is {0}x{1} which is bigger than allowed {2}x{3}. Retrying with scale {4}.", ioFonts.TexWidth, ioFonts.TexHeight, maxTexDimension, maxTexDimension, scaler + 1); + this.SetupFonts(scaler + 1); + return; + } + else + { + Log.Warning("[FONT] Atlas size is {0}x{1} which is bigger than allowed {2}x{3}, but giving up trying to scale smaller.", ioFonts.TexWidth, ioFonts.TexHeight, maxTexDimension, maxTexDimension); + } + } + if (Math.Abs(fontGamma - 1.0f) >= 0.001) { // Gamma correction (stbtt/FreeType would output in linear space whereas most real world usages will apply 1.4 or 1.8 gamma; Windows/XIV prebaked uses 1.4) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index b1f212d49..69202c523 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -38,9 +38,11 @@ namespace Dalamud.Interface.Internal.Windows private bool doCfChatMessage; private bool doMbCollect; + private readonly string[] fontResolutionLevelStrings; + private int fontResolutionLevel; + private float globalUiScale; private bool doUseAxisFontsFromGame; - private bool doAllowBigFontAtlas; private float fontGamma; private bool doToggleUiHide; private bool doToggleUiHideDuringCutscenes; @@ -97,7 +99,7 @@ namespace Dalamud.Interface.Internal.Windows this.globalUiScale = configuration.GlobalUiScale; this.fontGamma = configuration.FontGamma; this.doUseAxisFontsFromGame = configuration.UseAxisFontsFromGame; - this.doAllowBigFontAtlas = configuration.AllowBigFontAtlas; + this.fontResolutionLevel = configuration.FontResolutionLevel; this.doToggleUiHide = configuration.ToggleUiHide; this.doToggleUiHideDuringCutscenes = configuration.ToggleUiHideDuringCutscenes; this.doToggleUiHideDuringGpose = configuration.ToggleUiHideDuringGpose; @@ -120,6 +122,15 @@ namespace Dalamud.Interface.Internal.Windows this.doButtonsSystemMenu = configuration.DoButtonsSystemMenu; this.disableRmtFiltering = configuration.DisableRmtFiltering; + this.fontResolutionLevelStrings = new string[] + { + Loc.Localize("DalamudSettingsFontResolutionLevel0", "Least (1k x 1k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel1", "Lesser (2k x 2k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel2", "Normal (4k x 4k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel3", "Better (8k x 8k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel4", "Best (16k x 16k texture)"), + }; + this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray(); try { @@ -188,7 +199,7 @@ namespace Dalamud.Interface.Internal.Windows ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale; interfaceManager.FontGammaOverride = null; - interfaceManager.AllowBigFontAtlasOverride = null; + interfaceManager.FontResolutionLevelOverride = null; interfaceManager.UseAxisOverride = null; this.thirdRepoList = configuration.ThirdRepoList.Select(x => x.Clone()).ToList(); this.devPluginLocations = configuration.DevPluginLoadLocations.Select(x => x.Clone()).ToList(); @@ -296,13 +307,45 @@ namespace Dalamud.Interface.Internal.Windows ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global UI Scale")); ImGui.SameLine(); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 3); - if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "Reset") + "##DalamudSettingsGlobalUiScaleReset")) + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "9.6pt") + "##DalamudSettingsGlobalUiScaleReset96")) + { + this.globalUiScale = 9.6f / 12.0f; + ImGui.GetIO().FontGlobalScale = this.globalUiScale; + interfaceManager.RebuildFonts(); + } + + ImGui.SameLine(); + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "Reset (12pt)") + "##DalamudSettingsGlobalUiScaleReset12")) { this.globalUiScale = 1.0f; ImGui.GetIO().FontGlobalScale = this.globalUiScale; interfaceManager.RebuildFonts(); } + ImGui.SameLine(); + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "14pt") + "##DalamudSettingsGlobalUiScaleReset14")) + { + this.globalUiScale = 14.0f / 12.0f; + ImGui.GetIO().FontGlobalScale = this.globalUiScale; + interfaceManager.RebuildFonts(); + } + + ImGui.SameLine(); + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "18pt") + "##DalamudSettingsGlobalUiScaleReset18")) + { + this.globalUiScale = 18.0f / 12.0f; + ImGui.GetIO().FontGlobalScale = this.globalUiScale; + interfaceManager.RebuildFonts(); + } + + ImGui.SameLine(); + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "36pt") + "##DalamudSettingsGlobalUiScaleReset36")) + { + this.globalUiScale = 36.0f / 12.0f; + ImGui.GetIO().FontGlobalScale = this.globalUiScale; + interfaceManager.RebuildFonts(); + } + if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref this.globalUiScale, 0.005f, MinScale, MaxScale, "%.2f")) { ImGui.GetIO().FontGlobalScale = this.globalUiScale; @@ -332,13 +375,17 @@ namespace Dalamud.Interface.Internal.Windows ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiAxisFontsHint", "Use AXIS fonts (the game's main UI fonts) as default Dalamud font.")); - if (ImGui.Checkbox(Loc.Localize("DalamudSettingAllowBigFontAtlas", "Allow big font atlas"), ref this.doAllowBigFontAtlas)) + ImGui.Text(Loc.Localize("DalamudSettingsFontResolutionLevel", "Font resolution level")); + if (ImGui.Combo("##DalamudSettingsFontResolutionLevelCombo", ref this.fontResolutionLevel, this.fontResolutionLevelStrings, this.fontResolutionLevelStrings.Length)) { - interfaceManager.AllowBigFontAtlasOverride = this.doAllowBigFontAtlas; + interfaceManager.FontResolutionLevelOverride = this.fontResolutionLevel; interfaceManager.RebuildFonts(); } - ImGui.TextColored(ImGuiColors.DalamudGrey, string.Format(Loc.Localize("DalamudSettingAllowBigFontAtlas", "Displays text crisply, but may crash if your GPU does not support it.\nCurrent size: {0}px * {1}px"), ImGui.GetIO().Fonts.TexWidth, ImGui.GetIO().Fonts.TexHeight)); + ImGui.TextColored(ImGuiColors.DalamudGrey, string.Format( + Loc.Localize("DalamudSettingsFontResolutionLevel", "Your PC may not support loading all font into memory at maximum sizes, and it may crash. Adjust this option to try to show more crisp text.\nCurrent font atlas size is {0}px * {1}px."), + ImGui.GetIO().Fonts.TexWidth, + ImGui.GetIO().Fonts.TexHeight)); ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"), ref this.doToggleUiHide); ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay.")); @@ -867,7 +914,7 @@ namespace Dalamud.Interface.Internal.Windows configuration.ShowTsm = this.doTsm; configuration.UseAxisFontsFromGame = this.doUseAxisFontsFromGame; - configuration.AllowBigFontAtlas = this.doAllowBigFontAtlas; + configuration.FontResolutionLevel = this.fontResolutionLevel; configuration.FontGamma = this.fontGamma; // This is applied every frame in InterfaceManager::CheckViewportState() From a21cdc3eaa33b586ba4df6cbee114b67a9d68fd8 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Tue, 5 Apr 2022 15:47:27 +0900 Subject: [PATCH 2/3] Fix minor scaling bug --- Dalamud/Interface/Internal/InterfaceManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index fee865af3..3f6e65a1d 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -653,7 +653,7 @@ namespace Dalamud.Interface.Internal DefaultFont = ioFonts.AddFontDefault(fontConfig); fontsToUnscale.Add(DefaultFont); fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(disableBigFonts ? DefaultFontSizePx * fontLoadScale : null); + fontsToReassignSizes.Add(disableBigFonts ? DefaultFontSizePx : null); } else { @@ -758,14 +758,14 @@ namespace Dalamud.Interface.Internal sizedFont = ioFonts.AddFontDefault(fontConfig); fontsToUnscale.Add(sizedFont); fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(disableBigFonts ? fontLoadScale * fontSize : null); + fontsToReassignSizes.Add(disableBigFonts ? fontSize : null); } else { var rangeHandle = GCHandle.Alloc(flattenedRanges.ToArray(), GCHandleType.Pinned); garbageList.Add(rangeHandle); fontConfig.PixelSnapH = true; - sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (disableBigFonts ? fontSize : DefaultFontSizePx + 1) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); + sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (disableBigFonts ? DefaultFontSizePx + 1 : fontSize) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); fontsToUnscale.Add(sizedFont); fontsToOverwriteFromAxis.Add(false); fontsToReassignSizes.Add(disableBigFonts ? fontSize : null); @@ -849,7 +849,7 @@ namespace Dalamud.Interface.Internal } if (overwriteSize != null) - scale *= overwriteSize.Value / fontPtr->ConfigData->SizePixels; + scale *= fontLoadScale * overwriteSize.Value / fontPtr->ConfigData->SizePixels; if (scale != 1f) GameFontManager.UnscaleFont(font, 1 / scale, false); From 32ff56a3c5ae948b5340e243bdce02ee1e3789f4 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Tue, 5 Apr 2022 15:58:11 +0900 Subject: [PATCH 3/3] Warn about possible crashes --- Dalamud/Interface/Internal/Windows/SettingsWindow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index 69202c523..a8aaa8e86 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -127,8 +127,8 @@ namespace Dalamud.Interface.Internal.Windows Loc.Localize("DalamudSettingsFontResolutionLevel0", "Least (1k x 1k texture)"), Loc.Localize("DalamudSettingsFontResolutionLevel1", "Lesser (2k x 2k texture)"), Loc.Localize("DalamudSettingsFontResolutionLevel2", "Normal (4k x 4k texture)"), - Loc.Localize("DalamudSettingsFontResolutionLevel3", "Better (8k x 8k texture)"), - Loc.Localize("DalamudSettingsFontResolutionLevel4", "Best (16k x 16k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel3", "Better (8k x 8k texture, may crash your game)"), + Loc.Localize("DalamudSettingsFontResolutionLevel4", "Best (16k x 16k texture, may crash your game)"), }; this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();