运行时显示错误的字体 [英] Wrong font displayed at runtime

查看:48
本文介绍了运行时显示错误的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某些标签(winforms)中使用Calibri字体,并且在运行程序时,该标签以其他字体显示.在没有Office的计算机上进行测试时,我曾见过此问题(因此未安装Calibri),但现在到处都可以看到它,甚至在安装Calibri的计算机上也是如此(并且在设计器中看到了带有Calibri的标签;然后在调试模式,我看到了另一种字体).

I am using the Calibri font in some labels (winforms) and when I run my program, this label are displayed with a different font. I had seen this problem when testing on computers without Office (hence no Calibri installed) but now I see it everywhere, even on my computer where Calibri is well installed (and I see the labels with Calibri in the designer ; then when I run in debug mode, I see another font).

标签过去一直显示得很好,我直到今天才看到这个问题(但是,我不确定几天,但我不确定,但不会很长一段时间,我确定).

The labels used to be displayed well, I've seen this problem only today (but could have been unnoticed for a few days, I'm not sure, but not long, that I'm sure).

昨天有一些Windows更新,一些是针对Office的,但我不确定是否相关.底线是我有calibri,calibri在设计器中显示,而其他字体在运行时显示.而且我似乎对Segoe UI也有同样的问题,但只有在使用SemiBold样式时才可以.

There were a few windows updates yesterday, and some were for Office, but I'm not sure if it's relevant. Bottomline is I have calibri, calibri is displayed in designer, and some other font is displayed at runtime.. And I seem to have the same problem with Segoe UI, but only when using the SemiBold style..

这是结果的图像,左边是运行时,右边是VS设计器:

Here is an image of the result, on the left is runtime and on the right is the VS designer:

当我尝试使用Calibri bold时,这一点更加明显.这次运行时在右侧,设计器视图在左侧:

It is even more obvious when I try to use Calibri bold ; this time runtime is on the right and designer view on the left :

推荐答案

无论何时在Visual Studio中创建新的Windows窗体应用程序,模板都会包含以下几行

Whenever you create a new Windows Forms application in Visual Studio, the template includes the following lines

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(/*new instance of your form*/);

该行尤其可能会影响应用程序中文本的呈现方式.

This line in particular will likely affect how text is rendered in your application.

Application.SetCompatibleTextRenderingDefault(false);

这篇关于运行时显示错误的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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