/* Load custom font by font file stream*/ public void setFontByStream() { string AppPath = Application.StartupPath; string fontPath = AppPath + @"\汉仪刚艺体-35W.ttf"; if (System.IO.File.Exists(fontPath)) { System.IO.Stream fileStream = new System.IO.StreamReader(fontPath).BaseStream; byte[] bytes = new byte[fileStream.Length]; fileStream.Read(bytes, 0, bytes.Length); // 设置当前流的位置为流的开始 fileStream.Seek(0, System.IO.SeekOrigin.Begin); System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection(); unsafe { fixed(byte *pFontData = &bytes[0]) { pfc.AddMemoryFont((System.IntPtr)pFontData, bytes.Length); } } Font myFont = new Font(pfc.Families[0], 20f); this.label3.Font = myFont; } }