Skip to content

Commit cf323b8

Browse files
committed
Fix IGuiApi.PixelText/gui.pixelText swapping the font names
it must be that `Families` happens to return in the reverse order added on Windows, but libgdiplus doesn't
1 parent 05604aa commit cf323b8

File tree

1 file changed

+10
-1
lines changed
  • src/BizHawk.Client.Common/Api/Classes

1 file changed

+10
-1
lines changed

src/BizHawk.Client.Common/Api/Classes/GuiApi.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
using System.Drawing.Imaging;
66
using System.Drawing.Text;
77
using System.IO;
8+
using System.Linq;
89

910
using BizHawk.Bizware.Graphics;
1011
using BizHawk.Common.CollectionExtensions;
12+
using BizHawk.Common.StringExtensions;
1113
using BizHawk.Emulation.Common;
1214

1315
namespace BizHawk.Client.Common
@@ -44,6 +46,8 @@ public sealed class GuiApi : IGuiApi
4446

4547
private (int Left, int Top, int Right, int Bottom) _padding = (0, 0, 0, 0);
4648

49+
private readonly FontFamily[] _pixelFonts;
50+
4751
private DisplaySurfaceID? _usingSurfaceID;
4852
public bool HasGUISurface => true;
4953

@@ -55,6 +59,11 @@ public GuiApi(
5559
_dialogController = dialogController;
5660
LogCallback = logCallback;
5761
_displayManager = displayManager;
62+
_pixelFonts = (new[]
63+
{
64+
"fceux",
65+
"gens",
66+
}).Select(s => _displayManager.CustomFonts.Families.First(f => f.Name.EqualsIgnoreCase(s)));
5867
}
5968

6069
private I2DRenderer Get2DRenderer(DisplaySurfaceID? surfaceID)
@@ -519,7 +528,7 @@ public void PixelText(
519528
}
520529

521530
using var g = Graphics.FromImage(_nullGraphicsBitmap);
522-
var font = new Font(_displayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel);
531+
var font = new Font(_pixelFonts[index], 8, FontStyle.Regular, GraphicsUnit.Pixel);
523532
var sizeOfText = g.MeasureString(message, font, width: 0, PixelTextFormat).ToSize();
524533

525534
var r = Get2DRenderer(surfaceID);

0 commit comments

Comments
 (0)