InstalledFontCollection 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示系统上安装的字体。 无法继承此类。
public ref class InstalledFontCollection sealed : System::Drawing::Text::FontCollection
	public sealed class InstalledFontCollection : System.Drawing.Text.FontCollection
	type InstalledFontCollection = class
    inherit FontCollection
	Public NotInheritable Class InstalledFontCollection
Inherits FontCollection
		- 继承
 
示例
以下示例演示如何获取支持常规 FontStyle的字体列表。
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。
InstalledFontCollection ifc = new InstalledFontCollection();
private void EnumerateInstalledFonts(PaintEventArgs e)
{
    FontFamily[] families = ifc.Families;
    float x = 0.0F;
    float y = 0.0F;
    for (int i = 0; i < ifc.Families.Length; i++)
    {
        if (ifc.Families[i].IsStyleAvailable(FontStyle.Regular))
        {
            e.Graphics.DrawString(ifc.Families[i].Name, new Font(ifc.Families[i], 12), 
                Brushes.Black, x, y);
            y += 20;
            if (y % 700 == 0)
            {
                x += 140;
                y = 0;
            }
        }
    }
}
    Private ifc As New InstalledFontCollection()
    
Private Sub EnumerateInstalledFonts(ByVal e As PaintEventArgs)
      Dim families As FontFamily() = ifc.Families
      Dim x As Single = 0.0F
      Dim y As Single = 0.0F
        For i As Integer = 0 To ifc.Families.Length - 1
              If ifc.Families(i).IsStyleAvailable(FontStyle.Regular) Then
                e.Graphics.DrawString(ifc.Families(i).Name, New Font(ifc.Families(i), 12),  _ 
          Brushes.Black, x, y)
                y += 20
                If y Mod 700 = 0 Then
                      x += 140
                      y = 0
                    End If
              End If
        Next
   End Sub
	注解
通过 InstalledFontCollection,可以获取运行应用程序的计算机上安装了其 Families 属性的字体系列列表。 有关字体和文本的其他信息(包括示例代码)请参阅 使用字体和文本。
请勿使用 InstalledFontCollection 类将字体安装到 Windows。 请改用 GDI AddFontResource 函数。 
              InstalledFontCollection 对象仅看到在创建对象之前安装在 Windows 中的字体。
注意
在 .NET 6 及更高版本中,System.Drawing.Common 包(包括此类型)仅在 Windows 操作系统上受支持。 在跨平台应用中使用此类型会导致编译时警告和运行时异常。 有关详细信息,请参阅仅在 Windows上支持的 system.Drawing.Common 
构造函数
| InstalledFontCollection() | 
		 初始化 InstalledFontCollection 类的新实例。  | 
        	
属性
| Families | 
		 获取与此 FontCollection关联的 FontFamily 对象的数组。 (继承自 FontCollection) | 
        	
方法
| Dispose() | 
		 释放此 FontCollection使用的所有资源。 (继承自 FontCollection) | 
        	
| Dispose(Boolean) | 
		 释放 FontCollection 使用的非托管资源,并选择性地释放托管资源。 (继承自 FontCollection) | 
        	
| Equals(Object) | 
		 确定指定的对象是否等于当前对象。 (继承自 Object) | 
        	
| GetHashCode() | 
		 用作默认哈希函数。 (继承自 Object) | 
        	
| GetType() | 
		 获取当前实例的 Type。 (继承自 Object) | 
        	
| MemberwiseClone() | 
		 创建当前 Object的浅表副本。 (继承自 Object) | 
        	
| ToString() | 
		 返回一个表示当前对象的字符串。 (继承自 Object) | 
        	
适用于
另请参阅
- 使用字体和文本