4
votes

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.

1

1 Answers

3
votes

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