Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions UI/Debugger/Controls/HexEditor.HexViewDrawOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ namespace Mesen.Debugger.Controls
{
public partial class HexEditor
{
private static (string Name, SKTypeface Typeface)? s_typefaceCache = null;

private static SKTypeface GetCachedTypeface(string fontFamily)
{
if(s_typefaceCache == null || s_typefaceCache.Value.Name != fontFamily) {
s_typefaceCache?.Typeface.Dispose();
s_typefaceCache = (fontFamily, SKTypeface.FromFamilyName(fontFamily));
}

return s_typefaceCache.Value.Typeface;
}

class HexViewDrawOperation : ICustomDrawOperation
{
private HexEditor _he;
Expand Down Expand Up @@ -125,7 +137,7 @@ private void DrawHexView(SKCanvas canvas, Color color)
SKPaint paint = new SKPaint();
paint.Color = new SKColor(ColorHelper.GetColor(color).ToUInt32());

SKTypeface typeface = SKTypeface.FromFamilyName(_fontFamily);
SKTypeface typeface = GetCachedTypeface(_fontFamily);
SKFont font = new SKFont(typeface, _fontSize);
SetFontProperties(font);

Expand Down Expand Up @@ -232,7 +244,7 @@ private void DrawStringView(SKCanvas canvas, Color color)
SKPaint paint = new SKPaint();
paint.Color = new SKColor(ColorHelper.GetColor(color).ToUInt32());

SKTypeface typeface = SKTypeface.FromFamilyName(_fontFamily);
SKTypeface typeface = GetCachedTypeface(_fontFamily);
SKFont monoFont = new SKFont(typeface, _fontSize);
SetFontProperties(monoFont);

Expand Down Expand Up @@ -473,7 +485,7 @@ public void Render(ImmediateDrawingContext context)
SKPaint paint = new SKPaint();
paint.Color = new SKColor(ColorHelper.GetColor(_headerForeground).ToUInt32());

SKTypeface typeface = SKTypeface.FromFamilyName(_fontFamily);
SKTypeface typeface = GetCachedTypeface(_fontFamily);
SKFont font = new SKFont(typeface, _fontSize);
font.Edging = _skiaEdging;
font.Subpixel = _skiaSubpixelSmoothing;
Expand Down