C# System.Drawing.Text.AddMemoryFont
想请问一下各位高手,有人会打字体封装到程序里后用System.Drawing.Text.AddMemoryFont来动用吗?
上网查了资料如:
PrivateFontCollection pfc = new PrivateFontCollection();
string NameSpc = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();
Stream stmFont = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpc + ".AN.TTF");
if (null != stmFont)
{
byte[] rgbyt = new Byte[stmFont.Length];
stmFont.Read(rgbyt, 0, rgbyt.Length);
IntPtr pbyt = Marshal.AllocCoTaskMem(rgbyt.Length);
if (null != pbyt)
{
Marshal.Copy(rgbyt, 0, pbyt, rgbyt.Length);
pfc.AddMemoryFont(pbyt, rgbyt.Length);
Marshal.FreeCoTaskMem(pbyt);
}
}
在进行调度时,发现pfc.AddMemoryFont是添加进去,不过程序动用
Font f = new Font(pfc.Families[0], 15, FontStyle.Bold);
//设置字体
foreach (Control labb in this.Controls)
{
if (labb is Label)
{
labb.Font = f;
}
}
就是显不出结果
如果用pfc.AddFontFile("AN.TTF");就可以正常显示
不知何解,请高手指点指点。。。。。
先说声谢谢