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.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public int GetEmHeight(
	FontStyle style


Type: System.Drawing.FontStyle

The FontStyle for which to get the em height.

Return Value

Type: System.Int32
The height of the em square.

Em square is a typography term that refers to the rectangle occupied by the font's widest letter, traditionally the letter M.

The following code 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.

  • Gets the em square height for that font family.

  • Draws the value of the em height to the screen as text.

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));

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0