//
//  UIFont+Traits.swift
//  Tusker
//
//  Created by Shadowfacts on 9/22/19.
//  Copyright © 2019 Shadowfacts. All rights reserved.
//

import UIKit

extension UIFont {
    
    func withTraits(_ traits: UIFontDescriptor.SymbolicTraits, size: CGFloat? = nil) -> UIFont? {
        let descriptor = self.fontDescriptor
        guard let newDescriptor = descriptor.withSymbolicTraits([descriptor.symbolicTraits, traits]) else {
            return nil
        }
        return UIFont(descriptor: newDescriptor, size: size ?? self.pointSize)
    }
    
}
