---
title: "boundingRect(forGlyphRange:in:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nslayoutmanager/boundingrect(forglyphrange:in:)"
---

# boundingRect(forGlyphRange:in:)

Returns the bounding rectangle for the specified glyphs in a container.

## Declaration

```swift
func boundingRect(forGlyphRange glyphRange: NSRange, in container: NSTextContainer) -> CGRect
```

## Parameters

- `glyphRange`: The range of glyphs for which to return the bounding rectangle.
- `container`: The text container in which the glyphs are laid out.

## Return Value

Return Value The bounding rectangle enclosing the given range of glyphs.

## Discussion

Discussion This method returns a single bounding rectangle (in container coordinates) enclosing all glyphs and other marks drawn in the given text container for the given glyph range, including glyphs that draw outside their line fragment rectangles and text attributes such as underlining. The range is intersected with the container’s range before computing the bounding rectangle. This method can be used to translate glyph ranges into display rectangles for invalidation and redrawing  when a range of glyphs changes. Bounding rectangles are always in container coordinates. Performs glyph generation and layout if needed.

## See Also

### Related Documentation

- [drawsOutsideLineFragment(forGlyphAt:)](uikit/nslayoutmanager/drawsoutsidelinefragment(forglyphat:).md)

### Performing advanced layout queries

- [characterIndex(for:in:fractionOfDistanceBetweenInsertionPoints:)](uikit/nslayoutmanager/characterindex(for:in:fractionofdistancebetweeninsertionpoints:).md)
- [characterRange(forGlyphRange:actualGlyphRange:)](uikit/nslayoutmanager/characterrange(forglyphrange:actualglyphrange:).md)
- [enumerateEnclosingRects(forGlyphRange:withinSelectedGlyphRange:in:using:)](uikit/nslayoutmanager/enumerateenclosingrects(forglyphrange:withinselectedglyphrange:in:using:).md)
- [enumerateLineFragments(forGlyphRange:using:)](uikit/nslayoutmanager/enumeratelinefragments(forglyphrange:using:).md)
- [fractionOfDistanceThroughGlyph(for:in:)](uikit/nslayoutmanager/fractionofdistancethroughglyph(for:in:).md)
- [getLineFragmentInsertionPoints(forCharacterAt:alternatePositions:inDisplayOrder:positions:characterIndexes:)](uikit/nslayoutmanager/getlinefragmentinsertionpoints(forcharacterat:alternatepositions:indisplayorder:positions:characterindexes:).md)
- [glyphIndex(for:in:)](uikit/nslayoutmanager/glyphindex(for:in:).md)
- [glyphIndex(for:in:fractionOfDistanceThroughGlyph:)](uikit/nslayoutmanager/glyphindex(for:in:fractionofdistancethroughglyph:).md)
- [glyphRange(forBoundingRect:in:)](uikit/nslayoutmanager/glyphrange(forboundingrect:in:).md)
- [glyphRange(forBoundingRectWithoutAdditionalLayout:in:)](uikit/nslayoutmanager/glyphrange(forboundingrectwithoutadditionallayout:in:).md)
- [glyphRange(for:)](uikit/nslayoutmanager/glyphrange(for:).md)
- [glyphRange(forCharacterRange:actualCharacterRange:)](uikit/nslayoutmanager/glyphrange(forcharacterrange:actualcharacterrange:).md)
- [range(ofNominallySpacedGlyphsContaining:)](uikit/nslayoutmanager/range(ofnominallyspacedglyphscontaining:).md)
