---
title: "applyFontTraits(_:range:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmutableattributedstring/applyfonttraits(_:range:)"
---

# applyFontTraits(_:range:)

Applies the specified font-related attributes to characters in the string.

## Declaration

```swift
func applyFontTraits(_ traitMask: NSFontTraitMask, range: NSRange)
```

## Parameters

- `traitMask`: The font attributes to apply. For information about the font traits you can apply, see doc://com.apple.documentation/documentation/AppKit/NSFontManager.
- `range`: The range of characters.

## Discussion

Discussion Raises an rangeException if any part of range lies beyond the end of the receiver’s characters.

## See Also

### Changing Attributes

- [setAttributes(_:range:)](foundation/nsmutableattributedstring/setattributes(_:range:).md)
- [addAttribute(_:value:range:)](foundation/nsmutableattributedstring/addattribute(_:value:range:).md)
- [addAttributes(_:range:)](foundation/nsmutableattributedstring/addattributes(_:range:).md)
- [removeAttribute(_:range:)](foundation/nsmutableattributedstring/removeattribute(_:range:).md)
- [setAlignment(_:range:)](foundation/nsmutableattributedstring/setalignment(_:range:).md)
- [setBaseWritingDirection(_:range:)](foundation/nsmutableattributedstring/setbasewritingdirection(_:range:).md)
- [subscriptRange(_:)](foundation/nsmutableattributedstring/subscriptrange(_:).md)
- [superscriptRange(_:)](foundation/nsmutableattributedstring/superscriptrange(_:).md)
- [unscriptRange(_:)](foundation/nsmutableattributedstring/unscriptrange(_:).md)
