boundingRect(forGlyphRange:in:)
Returns the bounding rectangle for the specified glyphs in a container.
Declaration
func boundingRect(forGlyphRange glyphRange: NSRange, in container: NSTextContainer) -> CGRectParameters
- 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
The bounding rectangle enclosing the given range of glyphs.
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
Performing advanced layout queries
characterIndex(for:in:fractionOfDistanceBetweenInsertionPoints:)characterRange(forGlyphRange:actualGlyphRange:)enumerateEnclosingRects(forGlyphRange:withinSelectedGlyphRange:in:using:)enumerateLineFragments(forGlyphRange:using:)fractionOfDistanceThroughGlyph(for:in:)getLineFragmentInsertionPoints(forCharacterAt:alternatePositions:inDisplayOrder:positions:characterIndexes:)glyphIndex(for:in:)glyphIndex(for:in:fractionOfDistanceThroughGlyph:)glyphRange(forBoundingRect:in:)glyphRange(forBoundingRectWithoutAdditionalLayout:in:)glyphRange(for:)glyphRange(forCharacterRange:actualCharacterRange:)range(ofNominallySpacedGlyphsContaining:)