<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSLayoutManagerDelegate(im)layoutManager:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:"
  },
  "title" : "layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:)"
}
-->

# layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:)

Enables customization of the initial glyph generation process.

```
optional func layoutManager(_ layoutManager: NSLayoutManager, shouldGenerateGlyphs glyphs: UnsafePointer<CGGlyph>, properties props: UnsafePointer<NSLayoutManager.GlyphProperty>, characterIndexes charIndexes: UnsafePointer<Int>, font aFont: NSFont, forGlyphRange glyphRange: NSRange) -> Int
```

## Parameters

`layoutManager`

The layout manager doing the layout.

`glyphs`

A pointer to the layout manager’s glyph cache.

`props`

A pointer to a buffer containing glyph properties for the glyphs in the cache.

`charIndexes`

A pointer to the starting index for the characters in the text storage for which glyphs are generated.

`aFont`

A font to override the font attributes in the text storage for the specified character range.

`glyphRange`

The range of glyphs in the glyph cache to set.

## Return Value

The actual glyph range stored in this method. By returning `0`, it can indicate for the layout manager to do the default processing.

## Discussion

This message is sent whenever the layout manager is about to store the initial glyph information via [`setGlyphs(_:properties:characterIndexes:font:forGlyphRange:)`](/documentation/AppKit/NSLayoutManager/setGlyphs(_:properties:characterIndexes:font:forGlyphRange:)). To customize the initial glyph generation process, this method can invoke [`setGlyphs(_:properties:characterIndexes:font:forGlyphRange:)`](/documentation/AppKit/NSLayoutManager/setGlyphs(_:properties:characterIndexes:font:forGlyphRange:)) with modified glyph information.

> Note:
> Querying glyph information surrounding `glyphRange` could lead to recursion since the data might not be available yet.

---

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)