동적으로 폰트 파일 읽어서 컨트롤에 적용하기

폰트파일 로드
PrivateFontCollection fonts;
FontFamily family = LoadFontFamily(@"F:\azuki.ttf", out fonts);
theFont = new Font(family, 20.0f);
// when done:
theFont.Dispose();
family.Dispose();
family.Dispose();

/////////////////////////////////////////////////////////////////////////////////////////

public static FontFamily LoadFontFamily(Stream stream, out PrivateFontCollection fontCollection)
{
var buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
return LoadFontFamily(buffer, out fontCollection);
}

//public static unsafe FontFamily LoadFontFamilyUnsafe(byte[] buffer, out PrivateFontCollection fontCollection)
//{
// fixed (byte* ptr = buffer)
// {
// fontCollection = new PrivateFontCollection();
// fontCollection.AddMemoryFont(new IntPtr(ptr), buffer.Length);
// return fontCollection.Families[0];
// }
//}

public static FontFamily LoadFontFamily(byte[] buffer, out PrivateFontCollection fontCollection)
{
// pin array so we can get its address
var handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);