<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManagerDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSLayoutManagerDelegate"
  },
  "title" : "NSLayoutManagerDelegate"
}
-->

# NSLayoutManagerDelegate

A set of optional methods that delegates of layout manager objects implement.

```
protocol NSLayoutManagerDelegate : NSObjectProtocol
```

## Topics

### Invalidating glyphs and layout

[`func layoutManagerDidInvalidateLayout(NSLayoutManager)`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManagerDidInvalidateLayout(_:))

Informs the delegate when the specified layout manager invalidates layout information (not glyph information).

[`func layoutManager(NSLayoutManager, shouldGenerateGlyphs: UnsafePointer<CGGlyph>, properties: UnsafePointer<NSLayoutManager.GlyphProperty>, characterIndexes: UnsafePointer<Int>, font: NSFont, forGlyphRange: NSRange) -> Int`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:))

Enables customization of the initial glyph generation process.

[`func layoutManager(NSLayoutManager, shouldUse: NSLayoutManager.ControlCharacterAction, forControlCharacterAt: Int) -> NSLayoutManager.ControlCharacterAction`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:shouldUse:forControlCharacterAt:))

Returns the control character action for the control character at the specified character index.

[`struct ControlCharacterAction`](/documentation/AppKit/NSLayoutManager/ControlCharacterAction)

Constants that describe actions for control characters.

### Responding to text container layout

[`func layoutManager(NSLayoutManager, didCompleteLayoutFor: NSTextContainer?, atEnd: Bool)`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:didCompleteLayoutFor:atEnd:))

Informs the delegate when the layout manager finishes laying out text in the specified text container.

[`func layoutManager(NSLayoutManager, textContainer: NSTextContainer, didChangeGeometryFrom: NSSize)`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:textContainer:didChangeGeometryFrom:))

Informs the delegate when the layout manager invalidates layout due to a change in the geometry of the specified text container.

### Handling line fragments

[`func layoutManager(NSLayoutManager, shouldBreakLineByHyphenatingBeforeCharacterAt: Int) -> Bool`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:shouldBreakLineByHyphenatingBeforeCharacterAt:))

Asks the delegate whether to break the line at the specified character.

[`func layoutManager(NSLayoutManager, shouldBreakLineByWordBeforeCharacterAt: Int) -> Bool`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:shouldBreakLineByWordBeforeCharacterAt:))

Asks the delegate whether to break the line at the specified word.

[`func layoutManager(NSLayoutManager, lineSpacingAfterGlyphAt: Int, withProposedLineFragmentRect: NSRect) -> CGFloat`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:lineSpacingAfterGlyphAt:withProposedLineFragmentRect:))

Returns the amount of space to add to the end of a line.

[`func layoutManager(NSLayoutManager, paragraphSpacingAfterGlyphAt: Int, withProposedLineFragmentRect: NSRect) -> CGFloat`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:paragraphSpacingAfterGlyphAt:withProposedLineFragmentRect:))

Returns the amount of space to add at the end of a paragraph.

[`func layoutManager(NSLayoutManager, paragraphSpacingBeforeGlyphAt: Int, withProposedLineFragmentRect: NSRect) -> CGFloat`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:paragraphSpacingBeforeGlyphAt:withProposedLineFragmentRect:))

Returns the amount of space to add at the beginning of a paragraph.

[`func layoutManager(NSLayoutManager, boundingBoxForControlGlyphAt: Int, for: NSTextContainer, proposedLineFragment: NSRect, glyphPosition: NSPoint, characterIndex: Int) -> NSRect`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:boundingBoxForControlGlyphAt:for:proposedLineFragment:glyphPosition:characterIndex:))

Returns the bounding rectangle for the specified control glyph with the specified parameters.

[`func layoutManager(NSLayoutManager, shouldSetLineFragmentRect: UnsafeMutablePointer<NSRect>, lineFragmentUsedRect: UnsafeMutablePointer<NSRect>, baselineOffset: UnsafeMutablePointer<CGFloat>, in: NSTextContainer, forGlyphRange: NSRange) -> Bool`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:shouldSetLineFragmentRect:lineFragmentUsedRect:baselineOffset:in:forGlyphRange:))

Customizes the line fragment geometry before committing it to the layout cache.

### Managing temporary attribute support

[`func layoutManager(NSLayoutManager, shouldUseTemporaryAttributes: [NSAttributedString.Key : Any], forDrawingToScreen: Bool, atCharacterIndex: Int, effectiveRange: NSRangePointer?) -> [NSAttributedString.Key : Any]?`](/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:shouldUseTemporaryAttributes:forDrawingToScreen:atCharacterIndex:effectiveRange:))

Asks the delegate whether to use temporary attributes when drawing the text.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

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)