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

# willSetLineFragmentRect(_:forGlyphRange:usedRect:baselineOffset:)

Notifies subclasses that the typesetter is about to set a new line fragment.

```
func willSetLineFragmentRect(_ lineRect: UnsafeMutablePointer<NSRect>, forGlyphRange glyphRange: NSRange, usedRect: UnsafeMutablePointer<NSRect>, baselineOffset: UnsafeMutablePointer<CGFloat>)
```

## Discussion

The typesetter calls this method before calling [`setLineFragmentRect(_:forGlyphRange:usedRect:)`](/documentation/AppKit/NSLayoutManager/setLineFragmentRect(_:forGlyphRange:usedRect:)), which stores the actual line fragment rectangle location in the layout manager.

The `lineRect` argument is the rectangle in which the glyphs in `glyphRange` are laid out. The `usedRect` argument indicates the portion of `lineRect`, in the [`NSTextContainer`](/documentation/AppKit/NSTextContainer) object’s coordinate system, that actually contains glyphs or other marks that are drawn (including the text container’s line fragment padding). The `usedRect` must be equal to or contained within `lineRect`. The `baselineOffset` argument is the vertical distance in pixels from the line fragment origin to the baseline on which the glyphs align.

A subclass can override this method to customize the text layout process. For example, it could change the shape of the line fragment rectangle. The subclass is responsible for ensuring that the modified rectangle remains valid (for example, that it lies within the text container).

---

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)