FontFamily.GetName(Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回此 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 安装目录的此头文件。