 import UIKit
 
 public extension UIFont {
-    public struct DefaultFontName {
-        public static var regular = "PingFangSC-Regular"
-        public static var bold = "PingFangSC-Medium"
-        public static var italic = "PingFangSC-Thin"
+    struct DefaultFontName {
+        static var regular = "PingFangSC-Regular"
+        static var bold = "PingFangSC-Medium"
+        static var italic = "PingFangSC-Thin"
     }
     
     static private let size: CGFloat = 17

        return UIFont(descriptor: fd, size: size)
    }()
    
    class func defaultFont(ofSize size: CGFloat) -> UIFont {
        return font.withSize(size)
    }
    
    class func boldDefaultFont(ofSize size: CGFloat) -> UIFont {
        return boldFont.withSize(size)
    }
    
    class func italicDefaultFont(ofSize size: CGFloat) -> UIFont {
        return italicFont.withSize(size)
    }
    
    convenience init(myCoder aDecoder: NSCoder) {
        if let fontDescriptor = aDecoder.decodeObject(forKey: "UIFontDescriptor") as? UIFontDescriptor {
            if let fontAttribute = fontDescriptor.fontAttributes["NSCTFontUIUsageAttribute"] as? String {
                var fontName = ""

                let fd = UIFontDescriptor(name: fontName, size: size)
                self.init(descriptor: fd, size: size)
            } else {
                self.init(swizzledCoder: aDecoder)
            }
        } else {
            self.init(swizzledCoder: aDecoder)
        }
    }
    
    class func swizzle() {
        if self == UIFont.self {
            let systemFontMethod = class_getClassMethod(self, #selector(systemFont(ofSize:)))
            let myFontMethod = class_getClassMethod(self, #selector(swizzledSystemFont(ofSize:)))
            method_exchangeImplementations(systemFontMethod, myFontMethod)
            
            let boldSystemFontMethod = class_getClassMethod(self, #selector(boldSystemFont(ofSize:)))
            let myBoldFontMethod = class_getClassMethod(self, #selector(swizzledBoldSystemFont(ofSize:)))
            method_exchangeImplementations(boldSystemFontMethod, myBoldFontMethod)
            
            let italicSystemFontMethod = class_getClassMethod(self, #selector(italicSystemFont(ofSize:)))
            let myItalicFontMethod = class_getClassMethod(self, #selector(swizzledItalicSystemFont(ofSize:)))
            method_exchangeImplementations(italicSystemFontMethod, myItalicFontMethod)
            
            //borrow init(coder:) from UIFontDescriptor
            let initCoderMethod = class_getInstanceMethod(self, #selector(UIFontDescriptor.init(coder:)))
            let myInitCoderMethod = class_getInstanceMethod(self, #selector(UIFont.init(swizzledCoder:)))
            method_exchangeImplementations(initCoderMethod, myInitCoderMethod)
        }
    }
