如何在.NET应用程序中找到用户的字体?

时间:2021-04-02 20:14:04

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

如何在.NET中使用C#找到用户在其Windows显示属性中设置的字体?

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).

我想使用用户选择的字体显示表单。我想要的字体是在Windows显示属性表单中为3D对象,菜单和窗口标题栏选择的字体。但我找不到访问它们的方法。有一个System.Windows.Forms.Control.DefaultFont属性,但它返回Windows默认字体(我认为,MS Sans Serif在XP上)。

3 个解决方案

#1


1  

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

使用SystemFonts类,您可以从用户选择的主题中获取字体。还返回用户自己进行的自定义。

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

顺便说一句:我(使用XP)无法为3D对象选择字体,其他可用。

#2


1  

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.

查看System.Drawing.Text.InstalledFontCollection对象的Families属性。您应该能够遍历Families集合以获取所有用户的字体。不幸的是,这并不能确定您正在寻找的特定字体。

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

#3


0  

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

我建议你看一下Michael Kaplan博客上的这篇文章吗?它涵盖了WinForms应用程序中的用户字体。

#1


1  

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

使用SystemFonts类,您可以从用户选择的主题中获取字体。还返回用户自己进行的自定义。

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

顺便说一句:我(使用XP)无法为3D对象选择字体,其他可用。

#2


1  

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.

查看System.Drawing.Text.InstalledFontCollection对象的Families属性。您应该能够遍历Families集合以获取所有用户的字体。不幸的是,这并不能确定您正在寻找的特定字体。

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

#3


0  

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

我建议你看一下Michael Kaplan博客上的这篇文章吗?它涵盖了WinForms应用程序中的用户字体。