Instance Method


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


func getGlyphs(in glyphRange: NSRange, glyphs glyphBuffer: UnsafeMutablePointer<NSGlyph>?, characterIndexes charIndexBuffer: UnsafeMutablePointer<Int>?, glyphInscriptions inscribeBuffer: UnsafeMutablePointer<NSGlyphInscription>?, elasticBits elasticBuffer: UnsafeMutablePointer<ObjCBool>?, bidiLevels bidiLevelBuffer: UnsafeMutablePointer<UInt8>?) -> Int



The range of glyphs to lay out.


On output, the sequence of glyphs needed to lay out the given glyph range.


On output, the indexes of the original characters corresponding to the given glyph range. Note that a glyph at index 1 is not necessarily mapped to the character at index 1, since a glyph may be for a ligature or accent.


On output, the inscription attributes for each glyph, which are used to lay out characters that are combined together. The possible values are described in Constants.


On output, values indicating whether a glyph is elastic for each glyph. An elastic glyph can be made longer at the end of a line or when needed for justification.


On output, the direction of each glyph for bidirectional text. The values range from 0 to 61 as defined by Unicode Standard Annex #9. An even value means the glyph goes left-to-right, and an odd value means the glyph goes right-to-left.

Return Value

The number of glyphs returned in glyphBuffer.


This method and getGlyphs(in:glyphs:characterIndexes:glyphInscriptions:elasticBits:) are intended primarily to enable the typesetter to obtain in bulk the glyphs and other information that it needs to perform layout. These methods return all glyphs in the range, including NSNullGlyph and not-shown glyphs. They do not null-terminate the results. Each pointer passed in should either be NULL, or else point to sufficient memory to hold glyphRange.length elements.

See Also



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

func invalidateGlyphs(onLayoutInvalidationForGlyphRange: NSRange)

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

func invalidateLayout(forCharacterRange: NSRange, isSoft: Bool, actualCharacterRange: NSRangePointer?)

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

func textStorage(NSTextStorage, edited: Int, range: NSRange, changeInLength: Int, invalidatedRange: NSRange)

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

func insertGlyph(NSGlyph, atGlyphIndex: Int, characterIndex: Int)

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

func glyph(at: Int) -> CGGlyph

Returns the glyph at glyphIndex.

func glyph(at: Int, isValidIndex: UnsafeMutablePointer<ObjCBool>?) -> CGGlyph

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.

func replaceGlyph(at: Int, withGlyph: NSGlyph)

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

func getGlyphs(UnsafeMutablePointer<NSGlyph>?, range: NSRange) -> Int

Fills the passed-in buffer with a sequence of glyphs

func deleteGlyphs(in: NSRange)

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

func setCharacterIndex(Int, forGlyphAt: Int)

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

func intAttribute(Int, forGlyphAt: Int) -> Int

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

func rectArray(forCharacterRange: NSRange, withinSelectedCharacterRange: NSRange, in: NSTextContainer, rectCount: UnsafeMutablePointer<Int>) -> NSRectArray?

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.

func rectArray(forGlyphRange: NSRange, withinSelectedGlyphRange: NSRange, in: NSTextContainer, rectCount: UnsafeMutablePointer<Int>) -> NSRectArray?

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.


The layout manager’s current layout options.

var usesScreenFonts: Bool

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

func substituteFont(for: NSFont) -> NSFont

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