<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIFontDescriptor/preferredFontDescriptor(withTextStyle:compatibleWith:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIFontDescriptor(cm)preferredFontDescriptorWithTextStyle:compatibleWithTraitCollection:"
  },
  "title" : "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.

```
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

The new font descriptor.

## Discussion

---

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)