Registered font not getting after reopen application

355 Views Asked by At

I am using Font from UIDocumentPickerViewController and I am successfully registered font and also get UIFont.families. But once I kill the application and then reopen application then I can not get that font in UIFont.families. I used bellow code

func handleFileSelection(inUrl:URL) -> Void {
do {
    // inUrl is the document's URL
    let fontData = try Data(contentsOf: inUrl) // Getting file data here
    let dataProvider = CGDataProvider(data: fontData as CFData)
    let cgFont = CGFont(dataProvider
   
    var error: Unmanaged<CFError>?
    if !CTFontManagerRegisterGraphicsFont(cgFont!, &error)
    {
        print("Error loading Font!")
    } else {}
        let fontName = cgFont!.postScriptName
        self.lblText.font = UIFont.init(name: "\(fontName!)", size: 25.0)
        self.lblText.text = "\(fontName!)"
    } catch {
        print("document loading error")
    }
}

If I am missing something please let me know.

0

There are 0 best solutions below