---
title: "insertGlyph(_:atGlyphIndex:characterIndex:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstypesetter/insertglyph(_:atglyphindex:characterindex:)"
---

# insertGlyph(_:atGlyphIndex:characterIndex:)

Enables the typesetter to insert a new glyph into the stream.

## Declaration

```swift
func insertGlyph(_ glyph: NSGlyph, atGlyphIndex glyphIndex: Int, characterIndex: Int)
```

## Parameters

- `glyph`: The glyph to insert into the glyph cache.
- `glyphIndex`: The index at which to insert glyph.
- `characterIndex`: The index of the character that glyph maps to. If the glyph is mapped to several characters, charIndex should indicate the first character to which it’s mapped.

## Discussion

Discussion The standard typesetter uses this method for inserting hyphenation glyphs. Because this method keeps the glyph caches synchronized, subclasses should always use this method to insert glyphs instead of calling layoutManager directly. A subclass can override this method to interact with custom glyph storage.

## See Also

### Deprecated

- [actionForControlCharacter(at:)](appkit/nstypesetter/actionforcontrolcharacter(at:).md)
- [deleteGlyphs(in:)](appkit/nstypesetter/deleteglyphs(in:).md)
- [substituteGlyphs(in:withGlyphs:)](appkit/nstypesetter/substituteglyphs(in:withglyphs:).md)
- [getGlyphs(in:glyphs:characterIndexes:glyphInscriptions:elasticBits:bidiLevels:)](appkit/nstypesetter/getglyphs(in:glyphs:characterindexes:glyphinscriptions:elasticbits:bidilevels:).md)
- [NSTypesetterControlCharacterAction](appkit/nstypesettercontrolcharacteraction.md)
