<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextAttachmentContainer/attachmentBounds(for:proposedLineFragment:glyphPosition:characterIndex:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextAttachmentContainer(im)attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex:"
  },
  "title" : "attachmentBounds(for:proposedLineFragment:glyphPosition:characterIndex:)"
}
-->

# attachmentBounds(for:proposedLineFragment:glyphPosition:characterIndex:)

Returns the layout bounds of the text attachment to the layout manager.

```
func attachmentBounds(for textContainer: NSTextContainer?, proposedLineFragment lineFrag: CGRect, glyphPosition position: CGPoint, characterIndex charIndex: Int) -> CGRect
```

## Parameters

`textContainer`

The text container for the text being laid out.

`lineFrag`

The line fragment containing the text attachment.

`position`

The glyph location inside `lineFrag` which is the origin of the returned bounds rectangle.

`charIndex`

The character location inside the text storage for the attachment character.

## Return Value

The [`bounds`](/documentation/AppKit/NSTextAttachment/bounds) rectangle of the text attachment if not <doc://com.apple.documentation/documentation/CoreGraphics/CGRectZero>; otherwise, the rectangle of the <doc://com.apple.documentation/documentation/UIKit/UIImage/size> property of the attachment’s [`image`](/documentation/AppKit/NSTextAttachment/image) property.

## Discussion

Conforming objects can implement more sophisticated logic for negotiating the attachment bounds based on the available container space and proposed line fragment rectangle.

---

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)