---
title: "preferredFont(forTextStyle:options:)"
framework: appkit
role: symbol
role_heading: Type Method
path: "appkit/nsfont/preferredfont(fortextstyle:options:)"
---

# preferredFont(forTextStyle:options:)

Returns the font associated with the text style.

## Declaration

```swift
class func preferredFont(forTextStyle style: NSFont.TextStyle, options: [NSFont.TextStyleOptionKey : Any] = [:]) -> NSFont
```

## Parameters

- `style`: The text style for which to return a font. See doc://com.apple.appkit/documentation/AppKit/NSFont/TextStyle for available values.
- `options`: A dictionary you use to further configure the returned font. See doc://com.apple.appkit/documentation/AppKit/NSFont/TextStyleOptionKey for a list of valid keys. Pass an empty dictionary to use the default configuration.

## Return Value

Return Value The font associated with the text style.

## See Also

### Creating System Fonts

- [systemFont(ofSize:)](appkit/nsfont/systemfont(ofsize:).md)
- [systemFont(ofSize:weight:)](appkit/nsfont/systemfont(ofsize:weight:).md)
- [boldSystemFont(ofSize:)](appkit/nsfont/boldsystemfont(ofsize:).md)
- [monospacedSystemFont(ofSize:weight:)](appkit/nsfont/monospacedsystemfont(ofsize:weight:).md)
- [monospacedDigitSystemFont(ofSize:weight:)](appkit/nsfont/monospaceddigitsystemfont(ofsize:weight:).md)
- [systemFontSize](appkit/nsfont/systemfontsize.md)
- [smallSystemFontSize](appkit/nsfont/smallsystemfontsize.md)
- [NSFont.Weight](appkit/nsfont/weight.md)
- [NSFont.TextStyle](appkit/nsfont/textstyle.md)
- [NSFont.TextStyleOptionKey](appkit/nsfont/textstyleoptionkey.md)
