|
@@ -199,6 +199,11 @@ public class Nexilis: NSObject {
|
|
OutgoingThread.default.run()
|
|
OutgoingThread.default.run()
|
|
|
|
|
|
InquiryThread.default.run()
|
|
InquiryThread.default.run()
|
|
|
|
+
|
|
|
|
+ if UIFont.systemFont(ofSize: 12).familyName == ".AppleSystemUIFont" {
|
|
|
|
+ UIFont.libOverrideInitialize()
|
|
|
|
+ }
|
|
|
|
+ print("MANIA \(UIFont.systemFont(ofSize: 12)) <> \(UIFont.italicSystemFont(ofSize: 12)) <> \(UIFont.boldSystemFont(ofSize: 12))")
|
|
}
|
|
}
|
|
catch {
|
|
catch {
|
|
print(error)
|
|
print(error)
|
|
@@ -1408,6 +1413,111 @@ public class Nexilis: NSObject {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+struct LibFontName {
|
|
|
|
+ static let regular = "Poppins-Regular"
|
|
|
|
+ static let bold = "Poppins-Bold"
|
|
|
|
+ static let italic = "Poppins-Italic"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+extension UIFontDescriptor.AttributeName {
|
|
|
|
+ static let nsctFontUIUsage = UIFontDescriptor.AttributeName(rawValue: "NSCTFontUIUsageAttribute")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+extension UIFont {
|
|
|
|
+ static var isOverrided: Bool = false
|
|
|
|
+ static let FONT_SELECT = 0
|
|
|
|
+
|
|
|
|
+ @objc class func libSystemFont(ofSize size: CGFloat) -> UIFont {
|
|
|
|
+ jbs_registerFont(withFilenameString: LibFontName.regular)
|
|
|
|
+ return UIFont(name: LibFontName.regular, size: size)!
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc class func libBoldSystemFont(ofSize size: CGFloat) -> UIFont {
|
|
|
|
+ jbs_registerFont(withFilenameString: LibFontName.bold)
|
|
|
|
+ return UIFont(name: LibFontName.bold, size: size)!
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc class func libItalicSystemFont(ofSize size: CGFloat) -> UIFont {
|
|
|
|
+ jbs_registerFont(withFilenameString: LibFontName.italic)
|
|
|
|
+ return UIFont(name: LibFontName.italic, size: size)!
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc convenience init(myCoder aDecoder: NSCoder) {
|
|
|
|
+ guard
|
|
|
|
+ let fontDescriptor = aDecoder.decodeObject(forKey: "UIFontDescriptor") as? UIFontDescriptor,
|
|
|
|
+ let fontAttribute = fontDescriptor.fontAttributes[.nsctFontUIUsage] as? String else {
|
|
|
|
+ self.init(myCoder: aDecoder)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var fontName = ""
|
|
|
|
+ switch fontAttribute {
|
|
|
|
+ case "CTFontRegularUsage":
|
|
|
|
+ fontName = LibFontName.regular
|
|
|
|
+ case "CTFontEmphasizedUsage", "CTFontBoldUsage":
|
|
|
|
+ fontName = LibFontName.bold
|
|
|
|
+ case "CTFontObliqueUsage":
|
|
|
|
+ fontName = LibFontName.italic
|
|
|
|
+ default:
|
|
|
|
+ fontName = LibFontName.regular
|
|
|
|
+ }
|
|
|
|
+ self.init(name: fontName, size: fontDescriptor.pointSize)!
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ class func libOverrideInitialize() {
|
|
|
|
+ guard self == UIFont.self, !isOverrided, FONT_SELECT == 0 else { return }
|
|
|
|
+
|
|
|
|
+ // Avoid method swizzling run twice and revert to original initialize function
|
|
|
|
+ isOverrided = true
|
|
|
|
+
|
|
|
|
+ if let systemFontMethod = class_getClassMethod(self, #selector(systemFont(ofSize:))),
|
|
|
|
+ let mySystemFontMethod = class_getClassMethod(self, #selector(libSystemFont(ofSize:))) {
|
|
|
|
+ method_exchangeImplementations(systemFontMethod, mySystemFontMethod)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if let boldSystemFontMethod = class_getClassMethod(self, #selector(boldSystemFont(ofSize:))),
|
|
|
|
+ let myBoldSystemFontMethod = class_getClassMethod(self, #selector(libBoldSystemFont(ofSize:))) {
|
|
|
|
+ method_exchangeImplementations(boldSystemFontMethod, myBoldSystemFontMethod)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if let italicSystemFontMethod = class_getClassMethod(self, #selector(italicSystemFont(ofSize:))),
|
|
|
|
+ let myItalicSystemFontMethod = class_getClassMethod(self, #selector(libItalicSystemFont(ofSize:))) {
|
|
|
|
+ method_exchangeImplementations(italicSystemFontMethod, myItalicSystemFontMethod)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if let initCoderMethod = class_getInstanceMethod(self, #selector(UIFontDescriptor.init(coder:))), // Trick to get over the lack of UIFont.init(coder:))
|
|
|
|
+ let myInitCoderMethod = class_getInstanceMethod(self, #selector(UIFont.init(myCoder:))) {
|
|
|
|
+ method_exchangeImplementations(initCoderMethod, myInitCoderMethod)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ class func jbs_registerFont(withFilenameString filenameString: String) {
|
|
|
|
+
|
|
|
|
+ guard let pathForResourceString = Bundle.resourceBundle(for: Nexilis.self).path(forResource: filenameString, ofType: "otf") else {
|
|
|
|
+ print("UIFont+: Failed to register font - path for resource not found.")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ guard let fontData = NSData(contentsOfFile: pathForResourceString) else {
|
|
|
|
+ print("UIFont+: Failed to register font - font data could not be loaded.")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ guard let dataProvider = CGDataProvider(data: fontData) else {
|
|
|
|
+ print("UIFont+: Failed to register font - data provider could not be loaded.")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ guard let font = CGFont(dataProvider) else {
|
|
|
|
+ print("UIFont+: Failed to register font - font could not be loaded.")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var errorRef: Unmanaged<CFError>? = nil
|
|
|
|
+ if (CTFontManagerRegisterGraphicsFont(font, &errorRef) == false) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
public protocol LoginDelegate: NSObjectProtocol {
|
|
public protocol LoginDelegate: NSObjectProtocol {
|
|
func onProgress(code: String, progress: Int)
|
|
func onProgress(code: String, progress: Int)
|
|
func onProcess(message: String, status: String)
|
|
func onProcess(message: String, status: String)
|