C# Language
글꼴 리소스 포함
수색…
매개 변수
매개 변수 | 세부 |
---|---|
글꼴 바이트 | 이진 바이트 배열 |
리소스에서 'Fontfamily'인스턴스화
public FontFamily Maneteke = GetResourceFontFamily(Properties.Resources.manteka);
통합 방법
public static FontFamily GetResourceFontFamily(byte[] fontbytes)
{
PrivateFontCollection pfc = new PrivateFontCollection();
IntPtr fontMemPointer = Marshal.AllocCoTaskMem(fontbytes.Length);
Marshal.Copy(fontbytes, 0, fontMemPointer, fontbytes.Length);
pfc.AddMemoryFont(fontMemPointer, fontbytes.Length);
Marshal.FreeCoTaskMem(fontMemPointer);
return pfc.Families[0];
}
'버튼'을 이용한 사용법
public static class Res
{
/// <summary>
/// URL: https://www.behance.net/gallery/2846011/Manteka
/// </summary>
public static FontFamily Maneteke = GetResourceFontFamily(Properties.Resources.manteka);
public static FontFamily GetResourceFontFamily(byte[] fontbytes)
{
PrivateFontCollection pfc = new PrivateFontCollection();
IntPtr fontMemPointer = Marshal.AllocCoTaskMem(fontbytes.Length);
Marshal.Copy(fontbytes, 0, fontMemPointer, fontbytes.Length);
pfc.AddMemoryFont(fontMemPointer, fontbytes.Length);
Marshal.FreeCoTaskMem(fontMemPointer);
return pfc.Families[0];
}
}
public class FlatButton : Button
{
public FlatButton() : base()
{
Font = new Font(Res.Maneteke, Font.Size);
}
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
this.Font = new Font(Res.Maneteke, this.Font.Size);
}
}
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow