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

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

问题描述

我的 Winform 上有一个标签,我想使用一种名为 XCalibur 的自定义字体,让它看起来更时髦.

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

如果我在标签上使用自定义字体,然后构建解决方案,然后对 inRelease 中的文件进行 .ZIP 压缩,最终用户将使用我使用的自定义应用程序看到标签,无论他们是否安装了该字体?

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

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

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

推荐答案

将字体作为资源嵌入(或者只是将其包含在 bin 目录中),然后使用 PrivateFontCollection 以加载字体(请参阅AddFontFilecode> 和 AddMemoryFont 函数).然后,您可以像安装在机器上一样正常使用该字体.

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.

PrivateFontCollection 类允许安装私人应用程序现有字体的版本,没有更换系统的要求字体的版本.例如,GDI+可以创建私人版本的Arial 字体除了 Arial系统使用的字体.也可以使用 PrivateFontCollection安装不存在的字体操作系统.

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.

来源

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

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