mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Merge pull request #772 from Soreepeong/feature/nicer-fonts
This commit is contained in:
commit
ba165f09bc
1 changed files with 157 additions and 142 deletions
|
|
@ -611,7 +611,12 @@ namespace Dalamud.Interface.Internal
|
|||
ioFonts.Clear();
|
||||
ioFonts.TexDesiredWidth = 4096;
|
||||
|
||||
ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
|
||||
ImFontConfigPtr fontConfig = null;
|
||||
List<GCHandle> garbageList = new();
|
||||
|
||||
try
|
||||
{
|
||||
fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
|
||||
fontConfig.OversampleH = 1;
|
||||
fontConfig.OversampleV = 1;
|
||||
fontConfig.PixelSnapH = true;
|
||||
|
|
@ -623,8 +628,9 @@ namespace Dalamud.Interface.Internal
|
|||
// Default font
|
||||
{
|
||||
var japaneseRangeHandle = GCHandle.Alloc(GlyphRangesJapanese.GlyphRanges, GCHandleType.Pinned);
|
||||
garbageList.Add(japaneseRangeHandle);
|
||||
|
||||
DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, (DefaultFontSizePx + 1) * fontScale, fontConfig, japaneseRangeHandle.AddrOfPinnedObject());
|
||||
japaneseRangeHandle.Free();
|
||||
fontsToUnscale.Add(DefaultFont);
|
||||
}
|
||||
|
||||
|
|
@ -635,8 +641,9 @@ namespace Dalamud.Interface.Internal
|
|||
ShowFontError(fontPathIcon);
|
||||
|
||||
var iconRangeHandle = GCHandle.Alloc(new ushort[] { 0xE000, 0xF8FF, 0, }, GCHandleType.Pinned);
|
||||
garbageList.Add(iconRangeHandle);
|
||||
|
||||
IconFont = ioFonts.AddFontFromFileTTF(fontPathIcon, DefaultFontSizePx * fontScale, fontConfig, iconRangeHandle.AddrOfPinnedObject());
|
||||
iconRangeHandle.Free();
|
||||
fontsToUnscale.Add(IconFont);
|
||||
}
|
||||
|
||||
|
|
@ -694,9 +701,9 @@ 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());
|
||||
rangeHandle.Free();
|
||||
garbageList.Add(rangeHandle);
|
||||
|
||||
var sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, fontSize * fontScale, fontConfig, rangeHandle.AddrOfPinnedObject());
|
||||
fontsToUnscale.Add(sizedFont);
|
||||
|
||||
foreach (var request in requests)
|
||||
|
|
@ -775,11 +782,19 @@ namespace Dalamud.Interface.Internal
|
|||
|
||||
Log.Verbose("[FONT] Fonts built!");
|
||||
|
||||
fontConfig.Destroy();
|
||||
this.fontBuildSignal.Set();
|
||||
|
||||
this.FontsReady = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fontConfig.NativePtr != null)
|
||||
fontConfig.Destroy();
|
||||
|
||||
foreach (var garbage in garbageList)
|
||||
garbage.Free();
|
||||
}
|
||||
}
|
||||
|
||||
private void Disable()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue