<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManager/characterIndexForGlyph(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager(im)characterIndexForGlyphAtIndex:"
  },
  "title" : "characterIndexForGlyph(at:)"
}
-->

# characterIndexForGlyph(at:)

Returns the index in the text storage for the first character of the specified glyph.

```
func characterIndexForGlyph(at glyphIndex: Int) -> Int
```

## Parameters

`glyphIndex`

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

## Return Value

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

## Discussion

If noncontiguous layout is not enabled, this method causes generation of all glyphs up to and including `glyphIndex`. This method accepts an index beyond the last glyph, returning an index extrapolated from the last actual glyph index.

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

---

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)