---
title: "boundsRect(forContentRect:in:textContainer:characterRange:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextblock/boundsrect(forcontentrect:in:textcontainer:characterrange:)"
---

# boundsRect(forContentRect:in:textContainer:characterRange:)

Returns the rectangle the text in the block actually occupies, including padding, borders, and margins.

## Declaration

```swift
func boundsRect(forContentRect contentRect: NSRect, in rect: NSRect, textContainer: NSTextContainer, characterRange charRange: NSRange) -> NSRect
```

## Parameters

- `contentRect`: The actual rectangle in which the text was laid out, as determined by doc://com.apple.appkit/documentation/AppKit/NSTextBlock/rectForLayout(at:in:textContainer:characterRange:).
- `rect`: The initial rectangle in textContainer proposed by the typesetter.
- `textContainer`: The text container being used for the layout.
- `charRange`: The range of the characters in the doc://com.apple.appkit/documentation/AppKit/NSTextStorage object whose glyphs are to be drawn.

## Return Value

Return Value The rectangle the text in the block actually occupies, including padding, borders, and margins.

## Discussion

Discussion This methods is called by the typesetter after the text block is laid out to return the rectangle the text in the block actually occupies, including padding, borders, and margins.

## See Also

### Determining size and position of a text block

- [rectForLayout(at:in:textContainer:characterRange:)](appkit/nstextblock/rectforlayout(at:in:textcontainer:characterrange:).md)
