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

# textLayoutFragment(for:)

Returns the text layout fragment from the document at the specified location.

## Declaration

```swift
func textLayoutFragment(for location: any NSTextLocation) -> NSTextLayoutFragment?
```

## Parameters

- `location`: The starting location.

## 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:)-4dhrx.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)
