Instance Method

setLineFragmentRect(_:forGlyphRange:usedRect:)

Associates the given line fragment bounds with the given range of glyphs.

Declaration

iOS, tvOS
func setLineFragmentRect(_ fragmentRect: CGRect, forGlyphRange glyphRange: NSRange, usedRect: CGRect)
macOS
func setLineFragmentRect(_ fragmentRect: NSRect, forGlyphRange glyphRange: NSRange, usedRect: NSRect)

Parameters

fragmentRect

The rectangle of the line fragment.

glyphRange

The range of glyphs to be associated with fragmentRect.

usedRect

The portion of fragmentRect that actually contains glyphs or other marks that are drawn (including the text container’s line fragment padding. Must be equal to or contained within fragmentRect.

Discussion

The typesetter must specify the text container first with setTextContainer(_:forGlyphRange:), and it sets the exact positions of the glyphs afterwards with setLocation(_:forStartOfGlyphRange:).

In the course of layout, all glyphs should end up being included in a range passed to this method, but only glyphs that start a new line fragment should be at the start of such ranges.

Line fragment rectangles and line fragment used rectangles are always in container coordinates.

This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

See Also

Setting Layout Information

func setAttachmentSize(CGSize, forGlyphRange: NSRange)

Sets the size at which the given glyph (assumed to be an attachment) is asked to draw in the given glyph range.

func setDrawsOutsideLineFragment(Bool, forGlyphAt: Int)

Specifies whether the given glyph exceeds the bounds of the line fragment where it’s laid out.

func setExtraLineFragmentRect(CGRect, usedRect: CGRect, textContainer: NSTextContainer)

Sets the bounds and container for the extra line fragment.

func setLocation(CGPoint, forStartOfGlyphRange: NSRange)

Sets the location for the first glyph of the given range.

func setNotShownAttribute(Bool, forGlyphAt: Int)

Sets the glyph at the given index to be one that isn’t shown.