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

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

Sets the line fragment rectangle where the specified glyphs are laid out.

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

## Parameters

`fragmentRect`

The line fragment rectangle where the glyphs in `glyphRange` are laid out.

`glyphRange`

The range of the specified glyphs.

`usedRect`

The portion of `fragmentRect`, in the 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 `fragmentRect`.

`baselineOffset`

The vertical distance in pixels from the line fragment origin to the baseline on which the glyphs align.

## Discussion

The exact positions of the glyphs must be set after the line fragment rectangle with `setLocation:forStartOfGlyphRange:`.

A subclass can override this method to interact with custom glyph storage.

---

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)