FontFamily.GetEmHeight Method (FontStyle)


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 Function GetEmHeight (
	style As FontStyle
) As Integer


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 PaintEventArgse, 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 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 = _

    ' 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

.NET Framework
Available since 1.1
Return to top