<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.13.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTypesetter/insertGlyph(_:atGlyphIndex:characterIndex:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTypesetter(im)insertGlyph:atGlyphIndex:characterIndex:"
  },
  "title" : "insertGlyph(_:atGlyphIndex:characterIndex:)"
}
-->

# insertGlyph(_:atGlyphIndex:characterIndex:)

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

```
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

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`](/documentation/AppKit/NSTypesetter/layoutManager) directly.

A subclass can override this method to interact with custom glyph storage.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)