<!--
{
  "documentType" : "article",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/advanced-font-metrics",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Advanced Font Metrics"
}
-->

# Advanced Font Metrics

Retrieve details about ascender and descender heights, glyph bounding rectangles, glyph advancements, and more.

## Topics

### Getting the Font Metrics

[`var ascender: CGFloat`](/documentation/AppKit/NSFont/ascender)

The top y-coordinate, offset from the baseline, of the font’s longest ascender.

[`var descender: CGFloat`](/documentation/AppKit/NSFont/descender)

The bottom y-coordinate, offset from the baseline, of the font’s longest descender.

[`var capHeight: CGFloat`](/documentation/AppKit/NSFont/capHeight)

The cap height of the font.

[`var leading: CGFloat`](/documentation/AppKit/NSFont/leading)

The leading value of the font.

[`var xHeight: CGFloat`](/documentation/AppKit/NSFont/xHeight)

The x-height of the font.

### Getting Underline and Italic Metrics

[`var italicAngle: CGFloat`](/documentation/AppKit/NSFont/italicAngle)

The number of degrees that the font is slanted counterclockwise from the vertical.

[`var underlinePosition: CGFloat`](/documentation/AppKit/NSFont/underlinePosition)

The baseline offset to use when drawing underlines with the font.

[`var underlineThickness: CGFloat`](/documentation/AppKit/NSFont/underlineThickness)

The thickness to use when drawing underlines with the font.

### Getting Bounding Rectangles

[`var boundingRectForFont: NSRect`](/documentation/AppKit/NSFont/boundingRectForFont)

The font’s bounding rectangle, scaled to the font’s size.

[`func boundingRect(forCGGlyph: CGGlyph) -> NSRect`](/documentation/AppKit/NSFont/boundingRect(forCGGlyph:))

Returns the bounding rectangle for the specified glyph, scaled to the receiver’s size.

[`func getBoundingRects(NSRectArray, forCGGlyphs: UnsafePointer<CGGlyph>, count: Int)`](/documentation/AppKit/NSFont/getBoundingRects(_:forCGGlyphs:count:))

Returns an array of the bounding rectangles for the specified glyphs rendered by the receiver.

### Getting Glyph Advancements

[`var maximumAdvancement: NSSize`](/documentation/AppKit/NSFont/maximumAdvancement)

The maximum advance of any of the font’s glyphs.

[`func advancement(forCGGlyph: CGGlyph) -> NSSize`](/documentation/AppKit/NSFont/advancement(forCGGlyph:))

Returns the nominal spacing for the given glyph—the distance the current point moves after showing the glyph—accounting for the receiver’s size.

[`func getAdvancements(NSSizeArray, forCGGlyphs: UnsafePointer<CGGlyph>, count: Int)`](/documentation/AppKit/NSFont/getAdvancements(_:forCGGlyphs:count:))

Returns an array of the advancements for the specified glyphs rendered by the receiver.

### Getting the Font Matrices

[`var matrix: UnsafePointer<CGFloat>`](/documentation/AppKit/NSFont/matrix)

The transformation matrix associated with the font.

[`var textTransform: AffineTransform`](/documentation/AppKit/NSFont/textTransform)

The current transformation matrix of the font.

[`class var identityMatrix: UnsafePointer<CGFloat>`](/documentation/AppKit/NSFont/identityMatrix)

The identify matrix for the font.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)