                             guard let font = object as? UIFont else {
                                 return
                             }
-                            if !font.fontDescriptor.symbolicTraits.contains(trait) {
+                            if !font.fontDescriptor.symbolicTraits.contains(traits) {
                                 spansRange = false
                                 stop.pointee = true
                             }

                                return
                            }

                            let newFont = font.modifyTraits(fontTrait, enable: enable)

                            self.beginEditing()
                            self.removeAttribute(NSFontAttributeName, range: range)

    /// Checks if the specified font trait exists at the specified character index.
    ///
    /// - Parameters:
    ///     - traits: A font trait.
    ///     - index: A character index.
    ///
    /// - Returns: True if found.
    ///
    public func fontTrait(_ traits: UIFontDescriptorSymbolicTraits, existsAtIndex index: Int) -> Bool {
        guard let attr = attribute(NSFontAttributeName, at: index, effectiveRange: nil) else {
            return false
        }
        if let font = attr as? UIFont {
            return font.fontDescriptor.symbolicTraits.contains(traits)
        }
        return false
    }
