alqindiirsyam 2 年 前
コミット
39a641d855
22 ファイル変更153 行追加82 行削除
  1. 0 81
      appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift
  2. 0 1
      appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift
  3. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Black.otf
  4. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-BlackItalic.otf
  5. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Bold.otf
  6. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-BoldItalic.otf
  7. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ExtraBold.otf
  8. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ExtraBoldItalic.otf
  9. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ExtraLight.otf
  10. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ExtraLightItalic.otf
  11. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Italic.otf
  12. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Light.otf
  13. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-LightItalic.otf
  14. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Medium.otf
  15. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-MediumItalic.otf
  16. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Regular.otf
  17. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-SemiBold.otf
  18. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-SemiBoldItalic.otf
  19. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Thin.otf
  20. BIN
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ThinItalic.otf
  21. 43 0
      appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/SIL Open Font License.txt
  22. 110 0
      appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

+ 0 - 81
appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift

@@ -9,89 +9,8 @@ import UIKit
 import NexilisLite
 import NotificationBannerSwift
 
-struct AppFontName {
-    static let regular = "Poppins-Regular"
-    static let bold = "Poppins-SemiBold"
-    static let italic = "Poppins-MediumItalic"
-}
-
-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 mySystemFont(ofSize size: CGFloat) -> UIFont {
-        return UIFont(name: AppFontName.regular, size: size)!
-    }
-
-    @objc class func myBoldSystemFont(ofSize size: CGFloat) -> UIFont {
-        return UIFont(name: AppFontName.bold, size: size)!
-    }
-
-    @objc class func myItalicSystemFont(ofSize size: CGFloat) -> UIFont {
-        return UIFont(name: AppFontName.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 = AppFontName.regular
-        case "CTFontEmphasizedUsage", "CTFontBoldUsage":
-            fontName = AppFontName.bold
-        case "CTFontObliqueUsage":
-            fontName = AppFontName.italic
-        default:
-            fontName = AppFontName.regular
-        }
-        self.init(name: fontName, size: fontDescriptor.pointSize)!
-    }
-
-    class func overrideInitialize() {
-        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(mySystemFont(ofSize:))) {
-            method_exchangeImplementations(systemFontMethod, mySystemFontMethod)
-        }
-
-        if let boldSystemFontMethod = class_getClassMethod(self, #selector(boldSystemFont(ofSize:))),
-            let myBoldSystemFontMethod = class_getClassMethod(self, #selector(myBoldSystemFont(ofSize:))) {
-            method_exchangeImplementations(boldSystemFontMethod, myBoldSystemFontMethod)
-        }
-
-        if let italicSystemFontMethod = class_getClassMethod(self, #selector(italicSystemFont(ofSize:))),
-            let myItalicSystemFontMethod = class_getClassMethod(self, #selector(myItalicSystemFont(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)
-        }
-    }
-}
-
 @main
 class AppDelegate: UIResponder, UIApplicationDelegate {
-
-    override init() {
-        super.init()
-        UIFont.overrideInitialize()
-    }
-
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         var showButton = false
         if PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_FLOATING || PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_MIX {

+ 0 - 1
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -218,7 +218,6 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         if Bundle.main.displayName == "DigiNetS" {
             tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.gray, size: tabBarItemSize).resizableImage(withCapInsets: .zero)
         }
-        UIFont.overrideInitialize()
         let center: NotificationCenter = NotificationCenter.default
         center.addObserver(self, selector: #selector(checkCounter), name: NSNotification.Name(rawValue: "onReceiveChat"), object: nil)
         center.addObserver(self, selector: #selector(checkCounter), name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil)

BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Black.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-BlackItalic.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Bold.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-BoldItalic.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ExtraBold.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ExtraBoldItalic.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ExtraLight.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ExtraLightItalic.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Italic.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Light.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-LightItalic.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Medium.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-MediumItalic.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Regular.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-SemiBold.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-SemiBoldItalic.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-Thin.otf


BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/Poppins-ThinItalic.otf


+ 43 - 0
appbuilder-ios/NexilisLite/NexilisLite/Resource/fonts/SIL Open Font License.txt

@@ -0,0 +1,43 @@
+Copyright (c) 2014, Indian Type Foundry (info@indiantypefoundry.com).
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
+
+5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

+ 110 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -199,6 +199,11 @@ public class Nexilis: NSObject {
             OutgoingThread.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 {
             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 {
     func onProgress(code: String, progress: Int)
     func onProcess(message: String, status: String)