diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs
index 76c8f3603..66c2745c5 100644
--- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs
+++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs
@@ -148,12 +148,9 @@ internal sealed class DalamudConfiguration : IServiceType, IDisposable
public bool UseAxisFontsFromGame { get; set; } = false;
///
- /// Gets or sets the gamma value to apply for Dalamud fonts. Effects text thickness.
- ///
- /// Before gamma is applied...
- /// * ...TTF fonts loaded with stb or FreeType are in linear space.
- /// * ...the game's prebaked AXIS fonts are in gamma space with gamma value of 1.4.
+ /// Gets or sets the gamma value to apply for Dalamud fonts. Do not use.
///
+ [Obsolete("It happens that nobody touched this setting", true)]
public float FontGammaLevel { get; set; } = 1.4f;
///
diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs
index e21a22fa2..46d37fe90 100644
--- a/Dalamud/Interface/Internal/InterfaceManager.cs
+++ b/Dalamud/Interface/Internal/InterfaceManager.cs
@@ -199,16 +199,6 @@ internal class InterfaceManager : IDisposable, IServiceType
///
public bool UseAxis => this.UseAxisOverride ?? Service.Get().UseAxisFontsFromGame;
- ///
- /// Gets or sets the overrided font gamma value, instead of using the value from configuration.
- ///
- public float? FontGammaOverride { get; set; } = null;
-
- ///
- /// Gets the font gamma value to use.
- ///
- public float FontGamma => Math.Max(0.1f, this.FontGammaOverride.GetValueOrDefault(Service.Get().FontGammaLevel));
-
///
/// Gets a value indicating the native handle of the game main window.
///
diff --git a/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs
index 414eabd22..20ffc781c 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs
@@ -66,13 +66,9 @@ internal class SettingsWindow : Window
var configuration = Service.Get();
var interfaceManager = Service.Get();
- var rebuildFont =
- ImGui.GetIO().FontGlobalScale != configuration.GlobalUiScale ||
- interfaceManager.FontGamma != configuration.FontGammaLevel ||
- interfaceManager.UseAxis != configuration.UseAxisFontsFromGame;
+ var rebuildFont = interfaceManager.UseAxis != configuration.UseAxisFontsFromGame;
ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale;
- interfaceManager.FontGammaOverride = null;
interfaceManager.UseAxisOverride = null;
if (rebuildFont)
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
index ec140890f..35f307655 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
@@ -29,7 +29,6 @@ public class SettingsTabLook : SettingsTab
};
private float globalUiScale;
- private float fontGamma;
public override SettingsEntry[] Entries { get; } =
{
@@ -202,33 +201,12 @@ public class SettingsTabLook : SettingsTab
}
}
- ImGuiHelpers.ScaledDummy(5);
-
- ImGui.AlignTextToFramePadding();
- ImGui.Text(Loc.Localize("DalamudSettingsFontGamma", "Font Gamma"));
- ImGui.SameLine();
- if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "Reset") + "##DalamudSettingsFontGammaReset"))
- {
- this.fontGamma = 1.4f;
- interfaceManager.FontGammaOverride = this.fontGamma;
- interfaceManager.RebuildFonts();
- }
-
- if (ImGui.DragFloat("##DalamudSettingsFontGammaDrag", ref this.fontGamma, 0.005f, 0.3f, 3f, "%.2f", ImGuiSliderFlags.AlwaysClamp))
- {
- interfaceManager.FontGammaOverride = this.fontGamma;
- interfaceManager.RebuildFonts();
- }
-
- ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsFontGammaHint", "Changes the thickness of text."));
-
base.Draw();
}
public override void Load()
{
this.globalUiScale = Service.Get().GlobalUiScale;
- this.fontGamma = Service.Get().FontGammaLevel;
base.Load();
}
@@ -236,7 +214,6 @@ public class SettingsTabLook : SettingsTab
public override void Save()
{
Service.Get().GlobalUiScale = this.globalUiScale;
- Service.Get().FontGammaLevel = this.fontGamma;
base.Save();
}
diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.BuildToolkit.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.BuildToolkit.cs
index 8e115c126..4403d6400 100644
--- a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.BuildToolkit.cs
+++ b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.BuildToolkit.cs
@@ -381,7 +381,6 @@ internal sealed partial class FontAtlasFactory
public unsafe void PreBuild()
{
- var gamma = this.factory.InterfaceManager.FontGamma;
var configData = this.data.ConfigData;
foreach (ref var config in configData.DataSpan)
{
@@ -400,7 +399,7 @@ internal sealed partial class FontAtlasFactory
config.GlyphOffset *= this.Scale;
- config.RasterizerGamma *= gamma;
+ config.RasterizerGamma *= 1.4f;
}
}
diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.cs
index 7a1926a9d..fc199ef5a 100644
--- a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.cs
+++ b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.cs
@@ -39,8 +39,6 @@ internal sealed partial class FontAtlasFactory
private readonly Task defaultGlyphRanges;
private readonly DalamudAssetManager dalamudAssetManager;
- private float lastBuildGamma = -1f;
-
[ServiceManager.ServiceConstructor]
private FontAtlasFactory(
DataManager dataManager,
@@ -210,18 +208,10 @@ internal sealed partial class FontAtlasFactory
{
lock (this.prebakedTextureWraps[texPathFormat])
{
- var gamma = this.InterfaceManager.FontGamma;
var wraps = ExtractResult(this.prebakedTextureWraps[texPathFormat]);
- if (Math.Abs(this.lastBuildGamma - gamma) > 0.0001f)
- {
- this.lastBuildGamma = gamma;
- wraps.AggregateToDisposable().Dispose();
- wraps.AsSpan().Clear();
- }
-
var fileIndex = textureIndex / 4;
var channelIndex = FdtReader.FontTableEntry.TextureChannelOrder[textureIndex % 4];
- wraps[textureIndex] ??= this.GetChannelTexture(texPathFormat, fileIndex, channelIndex, gamma);
+ wraps[textureIndex] ??= this.GetChannelTexture(texPathFormat, fileIndex, channelIndex);
return CloneTextureWrap(wraps[textureIndex]);
}
}
@@ -232,13 +222,9 @@ internal sealed partial class FontAtlasFactory
Span target,
ReadOnlySpan source,
int channelIndex,
- bool targetIsB4G4R4A4,
- float gamma)
+ bool targetIsB4G4R4A4)
{
var numPixels = Math.Min(source.Length / 4, target.Length / (targetIsB4G4R4A4 ? 2 : 4));
- var gammaTable = stackalloc byte[256];
- for (var i = 0; i < 256; i++)
- gammaTable[i] = (byte)(MathF.Pow(Math.Clamp(i / 255f, 0, 1), 1.4f / gamma) * 255);
fixed (byte* sourcePtrImmutable = source)
{
@@ -250,7 +236,7 @@ internal sealed partial class FontAtlasFactory
var wptr = (ushort*)targetPtr;
while (numPixels-- > 0)
{
- *wptr = (ushort)((gammaTable[*rptr] << 8) | 0x0FFF);
+ *wptr = (ushort)((*rptr << 8) | 0x0FFF);
wptr++;
rptr += 4;
}
@@ -260,7 +246,7 @@ internal sealed partial class FontAtlasFactory
var wptr = (uint*)targetPtr;
while (numPixels-- > 0)
{
- *wptr = (uint)((gammaTable[*rptr] << 24) | 0x00FFFFFF);
+ *wptr = (uint)((*rptr << 24) | 0x00FFFFFF);
wptr++;
rptr += 4;
}
@@ -292,41 +278,33 @@ internal sealed partial class FontAtlasFactory
Span target,
ReadOnlySpan source,
int channelIndex,
- bool targetIsB4G4R4A4,
- float gamma)
+ bool targetIsB4G4R4A4)
{
var numPixels = Math.Min(source.Length / 2, target.Length / (targetIsB4G4R4A4 ? 2 : 4));
fixed (byte* sourcePtrImmutable = source)
{
var rptr = sourcePtrImmutable + (channelIndex / 2);
var rshift = (channelIndex & 1) == 0 ? 0 : 4;
- var gammaTable = stackalloc byte[256];
fixed (void* targetPtr = target)
{
if (targetIsB4G4R4A4)
{
- for (var i = 0; i < 16; i++)
- gammaTable[i] = (byte)(MathF.Pow(Math.Clamp(i / 15f, 0, 1), 1.4f / gamma) * 15);
-
var wptr = (ushort*)targetPtr;
while (numPixels-- > 0)
{
- *wptr = (ushort)((gammaTable[(*rptr >> rshift) & 0xF] << 12) | 0x0FFF);
+ *wptr = (ushort)(((*rptr >> rshift) << 12) | 0x0FFF);
wptr++;
rptr += 2;
}
}
else
{
- for (var i = 0; i < 256; i++)
- gammaTable[i] = (byte)(MathF.Pow(Math.Clamp(i / 255f, 0, 1), 1.4f / gamma) * 255);
-
var wptr = (uint*)targetPtr;
while (numPixels-- > 0)
{
var v = (*rptr >> rshift) & 0xF;
v |= v << 4;
- *wptr = (uint)((gammaTable[v] << 24) | 0x00FFFFFF);
+ *wptr = (uint)((v << 24) | 0x00FFFFFF);
wptr++;
rptr += 4;
}
@@ -335,7 +313,7 @@ internal sealed partial class FontAtlasFactory
}
}
- private IDalamudTextureWrap GetChannelTexture(string texPathFormat, int fileIndex, int channelIndex, float gamma)
+ private IDalamudTextureWrap GetChannelTexture(string texPathFormat, int fileIndex, int channelIndex)
{
var texFile = ExtractResult(ExtractResult(this.texFiles[texPathFormat])[fileIndex]);
var numPixels = texFile.Header.Width * texFile.Header.Height;
@@ -351,15 +329,15 @@ internal sealed partial class FontAtlasFactory
{
case TexFile.TextureFormat.B4G4R4A4:
// Game ships with this format.
- ExtractChannelFromB4G4R4A4(buffer, sliceSpan, channelIndex, targetIsB4G4R4A4, gamma);
+ ExtractChannelFromB4G4R4A4(buffer, sliceSpan, channelIndex, targetIsB4G4R4A4);
break;
case TexFile.TextureFormat.B8G8R8A8:
// In case of modded font textures.
- ExtractChannelFromB8G8R8A8(buffer, sliceSpan, channelIndex, targetIsB4G4R4A4, gamma);
+ ExtractChannelFromB8G8R8A8(buffer, sliceSpan, channelIndex, targetIsB4G4R4A4);
break;
default:
// Unlikely.
- ExtractChannelFromB8G8R8A8(buffer, texFile.ImageData, channelIndex, targetIsB4G4R4A4, gamma);
+ ExtractChannelFromB8G8R8A8(buffer, texFile.ImageData, channelIndex, targetIsB4G4R4A4);
break;
}
diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs
index 37266f39b..c40302f6c 100644
--- a/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs
+++ b/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs
@@ -334,7 +334,6 @@ internal class GamePrebakedFontHandle : IFontHandle.IInternal
ArrayPool.Shared.Return(x);
});
- var fontGamma = this.interfaceManager.FontGamma;
var pixels8Array = new byte*[toolkitPostBuild.NewImAtlas.Textures.Size];
var widths = new int[toolkitPostBuild.NewImAtlas.Textures.Size];
var heights = new int[toolkitPostBuild.NewImAtlas.Textures.Size];
@@ -447,21 +446,6 @@ internal class GamePrebakedFontHandle : IFontHandle.IInternal
}
}
}
-
- if (Math.Abs(fontGamma - 1.4f) >= 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)
- var xTo = rc->X + rc->Width;
- var yTo = rc->Y + rc->Height;
- for (int y = rc->Y; y < yTo; y++)
- {
- for (int x = rc->X; x < xTo; x++)
- {
- var i = (y * width) + x;
- pixels8[i] = (byte)(Math.Pow(pixels8[i] / 255.0f, 1.4f / fontGamma) * 255.0f);
- }
- }
- }
}
}
else if (this.lateBuildRanges.TryGetValue(font, out var buildRanges))