mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Revert "Don't oversample fonts, and use geta mark to indicate unavailable glyph"
This reverts commit e22b168c53.
This commit is contained in:
parent
a68d13f721
commit
64e931f9ef
2 changed files with 31 additions and 63 deletions
|
|
@ -284,49 +284,39 @@ namespace Dalamud.Interface.GameFonts
|
|||
/// </summary>
|
||||
public void BuildFonts()
|
||||
{
|
||||
unsafe
|
||||
var io = ImGui.GetIO();
|
||||
io.Fonts.TexDesiredWidth = 4096;
|
||||
|
||||
this.glyphRectIds.Clear();
|
||||
this.fonts.Clear();
|
||||
|
||||
foreach (var style in this.fontUseCounter.Keys)
|
||||
{
|
||||
ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
|
||||
fontConfig.OversampleH = 1;
|
||||
fontConfig.OversampleV = 1;
|
||||
fontConfig.PixelSnapH = true;
|
||||
var rectIds = this.glyphRectIds[style] = new();
|
||||
|
||||
var io = ImGui.GetIO();
|
||||
io.Fonts.TexDesiredWidth = 4096;
|
||||
var fdt = this.fdts[(int)style.FamilyAndSize];
|
||||
if (fdt == null)
|
||||
continue;
|
||||
|
||||
this.glyphRectIds.Clear();
|
||||
this.fonts.Clear();
|
||||
|
||||
foreach (var style in this.fontUseCounter.Keys)
|
||||
var font = io.Fonts.AddFontDefault();
|
||||
this.fonts[style] = font;
|
||||
foreach (var glyph in fdt.Glyphs)
|
||||
{
|
||||
var rectIds = this.glyphRectIds[style] = new();
|
||||
|
||||
var fdt = this.fdts[(int)style.FamilyAndSize];
|
||||
if (fdt == null)
|
||||
var c = glyph.Char;
|
||||
if (c < 32 || c >= 0xFFFF)
|
||||
continue;
|
||||
|
||||
var font = io.Fonts.AddFontDefault(fontConfig);
|
||||
this.fonts[style] = font;
|
||||
foreach (var glyph in fdt.Glyphs)
|
||||
{
|
||||
var c = glyph.Char;
|
||||
if (c < 32 || c >= 0xFFFF)
|
||||
continue;
|
||||
|
||||
var widthAdjustment = style.CalculateWidthAdjustment(fdt, glyph);
|
||||
rectIds[c] = Tuple.Create(
|
||||
io.Fonts.AddCustomRectFontGlyph(
|
||||
font,
|
||||
c,
|
||||
glyph.BoundingWidth + widthAdjustment + 1,
|
||||
glyph.BoundingHeight + 1,
|
||||
glyph.AdvanceWidth,
|
||||
new Vector2(0, glyph.CurrentOffsetY)),
|
||||
glyph);
|
||||
}
|
||||
var widthAdjustment = style.CalculateWidthAdjustment(fdt, glyph);
|
||||
rectIds[c] = Tuple.Create(
|
||||
io.Fonts.AddCustomRectFontGlyph(
|
||||
font,
|
||||
c,
|
||||
glyph.BoundingWidth + widthAdjustment + 1,
|
||||
glyph.BoundingHeight + 1,
|
||||
glyph.AdvanceWidth,
|
||||
new Vector2(0, glyph.CurrentOffsetY)),
|
||||
glyph);
|
||||
}
|
||||
|
||||
fontConfig.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ namespace Dalamud.Interface.Internal
|
|||
{
|
||||
private const float DefaultFontSizePt = 12.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 Fallback2Codepoint = '-'; // FFXIV uses dash if Geta mark is unavailable.
|
||||
|
||||
private readonly string rtssPath;
|
||||
|
||||
|
|
@ -605,11 +603,6 @@ namespace Dalamud.Interface.Internal
|
|||
this.fontBuildSignal.Reset();
|
||||
ioFonts.Clear();
|
||||
|
||||
ImFontConfigPtr 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))
|
||||
ShowFontError(fontPathJp);
|
||||
|
|
@ -617,7 +610,7 @@ namespace Dalamud.Interface.Internal
|
|||
// Default font
|
||||
{
|
||||
var japaneseRangeHandle = GCHandle.Alloc(GlyphRangesJapanese.GlyphRanges, GCHandleType.Pinned);
|
||||
DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, (DefaultFontSizePx + 1) * fontScale, fontConfig, japaneseRangeHandle.AddrOfPinnedObject());
|
||||
DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, (DefaultFontSizePx + 1) * fontScale, null, japaneseRangeHandle.AddrOfPinnedObject());
|
||||
japaneseRangeHandle.Free();
|
||||
fontsToUnscale.Add(DefaultFont);
|
||||
}
|
||||
|
|
@ -629,7 +622,7 @@ namespace Dalamud.Interface.Internal
|
|||
ShowFontError(fontPathIcon);
|
||||
|
||||
var iconRangeHandle = GCHandle.Alloc(new ushort[] { 0xE000, 0xF8FF, 0, }, GCHandleType.Pinned);
|
||||
IconFont = ioFonts.AddFontFromFileTTF(fontPathIcon, DefaultFontSizePx * fontScale, fontConfig, iconRangeHandle.AddrOfPinnedObject());
|
||||
IconFont = ioFonts.AddFontFromFileTTF(fontPathIcon, DefaultFontSizePx * fontScale, null, iconRangeHandle.AddrOfPinnedObject());
|
||||
iconRangeHandle.Free();
|
||||
fontsToUnscale.Add(IconFont);
|
||||
}
|
||||
|
|
@ -639,7 +632,7 @@ namespace Dalamud.Interface.Internal
|
|||
var fontPathMono = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "Inconsolata-Regular.ttf");
|
||||
if (!File.Exists(fontPathMono))
|
||||
ShowFontError(fontPathMono);
|
||||
MonoFont = ioFonts.AddFontFromFileTTF(fontPathMono, DefaultFontSizePx * fontScale, fontConfig);
|
||||
MonoFont = ioFonts.AddFontFromFileTTF(fontPathMono, DefaultFontSizePx * fontScale);
|
||||
fontsToUnscale.Add(MonoFont);
|
||||
}
|
||||
|
||||
|
|
@ -656,9 +649,6 @@ namespace Dalamud.Interface.Internal
|
|||
foreach (var (fontSize, requests) in extraFontRequests)
|
||||
{
|
||||
List<Tuple<ushort, ushort>> codepointRanges = new();
|
||||
codepointRanges.Add(Tuple.Create(Fallback1Codepoint, Fallback1Codepoint));
|
||||
codepointRanges.Add(Tuple.Create(Fallback2Codepoint, Fallback2Codepoint));
|
||||
|
||||
foreach (var request in requests)
|
||||
{
|
||||
foreach (var range in request.CodepointRanges)
|
||||
|
|
@ -684,7 +674,7 @@ namespace Dalamud.Interface.Internal
|
|||
flattenedRanges.Add(0);
|
||||
|
||||
var rangeHandle = GCHandle.Alloc(flattenedRanges.ToArray(), GCHandleType.Pinned);
|
||||
var sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, fontSize * fontScale, fontConfig, rangeHandle.AddrOfPinnedObject());
|
||||
var sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, fontSize * fontScale, null, rangeHandle.AddrOfPinnedObject());
|
||||
rangeHandle.Free();
|
||||
|
||||
fontsToUnscale.Add(sizedFont);
|
||||
|
|
@ -723,12 +713,7 @@ namespace Dalamud.Interface.Internal
|
|||
|
||||
foreach (var font in fontsToUnscale)
|
||||
{
|
||||
// Leave IconFont alone.
|
||||
if (font.NativePtr == IconFont.NativePtr)
|
||||
continue;
|
||||
|
||||
// MonoFont will be filled later from DefaultFont.
|
||||
if (font.NativePtr == MonoFont.NativePtr)
|
||||
if (font.NativePtr == MonoFont.NativePtr || font.NativePtr == IconFont.NativePtr)
|
||||
continue;
|
||||
|
||||
if (this.overwriteAllNotoGlyphsWithAxis)
|
||||
|
|
@ -737,17 +722,11 @@ namespace Dalamud.Interface.Internal
|
|||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, font, false, false, 0xE020, 0xE0DB);
|
||||
}
|
||||
|
||||
// Fill missing glyphs in DefaultFont from Axis
|
||||
GameFontManager.CopyGlyphsAcrossFonts(this.axisFontHandle?.ImFont, DefaultFont, true, false);
|
||||
|
||||
// Fill missing glyphs in MonoFont from DefaultFont
|
||||
GameFontManager.CopyGlyphsAcrossFonts(DefaultFont, MonoFont, true, false);
|
||||
|
||||
foreach (var font in fontsToUnscale)
|
||||
{
|
||||
font.FallbackChar = Fallback1Codepoint;
|
||||
font.BuildLookupTable();
|
||||
}
|
||||
|
||||
Log.Verbose("[FONT] Invoke OnAfterBuildFonts");
|
||||
this.AfterBuildFonts?.Invoke();
|
||||
|
|
@ -755,7 +734,6 @@ namespace Dalamud.Interface.Internal
|
|||
|
||||
Log.Verbose("[FONT] Fonts built!");
|
||||
|
||||
fontConfig.Destroy();
|
||||
this.fontBuildSignal.Set();
|
||||
|
||||
this.FontsReady = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue