55using System . Drawing . Imaging ;
66using System . Drawing . Text ;
77using System . IO ;
8+ using System . Linq ;
89
910using BizHawk . Bizware . Graphics ;
1011using BizHawk . Common . CollectionExtensions ;
12+ using BizHawk . Common . StringExtensions ;
1113using BizHawk . Emulation . Common ;
1214
1315namespace 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