<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextBlock/rectForLayout(at:in:textContainer:characterRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextBlock(im)rectForLayoutAtPoint:inRect:textContainer:characterRange:"
  },
  "title" : "rectForLayout(at:in:textContainer:characterRange:)"
}
-->

# rectForLayout(at:in:textContainer:characterRange:)

Returns the rectangle within which glyphs should be laid out for the specified arguments.

```
func rectForLayout(at startingPoint: NSPoint, in rect: NSRect, textContainer: NSTextContainer, characterRange charRange: NSRange) -> NSRect
```

## Parameters

`startingPoint`

The location, in container coordinates, where layout begins.

`rect`

The rectangle in which the block is constrained to lie. For top-level blocks, this is the container rectangle of `textContainer`; for nested blocks, this is the layout rectangle of the enclosing block.

`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 within which glyphs should be laid out.

## Discussion

This method is called by the typesetter before the text block is laid out to return the rectangle within which glyphs should be laid out.

---

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)