From fcc77fcf54f79950656be8d86a03bfe37c65a3f7 Mon Sep 17 00:00:00 2001 From: Julien Humbert Date: Thu, 10 Nov 2016 12:13:04 +0100 Subject: [PATCH] AddFontMemRessourceEx not supported on libgdiplus --- PKHeX/PKM/PKX.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 759d8c38f..ae614d29f 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -562,8 +562,6 @@ public static Image getSprite(PKM pkm) } // Font Related - [DllImport("gdi32.dll")] - private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts); private static readonly PrivateFontCollection s_FontCollection = new PrivateFontCollection(); private static FontFamily[] FontFamilies { @@ -581,12 +579,10 @@ private static void setPKXFont() { try { - byte[] fontData = Resources.pgldings_normalregular; - IntPtr fontPtr = Marshal.AllocCoTaskMem(fontData.Length); - Marshal.Copy(fontData, 0, fontPtr, fontData.Length); - s_FontCollection.AddMemoryFont(fontPtr, Resources.pgldings_normalregular.Length); uint dummy = 0; - AddFontMemResourceEx(fontPtr, (uint)Resources.pgldings_normalregular.Length, IntPtr.Zero, ref dummy); - Marshal.FreeCoTaskMem(fontPtr); + byte[] fontData = Resources.pgldings_normalregular; + GCHandle fontHandle = GCHandle.Alloc(fontData, GCHandleType.Pinned); + s_FontCollection.AddMemoryFont(fontHandle.AddrOfPinnedObject(), fontData.Length); + fontHandle.Free(); } catch (Exception ex) { Util.Error("Unable to add ingame font.", ex); } }