標籤:winform style class blog code java
http://social.msdn.microsoft.com/Forums/officeapps/zh-CN/61b717ae-f925-443a-baad-2b85f2564826/cwinformsvs2010
namespace WindowsFormsApplication2{ public partial class Form1 : Form { PrivateFontCollection pfc = new PrivateFontCollection(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string fontName = "WindowsFormsApplication2.漢儀水波體簡.ttf"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream stream = assembly.GetManifestResourceStream(fontName); byte[] fontData = new byte[stream.Length]; stream.Read(fontData, 0, (int)stream.Length); stream.Close(); unsafe { fixed (byte* pFontData = fontData) { pfc.AddMemoryFont((System.IntPtr)pFontData, fontData.Length); } } } private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Font font = new Font(pfc.Families[0], 20); g.DrawString("測試文字", font, new SolidBrush(Color.Black), 200, 100); } }}