Contents

boundingRect(forGlyphRange:in:)

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

Declaration

func boundingRect(forGlyphRange glyphRange: NSRange, in container: NSTextContainer) -> NSRect

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

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

Performing advanced layout queries