在Winforms上使用自定义字体 [英] Using custom fonts on a Label on Winforms

查看:163
本文介绍了在Winforms上使用自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我在自己的Winform上使用自定义字体,标签,然后构建解决方案,然后.ZIP文件在\\\\\\Release \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

如果不是这样,在Labels.Text上使用自定义字体的正确方法是什么?

解决方案

将字体嵌入为资源(或将其包含在bin目录中),然后使用 AddFontFile 和 AddMemoryFont 函数)。您可以像使用字体一样安装在机器上。


PrivateFontCollection类允许
应用程序安装一个专用的
版本的现有字体没有
要求取代系统
版本的字体。例如,除了系统使用的Arial
字体之外,GDI +
还可以创建
Arial字体的私有版本。
PrivateFontCollection也可以用
来安装
操作系统中不存在的字体。


I have a label on my Winform and I want to use a custom font called XCalibur to make it appear more shnazzy.

If I use a custom font on a label and then build the solution and then .ZIP the files in \bin\Release will the end user see the labels with my custom app I used regardless if they have that font installed or not?

If this isn't the case, what's the proper way to use Custom Fonts on Labels.Text?

解决方案

Embed the font as a resource (or just include it in the bin directory), and then use the PrivateFontCollection to load the font (See the AddFontFile and AddMemoryFont functions). You then use the font normally like it was installed on the machine.

The PrivateFontCollection class allows applications to install a private version of an existing font without the requirement to replace the system version of the font. For example, GDI+ can create a private version of the Arial font in addition to the Arial font that the system uses. PrivateFontCollection can also be used to install fonts that do not exist in the operating system.

Source

这篇关于在Winforms上使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆