Add attempts to reduce font atlas size

This commit is contained in:
Soreepeong 2022-04-01 01:18:28 +09:00
parent 6da762dc3c
commit f14bf171e4
4 changed files with 157 additions and 62 deletions

View file

@ -141,9 +141,9 @@ namespace Dalamud.Interface.GameFonts
target.Value!.ConfigData,
(ushort)glyph->Codepoint,
glyph->X0 * scale,
glyph->Y0 * scale,
((glyph->Y0 - source.Value!.Ascent) * scale) + target.Value!.Ascent,
glyph->X1 * scale,
glyph->Y1 * scale,
((glyph->Y1 - source.Value!.Ascent) * scale) + target.Value!.Ascent,
glyph->U0,
glyph->V0,
glyph->U1,
@ -153,9 +153,9 @@ namespace Dalamud.Interface.GameFonts
else if (!missingOnly)
{
prevGlyphPtr->X0 = glyph->X0 * scale;
prevGlyphPtr->Y0 = glyph->Y0 * scale;
prevGlyphPtr->Y0 = ((glyph->Y0 - source.Value!.Ascent) * scale) + target.Value!.Ascent;
prevGlyphPtr->X1 = glyph->X1 * scale;
prevGlyphPtr->Y1 = glyph->Y1 * scale;
prevGlyphPtr->Y1 = ((glyph->Y1 - source.Value!.Ascent) * scale) + target.Value!.Ascent;
prevGlyphPtr->U0 = glyph->U0;
prevGlyphPtr->V0 = glyph->V0;
prevGlyphPtr->U1 = glyph->U1;
@ -343,7 +343,7 @@ namespace Dalamud.Interface.GameFonts
{
var fdt = this.fdts[(int)style.FamilyAndSize];
var fontPtr = font.NativePtr;
fontPtr->ConfigData->SizePixels = fontPtr->FontSize = fdt.FontHeader.LineHeight;
fontPtr->ConfigData->SizePixels = fontPtr->FontSize = fdt.FontHeader.Size * 4 / 3;
fontPtr->Ascent = fdt.FontHeader.Ascent;
fontPtr->Descent = fdt.FontHeader.Descent;
fontPtr->EllipsisChar = '…';
@ -444,6 +444,9 @@ namespace Dalamud.Interface.GameFonts
{
lock (this.syncRoot)
{
if (!this.fontUseCounter.ContainsKey(style))
return;
if ((this.fontUseCounter[style] -= 1) == 0)
this.fontUseCounter.Remove(style);
}