---
title: "preferredFontDescriptor(withTextStyle:compatibleWith:)"
framework: uikit
role: symbol
role_heading: Type Method
path: "uikit/uifontdescriptor/preferredfontdescriptor(withtextstyle:compatiblewith:)"
---

# preferredFontDescriptor(withTextStyle:compatibleWith:)

Returns a font descriptor that contains the text style and the content size category that the provided trait collection specifies.

## Declaration

```swift
class func preferredFontDescriptor(withTextStyle style: UIFont.TextStyle, compatibleWith traitCollection: UITraitCollection?) -> UIFontDescriptor
```

## Parameters

- `style`: The text style for which to return a font descriptor.
- `traitCollection`: The trait collection containing the content size category information.

## Return Value

Return Value The new font descriptor.

## See Also

### Creating a font descriptor

- [preferredFontDescriptor(withTextStyle:)](uikit/uifontdescriptor/preferredfontdescriptor(withtextstyle:).md)
- [init(name:matrix:)](uikit/uifontdescriptor/init(name:matrix:).md)
- [init(name:size:)](uikit/uifontdescriptor/init(name:size:).md)
- [addingAttributes(_:)](uikit/uifontdescriptor/addingattributes(_:).md)
- [withDesign(_:)](uikit/uifontdescriptor/withdesign(_:).md)
- [withFamily(_:)](uikit/uifontdescriptor/withfamily(_:).md)
- [withFace(_:)](uikit/uifontdescriptor/withface(_:).md)
- [withMatrix(_:)](uikit/uifontdescriptor/withmatrix(_:).md)
- [withSize(_:)](uikit/uifontdescriptor/withsize(_:).md)
- [withSymbolicTraits(_:)](uikit/uifontdescriptor/withsymbolictraits(_:).md)
