由于缺少标准字体而崩溃 (VB.NET)

发布于 2024-08-07 11:34:42 字数 925 浏览 2 评论 0原文

我们的自动崩溃报告系统已开始发送越来越多的此类崩溃报告:

System::Windows::Forms::Application::ThreadException event occured
SENDER: System.Threading.Thread

EXCEPTION: System.ArgumentException
MESSAGE: Font 'Arial' does not support style 'Regular'.
SOURCE: System.Drawing
CALL STACK
   at System.Drawing.Font.CreateNativeFont()
   at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
   at System.Drawing.Font..ctor(FontFamily family, Single emSize)
   at Kernel.EH_FontServer.CreateFont(String family, Single size, FontStyle style) in **
   at Kernel.EH_FontServer..cctor() in **

我的印象是 Arial 应该在 Windows 上随处可用,并且当找不到字体时,Windows 会恢复为另一种字体+确实存在的风格。

处理这个问题的正确方法是什么?我的应用程序需要为不同的显示元素定义许多标准字体。到目前为止,我已经对 Arial、Courier New、Comic Sans Serif 和 Times New Roman 进行了硬编码,并且我已经收到了所有这些字体的崩溃报告。

一旦用户安装了缺失的字体,一切就又恢复正常了。

Our automatic crash-report system has started sending in more and more reports of this kind of crash:

System::Windows::Forms::Application::ThreadException event occured
SENDER: System.Threading.Thread

EXCEPTION: System.ArgumentException
MESSAGE: Font 'Arial' does not support style 'Regular'.
SOURCE: System.Drawing
CALL STACK
   at System.Drawing.Font.CreateNativeFont()
   at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
   at System.Drawing.Font..ctor(FontFamily family, Single emSize)
   at Kernel.EH_FontServer.CreateFont(String family, Single size, FontStyle style) in **
   at Kernel.EH_FontServer..cctor() in **

I was under the impression that Arial is supposed to be available everywhere on Windows, and, when a Font cannot be found windows would revert to another font+style that does exist.

What is the correct way to handle this? My app needs to define a number of standard fonts for different display elements. So far I've hardcoded Arial, Courier New, Comic Sans Serif and Times New Roman and I've been getting crash report for all of them.

Once the user installs the missing Font, all is well again.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情绪 2024-08-14 11:34:42

避免这种情况的一种方法是将字体直接嵌入到您的应用程序中。从许可角度来看,像 Arial 这样的核心 TTF 字体应该没问题:

阅读此内容以了解许可规范:

http://www.microsoft.com/typography/RedistributionFAQ.mspx

如何将字体嵌入到 VB.NET 应用程序中:

http://www.tek-tips.com/faqs.cfm?fid=4747

One way to avoid this is to embed the fonts directly into your application. Core TTF fonts like Arial should be okay from a licensing perspective:

Read this for licensing specs:

http://www.microsoft.com/typography/RedistributionFAQ.mspx

How to embed fonts into VB.NET apps:

http://www.tek-tips.com/faqs.cfm?fid=4747
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文