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 Forms使用,而且需要 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 安裝目錄的這個標頭檔。

適用於