views:

127

answers:

3

How can I find the font that the user has set in their Windows Display Properties using C# in .NET?

I want to display a form using the fonts that the user has selected. The fonts I want are those selected in the Windows Display Properties form for 3D-objects, menus and window title bars. But I cannot find a way to access them. There is a System.Windows.Forms.Control.DefaultFont property but that is returning the Windows default font (which is, I think, MS Sans Serif on XP).

+1  A: 

Take a look at the Families property of the System.Drawing.Text.InstalledFontCollection object. You should be able to loop through the Families collection to get all the user's fonts. Unfortunately this does not identify the specific font's you are looking for.

http://msdn.microsoft.com/en-us/library/system.drawing.text.fontcollection.families.aspx

A: 

May I suggest you look at this article from Michael Kaplan's blog? It covers users fonts in WinForms applications.

MSalters
+1  A: 

Using the SystemFonts class, you can get the fonts from the theme that the user selected. Also customizations the user made itself are returned.

BTW: I (using XP) cannot select a font for 3D objects, the others are available.

GvS