Instance Method

rectArrayForCharacterRange:withinSelectedCharacterRange:inTextContainer:rectCount:

Returns an array of rectangles and, by reference, the number of such rectangles, that define the region in the given container enclosing the given character range.

Declaration

- (NSRectArray)rectArrayForCharacterRange:(NSRange)charRange withinSelectedCharacterRange:(NSRange)selCharRange inTextContainer:(NSTextContainer *)container rectCount:(NSUInteger *)rectCount;

Parameters

charRange

The character range for which to return rectangles.

selCharRange

Selected characters within charRange, which can affect the size of the rectangles; it must be equal to or contain charRange. If the caller is interested in this more from an enclosing point of view rather than a selection point of view, pass {NSNotFound, 0} as the selected range.

container

The text container in which the text is laid out.

rectCount

The number of rectangles returned.

Return Value

The array of rectangles enclosing the given range.

Discussion

These rectangles can be used to draw the text background or highlight for the given range of characters. If a selected range is given in selCharRange, the rectangles returned are correct for drawing the selection. Selection rectangles are generally more complicated than enclosing rectangles and supplying a selected range is the clue this method uses to determine whether to go to the trouble of doing this special work.

This method will do the minimum amount of work required to answer the question. The resulting array is owned by the layout manager and will be reused when this method, rectArrayForGlyphRange:withinSelectedGlyphRange:inTextContainer:rectCount:, or boundingRectForGlyphRange:inTextContainer: is called. One of these methods may be called indirectly. If you aren't going to use the rectangles right away, you should copy them to another location. These rectangles are always in container coordinates.

The number of rectangles returned isn’t necessarily the number of lines enclosing the specified range. Contiguous lines can share an enclosing rectangle, and lines broken into several fragments have a separate enclosing rectangle for each fragment.

These rectangles don’t necessarily enclose glyphs that draw outside their line fragment rectangles; use boundingRectForGlyphRange:inTextContainer: to determine the area that contains all drawing performed for a range of glyphs.

Performs glyph generation and layout if needed.

See Also

Deprecated

attributedString

The text storage object from which the NSGlyphGenerator object procures characters for glyph generation.

- invalidateGlyphsOnLayoutInvalidationForGlyphRange:

Specifies explicitly when portions of the glyph stream depend on layout.

Deprecated
- invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:

Invalidates the layout information for the glyphs mapped to the given range of characters.

Deprecated
- textStorage:edited:range:changeInLength:invalidatedRange:

Invalidates glyph and layout information for a portion of the text in the given text storage object.

Deprecated
- insertGlyph:atGlyphIndex:characterIndex:

Inserts a single glyph into the glyph stream at the given index and maps it to the character at the given character index.

Deprecated
- insertGlyphs:length:forStartingGlyphAtIndex:characterIndex:

Inserts the given glyphs into the glyph cache at the given index and maps them to characters beginning at the given character index.

Deprecated
- glyphAtIndex:

Returns the glyph at glyphIndex.

Deprecated
- glyphAtIndex:isValidIndex:

If the given index is valid, returns the glyph at that location and optionally returns a flag indicating whether the requested index is in range.

Deprecated
- replaceGlyphAtIndex:withGlyph:

Replaces the glyph at the given index with a new glyph.

Deprecated
- getGlyphs:range:

Fills the passed-in buffer with a sequence of glyphs

Deprecated
- getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:

Returns the glyphs and information needed to perform layout for the given glyph range.

Deprecated
- getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:bidiLevels:

Returns the glyphs and information needed to perform layout for the given glyph range.

Deprecated
- deleteGlyphsInRange:

Deletes the glyphs in the given range from the receiver’s glyph store.

Deprecated
- setCharacterIndex:forGlyphAtIndex:

Sets the index of the character corresponding to the glyph at the given glyph index.

Deprecated
- intAttribute:forGlyphAtIndex:

Returns the value of the attribute identified by the given attribute tag for the glyph at the given index.

Deprecated
- setIntAttribute:value:forGlyphAtIndex:

Sets a custom attribute value for a given glyph.

Deprecated
- setLocations:startingGlyphIndexes:count:forGlyphRange:

Sets locations for many glyph ranges at once.

Deprecated
- rectArrayForGlyphRange:withinSelectedGlyphRange:inTextContainer:rectCount:

Returns an array of rectangles and, by reference, the number of such rectangles, that define the region in the given container enclosing the given glyph range.

Deprecated
- layoutOptions

The layout manager’s current layout options.

usesScreenFonts

A Boolean that controls using screen fonts to calculate layout and display text.

Deprecated
- substituteFontForFont:

Returns a screen font suitable for use in place of the given font, if one is available.

Deprecated