37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Drawing.Text;
|
|
|
|
namespace Cheongbuk_MegaPark_Key_Management
|
|
{
|
|
public class FontLibrary
|
|
{
|
|
private static FontLibrary inst = new FontLibrary();
|
|
public PrivateFontCollection privateFont = new PrivateFontCollection();
|
|
|
|
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
|
|
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont,
|
|
IntPtr pdv, [System.Runtime.InteropServices.In] ref uint pcFonts);
|
|
|
|
public static FontFamily[] Families
|
|
{
|
|
get { return inst.privateFont.Families; }
|
|
}
|
|
|
|
public FontLibrary()
|
|
{
|
|
AddFontFromMemory(Properties.Resources.DS_DIGIB);
|
|
AddFontFromMemory(Properties.Resources.NotoSansCJKkr_Black);
|
|
}
|
|
|
|
private void AddFontFromMemory(byte[] fontData)
|
|
{
|
|
IntPtr fontPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontData.Length);
|
|
System.Runtime.InteropServices.Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
|
|
uint dummy = 0;
|
|
privateFont.AddMemoryFont(fontPtr, fontData.Length);
|
|
AddFontMemResourceEx(fontPtr, (uint)fontData.Length, IntPtr.Zero, ref dummy);
|
|
System.Runtime.InteropServices.Marshal.FreeCoTaskMem(fontPtr);
|
|
}
|
|
}
|
|
} |