---
title: "characterIndexForGlyph(at:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nslayoutmanager/characterindexforglyph(at:)"
---

# characterIndexForGlyph(at:)

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

## Declaration

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

## Parameters

- `glyphIndex`: The index of the glyph for which to return the associated character.

## Return Value

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

## Discussion

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:) and glyphRange(forCharacterRange:actualCharacterRange:), which provide more comprehensive information.

## See Also

### Accessing glyphs

- [getGlyphs(in:glyphs:properties:characterIndexes:bidiLevels:)](uikit/nslayoutmanager/getglyphs(in:glyphs:properties:characterindexes:bidilevels:).md)
- [cgGlyph(at:)](uikit/nslayoutmanager/cgglyph(at:).md)
- [cgGlyph(at:isValidIndex:)](uikit/nslayoutmanager/cgglyph(at:isvalidindex:).md)
- [setGlyphs(_:properties:characterIndexes:font:forGlyphRange:)](uikit/nslayoutmanager/setglyphs(_:properties:characterindexes:font:forglyphrange:).md)
- [glyphIndexForCharacter(at:)](uikit/nslayoutmanager/glyphindexforcharacter(at:).md)
- [isValidGlyphIndex(_:)](uikit/nslayoutmanager/isvalidglyphindex(_:).md)
- [numberOfGlyphs](uikit/nslayoutmanager/numberofglyphs.md)
- [propertyForGlyph(at:)](uikit/nslayoutmanager/propertyforglyph(at:).md)
- [NSLayoutManager.GlyphProperty](uikit/nslayoutmanager/glyphproperty.md)
