layoutManager(_:shouldSetLineFragmentRect:lineFragmentUsedRect:baselineOffset:in:forGlyphRange:)
Customizes the line fragment geometry before committing it to the layout cache.
Declaration
optional func layoutManager(_ layoutManager: NSLayoutManager, shouldSetLineFragmentRect lineFragmentRect: UnsafeMutablePointer<CGRect>, lineFragmentUsedRect: UnsafeMutablePointer<CGRect>, baselineOffset: UnsafeMutablePointer<CGFloat>, in textContainer: NSTextContainer, forGlyphRange glyphRange: NSRange) -> BoolParameters
- layoutManager:
The layout manager doing the work.
- lineFragmentRect:
The proposed rectangle that contains the glyphs. You may modify this rectangle as needed.
- lineFragmentUsedRect:
The portion of
lineFragmentRectthat actually contains glyphs or other rendered marks, including the text container’s line fragment padding. This rectangle must be equal tolineFragmentRector wholly contained by it. You may modify this rectangle as needed. - baselineOffset:
The vertical distance (in pixels) from the line fragment origin to the baseline on which the glyphs align.
- textContainer:
The text container for the line fragments.
- glyphRange:
The range of glyphs being laid out.
Return Value
true if you modified the layout information and want your modifications to be used or false if the original layout information should be used.
Discussion
Use this method to modify the line fragment rectangles associated with the text container. It is your responsibility to ensure that the modified rectangles remain valid and still lie within the text container.
See Also
Handling line fragments
layoutManager(_:shouldBreakLineByHyphenatingBeforeCharacterAt:)layoutManager(_:shouldBreakLineByWordBeforeCharacterAt:)layoutManager(_:lineSpacingAfterGlyphAt:withProposedLineFragmentRect:)layoutManager(_:paragraphSpacingAfterGlyphAt:withProposedLineFragmentRect:)layoutManager(_:paragraphSpacingBeforeGlyphAt:withProposedLineFragmentRect:)layoutManager(_:boundingBoxForControlGlyphAt:for:proposedLineFragment:glyphPosition:characterIndex:)