FontFamily.GetName(Int32) 方法

定义

用指定的语言返回此 FontFamily 的名称。

public:
 System::String ^ GetName(int language);
public string GetName (int language);
member this.GetName : int -> string
Public Function GetName (language As Integer) As String

参数

language
Int32

返回此名称所用的语言。

返回

一个 String,它用指定的语言表示此 FontFamily 的名称。

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 此代码执行以下操作:

  • 创建一个 FontFamily

  • 获取字体系列的名称。

  • 将字体系列的名称以文本形式绘制到屏幕上。

public:
   void GetName_Example( PaintEventArgs^ e )
   {
      // Create a FontFamily object.
      FontFamily^ myFontFamily = gcnew FontFamily( "Arial" );

      // Get the name of myFontFamily.
      String^ familyName = myFontFamily->GetName( 0 );

      // Draw the name of the myFontFamily to the screen as a string.
      e->Graphics->DrawString( String::Format( "The family name is {0}", familyName ),
            gcnew System::Drawing::Font( myFontFamily,16 ), Brushes::Black, PointF(0,0) );
   }
public void GetName_Example(PaintEventArgs e)
{
    // Create a FontFamily object.
    FontFamily myFontFamily = new FontFamily("Arial");
             
    // Get the name of myFontFamily.
    string familyName = myFontFamily.GetName(0);
             
    // Draw the name of the myFontFamily to the screen as a string.
    e.Graphics.DrawString(
        "The family name is " + familyName,
        new Font(myFontFamily, 16),
        Brushes.Black,
        new PointF(0, 0));
}
Public Sub GetName_Example(ByVal e As PaintEventArgs)

    ' Create a FontFamily object.
    Dim myFontFamily As New FontFamily("Arial")

    ' Get the name of myFontFamily.
    Dim familyName As String = myFontFamily.GetName(0)

    ' Draw the name of the myFontFamily to the screen as a string.
    e.Graphics.DrawString("The family name is " & familyName, _
    New Font(myFontFamily, 16), Brushes.Black, New PointF(0, 0))
End Sub

注解

若要指示语言中性,应为 language 参数指定 0。 有关可用语言和子语言的列表,请参阅 Winnt.h 头文件。 如果已安装 Visual Studio,通常可以在 \\VC\PlatformSDK\Include 处找到相对于 Visual Studio 安装目录的此头文件。

适用于