Don't oversample fonts, and use geta mark to indicate unavailable glyph

(cherry picked from commit e22b168c53)
This commit is contained in:
Soreepeong 2022-03-07 14:05:20 +09:00
parent b2ff63a4cc
commit 1f20b3c35a
2 changed files with 63 additions and 31 deletions

View file

@ -284,39 +284,49 @@ namespace Dalamud.Interface.GameFonts
/// </summary>
public void BuildFonts()
{
var io = ImGui.GetIO();
io.Fonts.TexDesiredWidth = 4096;
this.glyphRectIds.Clear();
this.fonts.Clear();
foreach (var style in this.fontUseCounter.Keys)
unsafe
{
var rectIds = this.glyphRectIds[style] = new();
ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
fontConfig.OversampleH = 1;
fontConfig.OversampleV = 1;
fontConfig.PixelSnapH = true;
var fdt = this.fdts[(int)style.FamilyAndSize];
if (fdt == null)
continue;
var io = ImGui.GetIO();
io.Fonts.TexDesiredWidth = 4096;
var font = io.Fonts.AddFontDefault();
this.fonts[style] = font;
foreach (var glyph in fdt.Glyphs)
this.glyphRectIds.Clear();
this.fonts.Clear();
foreach (var style in this.fontUseCounter.Keys)
{
var c = glyph.Char;
if (c < 32 || c >= 0xFFFF)
var rectIds = this.glyphRectIds[style] = new();
var fdt = this.fdts[(int)style.FamilyAndSize];
if (fdt == null)
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 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);
}
}
fontConfig.Destroy();
}
}