---
title: "textLayoutFragment(for:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextlayoutmanager/textlayoutfragment(for:)-4dhrx"
---

# textLayoutFragment(for:)

Returns the text layout fragment at the position you specify in the text container.

## Declaration

```swift
func textLayoutFragment(for position: CGPoint) -> NSTextLayoutFragment?
```

## Parameters

- `position`: A doc://com.apple.documentation/documentation/CoreFoundation/CGPoint that describes the position in the coordinate system for the text container.

## Return Value

Return Value An NSTextLayoutFragment.

## See Also

### Causing layout generation

- [textViewportLayoutController](appkit/nstextlayoutmanager/textviewportlayoutcontroller.md)
- [invalidateLayout(for:)](appkit/nstextlayoutmanager/invalidatelayout(for:).md)
- [textLayoutFragment(for:)](appkit/nstextlayoutmanager/textlayoutfragment(for:)-68dez.md)
- [ensureLayout(for:)](appkit/nstextlayoutmanager/ensurelayout(for:)-6ptsj.md)
- [ensureLayout(for:)](appkit/nstextlayoutmanager/ensurelayout(for:)-3duae.md)
- [enumerateTextLayoutFragments(from:options:using:)](appkit/nstextlayoutmanager/enumeratetextlayoutfragments(from:options:using:).md)
- [NSTextLayoutManager.SegmentType](appkit/nstextlayoutmanager/segmenttype.md)
- [NSTextLayoutManager.SegmentOptions](appkit/nstextlayoutmanager/segmentoptions.md)
