Contitionally adds mono fix from #440

Only affects Mono-Debug and Mono-Release build configurations
This commit is contained in:
Evan Dixon 2017-01-04 12:00:32 -06:00
parent 986eca8f30
commit 16156a56ac
2 changed files with 28 additions and 8 deletions

View file

@ -41,6 +41,11 @@
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
<LangVersion>6</LangVersion>
<EnvironmentVariables>
<EnvironmentVariables>
<Variable name="MONO_WINFORMS_XIM_STYLE" value="disabled" />
</EnvironmentVariables>
</EnvironmentVariables>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Mono-Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
@ -52,6 +57,11 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
<LangVersion>6</LangVersion>
<DefineConstants>MONO</DefineConstants>
<EnvironmentVariables>
<EnvironmentVariables>
<Variable name="MONO_WINFORMS_XIM_STYLE" value="disabled" />
</EnvironmentVariables>
</EnvironmentVariables>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\icon.ico</ApplicationIcon>
@ -62,7 +72,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;CLICKONCE</DefineConstants>
<DefineConstants>DEBUG;CLICKONCE;WINDOWS</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
@ -71,7 +81,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DefineConstants>CLICKONCE</DefineConstants>
<DefineConstants>CLICKONCE;WINDOWS</DefineConstants>
<OutputPath>bin\Release\</OutputPath>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>

View file

@ -575,8 +575,11 @@ namespace PKHeX
}
// Font Related
#if WINDOWS
[DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
#endif
private static readonly PrivateFontCollection s_FontCollection = new PrivateFontCollection();
private static FontFamily[] FontFamilies
{
@ -595,11 +598,18 @@ namespace PKHeX
try
{
byte[] fontData = Resources.pgldings_normalregular;
#if WINDOWS
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);
#else
GCHandle fontHandle = GCHandle.Alloc(fontData, GCHandleType.Pinned);
s_FontCollection.AddMemoryFont(fontHandle.AddrOfPinnedObject(), fontData.Length);
fontHandle.Free();
#endif
}
catch (Exception ex) { Util.Error("Unable to add ingame font.", ex); }
}