<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextBlock/boundsRect(forContentRect:in:textContainer:characterRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextBlock(im)boundsRectForContentRect:inRect:textContainer:characterRange:"
  },
  "title" : "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.

```
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 [`rectForLayout(at:in:textContainer:characterRange:)`](/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 [`NSTextStorage`](/documentation/AppKit/NSTextStorage) object whose glyphs are to be drawn.

## Return Value

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

## 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.

---

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)