This documentation is archived and is not being maintained.

FontFamily.GetEmHeight Method

Gets the height, in font design units, of the em square for the specified style. For information about font metrics, see Obtaining Font Metrics.

[Visual Basic]
Public Function GetEmHeight( _
   ByVal style As FontStyle _
) As Integer
public int GetEmHeight(
 FontStyle style
public: int GetEmHeight(
 FontStyle style
public function GetEmHeight(
   style : FontStyle
) : int;


The FontStyle enumeration for which to get the em height.

Return Value

The height of the em square.


[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a FontFamily object.
  • Gets the em square height for that font family.
  • Draws the value of the em height to the screen as text.
[Visual Basic] 
Public Sub GetEmHeight_Example(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 = _
' 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
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.
"emFontFamily.GetEmHeight() returns " + emHeight.ToString() + ".",
new Font(emFontFamily, 16),
new PointF(0, 0));

[Visual Basic, C#] }

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

FontFamily Class | FontFamily Members | System.Drawing Namespace