FontFamily.GetEmHeight(FontStyle) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得指定樣式之 em 平方的高度,以字型設計單位表示。
public:
int GetEmHeight(System::Drawing::FontStyle style);
public int GetEmHeight (System.Drawing.FontStyle style);
member this.GetEmHeight : System.Drawing.FontStyle -> int
Public Function GetEmHeight (style As FontStyle) As Integer
參數
傳回
em 平方的高度。
範例
下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse
,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:
建立 FontFamily。
取得該字型系列的 em 平方高度。
將 em 高度的值繪製到螢幕做為文字。
public:
void GetEmHeight_Example( PaintEventArgs^ e )
{
// Create a FontFamily object.
FontFamily^ emFontFamily = gcnew FontFamily( "arial" );
// Get the em height of the font family in design units.
int emHeight = emFontFamily->GetEmHeight( FontStyle::Regular );
// Draw the result as a string to the screen.
e->Graphics->DrawString( String::Format( "emFontFamily.GetEmHeight() returns {0}.", emHeight ),
gcnew System::Drawing::Font( emFontFamily,16 ), Brushes::Black, PointF(0,0) );
}
public void GetEmHeight_Example(PaintEventArgs e)
{
// Create a FontFamily object.
FontFamily emFontFamily = new FontFamily("arial");
// Get the em height of the font family in design units.
int emHeight = emFontFamily.GetEmHeight(FontStyle.Regular);
// Draw the result as a string to the screen.
e.Graphics.DrawString(
"emFontFamily.GetEmHeight() returns " + emHeight.ToString() + ".",
new Font(emFontFamily, 16),
Brushes.Black,
new PointF(0, 0));
}
Public Sub GetEmHeight_Example(ByVal e As PaintEventArgs)
' Create a FontFamily object.
Dim emFontFamily As New FontFamily("arial")
' Get the em height of the font family in design units.
Dim emHeight As Integer = _
emFontFamily.GetEmHeight(FontStyle.Regular)
' Draw the result as a string to the screen.
e.Graphics.DrawString("emFontFamily.GetEmHeight() returns " & _
emHeight.ToString() + ".", New Font(emFontFamily, 16), _
Brushes.Black, New PointF(0, 0))
End Sub
備註
Em 方形 是一個印刷樣式字詞,是指字型最寬字母所佔用的矩形,傳統上是字母 M。