func layoutManager()

in Sources/TwitterTextEditor/LayoutManager.swift [341:361]


    func layoutManager(_ layoutManager: NSLayoutManager,
                       boundingBoxForControlGlyphAt glyphIndex: Int,
                       for textContainer: NSTextContainer,
                       proposedLineFragment proposedRect: CGRect,
                       glyphPosition: CGPoint,
                       characterIndex charIndex: Int) -> CGRect
    {
        guard let textStorage = layoutManager.textStorage else {
            return .zero
        }

        let attributes = textStorage.attributes(at: charIndex, effectiveRange: nil)
        guard let suffixedAttachment = attributes[.suffixedAttachment] as? TextAttributes.SuffixedAttachment else {
            // Should't reach here.
            // See `layoutManager(_:shouldUse:forControlCharacterAt:)`.
            assertionFailure("Glyphs that have .suffixedAttachment shouldn't be a control glyphs")
            return .zero
        }

        return CGRect(origin: glyphPosition, size: suffixedAttachment.size)
    }