---
title: "cgGlyph(at:isValidIndex:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nslayoutmanager/cgglyph(at:isvalidindex:)"
---

# cgGlyph(at:isValidIndex:)

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

## Declaration

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

## Parameters

- `glyphIndex`: The index of the glyph that you want.
- `isValidIndex`: An optional Boolean variable. On return, the variable is set to doc://com.apple.documentation/documentation/Swift/true if the glyph index is valid or doc://com.apple.documentation/documentation/Swift/false if it is not.

## Return Value

Return Value The glyph at the specified index or kCGFontIndexInvalid if the index is out of range.

## Discussion

Discussion If noncontiguous layout is disabled, calling this method generates all glyphs up to and including the one at glyphIndex.

## See Also

### Accessing glyphs

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