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 窗体,它需要 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)占用的矩形。