Instance Method

glyphIndexForCharacter(at:)

Returns the index of the first glyph associated with the character at the specified index.

Declaration

func glyphIndexForCharacter(at charIndex: Int) -> Int

Parameters

charIndex

The index of the character for which to return the associated glyph.

Return Value

The index of the first glyph associated with the character at the specified index.

Discussion

If noncontiguous layout is not enabled, this method causes generation of all glyphs up to and including those associated with the specified character. This method accepts an index beyond the last character, returning an index extrapolated from the last actual character index.

In many cases it’s better to use the range-mapping methods, characterRange(forGlyphRange:actualGlyphRange:) and glyphRange(forCharacterRange:actualCharacterRange:), which provide more comprehensive information.

See Also

Accessing Glyphs

func cgGlyph(at: Int) -> CGGlyph

Returns the glyph at the specified index.

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

Returns the glyph at the specified index and information about whether the glyph index is valid.

func characterIndexForGlyph(at: Int) -> Int

Returns the index in the text storage for the first character associated with the given glyph.

func isValidGlyphIndex(Int) -> Bool

Indicates whether the specified index refers to a valid glyph, otherwise false.

var numberOfGlyphs: Int

The number of glyphs in the receiver.

func propertyForGlyph(at: Int) -> NSLayoutManager.GlyphProperty

Returns the glyph property associated with the glyph at the specified index.