How to make sure a font exists before using it with .NET
.net, fonts, vb.net, winforms
Solution
From an MSDN article titled "How To: Enumerate Installed Fonts", I found this code:
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
// Get the array of FontFamily objects.
FontFamily[] fontFamilies = installedFontCollection.Families;
Problem
I have a VB.NET Windows Forms project that at one point paints text directly to onto the form at runtime. Before I paint with the font though, I want to make sure that the font and font-size exists on the user's machine. If they don't, I'll try a few other similar fonts, eventually defaulting with Arial or something. What's the best way to test and validate a font on a user's computer?