<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTypesetter/getLineFragmentRect(_:usedRect:remaining:forStartingGlyphAt:proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTypesetter(im)getLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter:"
  },
  "title" : "getLineFragmentRect(_:usedRect:remaining:forStartingGlyphAt:proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter:)"
}
-->

# getLineFragmentRect(_:usedRect:remaining:forStartingGlyphAt:proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter:)

Calculates line fragment rectangle, line fragment used rectangle, and remaining rectangle for a line fragment.

```
func getLineFragmentRect(_ lineFragmentRect: NSRectPointer!, usedRect lineFragmentUsedRect: NSRectPointer!, remaining remainingRect: NSRectPointer!, forStartingGlyphAt startingGlyphIndex: Int, proposedRect: NSRect, lineSpacing: CGFloat, paragraphSpacingBefore: CGFloat, paragraphSpacingAfter: CGFloat)
```

## Parameters

`lineFragmentRect`

On return, the calculated line fragment rectangle.

`lineFragmentUsedRect`

On return, the used rectangle (the portion of the line fragment rectangle that actually contains marks).

`remainingRect`

On return, the remaining rectangle of `proposedRect`.

`startingGlyphIndex`

The glyph index where the line fragment starts.

`proposedRect`

The proposed rectangle of the line fragment.

`lineSpacing`

The line spacing.

`paragraphSpacingBefore`

The spacing before the paragraph.

`paragraphSpacingAfter`

The spacing after the paragraph.

## Discussion

The height of the line fragment is determined using `lineSpacing`, `paragraphSpacingBefore`, and `paragraphSpacingAfter` as well as `proposedRect`. The width for `lineFragmentUsedRect` is set to the `lineFragmentRect` width. In the standard implementation, paragraph spacing is included in the line fragment rectangle but not the line fragment used rectangle; line spacing is included in both.

---

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)