<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManager/glyphRange(forBoundingRect:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager(im)glyphRangeForBoundingRect:inTextContainer:"
  },
  "title" : "glyphRange(forBoundingRect:in:)"
}
-->

# glyphRange(forBoundingRect:in:)

Returns the smallest contiguous range for glyphs lying wholly or partially within the specified rectangle of the text container.

```
func glyphRange(forBoundingRect bounds: NSRect, in container: NSTextContainer) -> NSRange
```

## Parameters

`bounds`

The bounding rectangle for which to return glyphs.

`container`

The text container in which the glyphs are laid out.

## Return Value

The range of glyphs that would need to be displayed in order to draw all glyphs that fall (even partially) within the given bounding rectangle. The range returned can include glyphs that don’t fall inside or intersect `bounds`, although the first and last glyphs in the range always do. At most this method returns the glyph range for the whole container.

## Discussion

This method is used to determine which glyphs need to be displayed within a given rectangle.

Performs glyph generation and layout if needed. Bounding rectangles are always in container coordinates.

---

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)