2017-01-07 23:54:09 -08:00
|
|
|
|
using System;
|
2017-07-01 19:43:51 -07:00
|
|
|
|
using System.Diagnostics;
|
2017-01-07 23:54:09 -08:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Text;
|
2019-05-19 14:37:15 -07:00
|
|
|
|
using System.IO;
|
2017-05-11 23:34:18 -05:00
|
|
|
|
using PKHeX.WinForms.Properties;
|
2017-01-07 23:54:09 -08:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.WinForms
|
|
|
|
|
{
|
2018-12-10 20:32:08 -08:00
|
|
|
|
public static class FontUtil
|
|
|
|
|
{
|
2019-05-19 14:37:15 -07:00
|
|
|
|
private static readonly PrivateFontCollection CustomFonts = new PrivateFontCollection();
|
2018-07-26 19:34:27 -07:00
|
|
|
|
|
2019-05-19 14:37:15 -07:00
|
|
|
|
static FontUtil()
|
2017-01-07 23:54:09 -08:00
|
|
|
|
{
|
2019-05-19 14:37:15 -07:00
|
|
|
|
string g6path = Path.Combine(Path.GetTempPath(), "pgldings6.ttf");
|
|
|
|
|
try
|
2017-01-07 23:54:09 -08:00
|
|
|
|
{
|
2019-05-19 14:37:15 -07:00
|
|
|
|
if (!File.Exists(g6path))
|
|
|
|
|
File.WriteAllBytes(g6path, Resources.pgldings_normalregular);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine($"Unable to add in-game font: {ex.Message}");
|
|
|
|
|
return;
|
2017-01-07 23:54:09 -08:00
|
|
|
|
}
|
2018-07-26 19:34:27 -07:00
|
|
|
|
|
2019-05-19 14:37:15 -07:00
|
|
|
|
CustomFonts.AddFontFile(g6path);
|
|
|
|
|
}
|
2018-07-26 19:34:27 -07:00
|
|
|
|
|
2019-05-19 14:37:15 -07:00
|
|
|
|
public static Font GetPKXFont(float size)
|
2017-01-07 23:54:09 -08:00
|
|
|
|
{
|
2019-05-19 14:37:15 -07:00
|
|
|
|
var family = CustomFonts.Families.Length == 0 ? FontFamily.GenericSansSerif : CustomFonts.Families[0];
|
|
|
|
|
return new Font(family, size);
|
2017-01-07 23:54:09 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|