Commit f51c3f2

Nick committed on
Use AddFontResourceExA on windows for automatic font removal at process shutdown
commit f51c3f20cc3eb31e9fd2a7e7db65138ce3a57dc5 parent ffa4946
1 changed files +7−7
ModifiedGBEmu.lpr +7−7
@@ -38,10 +38,11 @@ uses
38 {$R *.res} 38 {$R *.res}
39 39
40 {$ifdef MSWINDOWS} 40 {$ifdef MSWINDOWS}
41 procedure WindowsExitProc; 41 // https://forum.lazarus.freepascal.org/index.php?topic=39124.0
42 begin 42 Function AddFont (Dir : PAnsiChar;
43 RemoveFontResource('PixeliteTTF.ttf'); 43 Flag: DWORD): LongBool; StdCall;
44 end; 44 External GDI32
45 Name 'AddFontResourceExA';
45 {$endif} 46 {$endif}
46 47
47 begin 48 begin
@@ -61,10 +62,9 @@ begin
61 ifdef mess. } 62 ifdef mess. }
62 63
63 {$ifdef MSWINDOWS} 64 {$ifdef MSWINDOWS}
64 if AddFontResource('PixeliteTTF.ttf') = 0 then 65 // $10 is FR_PRIVATE which uninstalls the font when the process ends
66 if not AddFont(PChar('PixeliteTTF.ttf'), $10) then
65 Writeln(StdErr, '[ERROR] Couldn''t load Pixelite!!!'); 67 Writeln(StdErr, '[ERROR] Couldn''t load Pixelite!!!');
66
67 ExitProc := @WindowsExitProc;
68 {$endif} 68 {$endif}
69 69
70 {$ifdef PRODUCTION} 70 {$ifdef PRODUCTION}