<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSFontManager/fontNamed(_:hasTraits:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFontManager(im)fontNamed:hasTraits:"
  },
  "title" : "fontNamed(_:hasTraits:)"
}
-->

# fontNamed(_:hasTraits:)

Indicates whether the given font has all the specified traits.

```
func fontNamed(_ fName: String, hasTraits someTraits: NSFontTraitMask) -> Bool
```

## Parameters

`fName`

The name of the font.

`someTraits`

The font traits to test, specified by combining the font trait mask values described in `Constants` using the C bitwise OR operator.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the font named `typeface` has all the traits specified in `fontTraitMask`; <doc://com.apple.documentation/documentation/Swift/false> if it doesn’t.

## Discussion

Using `NSUnboldFontMask` returns <doc://com.apple.documentation/documentation/Swift/true> if the font is not bold, <doc://com.apple.documentation/documentation/Swift/false> otherwise. Using `NSUnitalicFontMask` returns <doc://com.apple.documentation/documentation/Swift/true> if the font is not italic, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

---

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)