---
title: "setFont(_:range:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstext/setfont(_:range:)"
---

# setFont(_:range:)

Sets the font of characters within aRange to aFont.

## Declaration

```swift
func setFont(_ font: NSFont, range: NSRange)
```

## Discussion

Discussion This method applies only to a rich text object. This method does not include undo support by default. Clients must invoke shouldChangeText(inRanges:replacementStrings:) or shouldChangeText(in:replacementString:) to include this method in an undoable action.

## See Also

### Changing the font

- [changeFont(_:)](appkit/nstext/changefont(_:).md)
- [font](appkit/nstext/font.md)
