---
title: "glyphRange(forBoundingRect:in:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nslayoutmanager/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.

## Declaration

```swift
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

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

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.

## See Also

### Performing advanced layout queries

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