enumerateEnclosingRects(forGlyphRange:withinSelectedGlyphRange:in:using:)
Enumerates enclosing rectangles for the specified glyph range in a text container.
Declaration
func enumerateEnclosingRects(forGlyphRange glyphRange: NSRange, withinSelectedGlyphRange selectedRange: NSRange, in textContainer: NSTextContainer, using block: @escaping (NSRect, UnsafeMutablePointer<ObjCBool>) -> Void)Parameters
- glyphRange:
The glyph range for which to return enclosing rectangles.
- selectedRange:
Selected glyphs within
glyphRange, which can affect the size of the rectangles. If not interested in selection rectangles, pass{NSNotFound, 0}as the selected range. - textContainer:
The text container in which the glyphs are laid out.
- block:
The block to apply to the glyph range. The block has two arguments:
Discussion
These rectangles are always in container coordinates. They can be used to draw the text background or highlight for the given range of characters. The rectangles don’t necessarily enclose glyphs that draw outside their line fragment rectangles; use boundingRect(forGlyphRange:in:) to determine the area that contains all drawing performed for a range of glyphs.
If a selected range is given in the second argument, the rectangles returned are correct for drawing the selection. Selection rectangles are generally more complicated than enclosing rectangles, and supplying a selected range determines whether the method does this extra work. This method does the minimum amount of work required to answer the question.
Performs glyph generation and layout if needed.
See Also
Performing advanced layout queries
boundingRect(forGlyphRange:in:)characterIndex(for:in:fractionOfDistanceBetweenInsertionPoints:)characterRange(forGlyphRange:actualGlyphRange:)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:)