<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManager/setLineFragmentRect(_:forGlyphRange:usedRect:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager(im)setLineFragmentRect:forGlyphRange:usedRect:"
  },
  "title" : "setLineFragmentRect(_:forGlyphRange:usedRect:)"
}
-->

# setLineFragmentRect(_:forGlyphRange:usedRect:)

Associates the line fragment bounds for the specified range of glyphs.

```
func setLineFragmentRect(_ fragmentRect: NSRect, forGlyphRange glyphRange: NSRange, usedRect: NSRect)
```

## Parameters

`fragmentRect`

The rectangle of the line fragment.

`glyphRange`

The range of glyphs to be associated with `fragmentRect`.

`usedRect`

The portion of `fragmentRect` that actually contains glyphs or other marks that are drawn (including the text container’s line fragment padding. Must be equal to or contained within `fragmentRect`.

## Discussion

The typesetter must specify the text container first with [`setTextContainer(_:forGlyphRange:)`](/documentation/AppKit/NSLayoutManager/setTextContainer(_:forGlyphRange:)), and it sets the exact positions of the glyphs afterwards with [`setLocation(_:forStartOfGlyphRange:)`](/documentation/AppKit/NSLayoutManager/setLocation(_:forStartOfGlyphRange:)).

In the course of layout, all glyphs should end up being included in a range passed to this method, but only glyphs that start a new line fragment should be at the start of such ranges.

Line fragment rectangles and line fragment used rectangles are always in container coordinates.

This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

---

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)