NSTextLayoutManager's enumerateTextSegments parameters documentation

This function on NSTextLayoutManager has the following signature

func enumerateTextSegments(
    in textRange: NSTextRange,
    type: NSTextLayoutManager.SegmentType,
    options: NSTextLayoutManager.SegmentOptions = [],
    using block: (NSTextRange?, CGRect, CGFloat, NSTextContainer) -> Bool
)

The documentation here doesn't define what the CGRect and CGFloat passed to block are. However, looking at sample code Using TextKit2 To Interact With Text, they seem to be the frame for the textsegment and baselineposition respectively.

But, the textSegmentFrame seems to start at origin.x = 5.0 when text is empty. Is this some starting offset for text segments? I don't seem to be able to find mention of this anywhere.

the origin x = 5 most likely comes from NSTextContainer.lineFragmentPadding. The default value of this property is 5.0.

NSTextLayoutManager's enumerateTextSegments parameters documentation
 
 
Q