Downloading and installing a custom font in iOS

<>

This question already has an answer here:

Answers


It is possible. I created an example project in github. You have to just add the line below.

if !CTFontManagerRegisterGraphicsFont(cgFont, &error)
{
    print("Error loading Font!")
}
else
{
    let fontName = CGFontCopyPostScriptName(cgFont)
    uiFont = UIFont(name: String(fontName) , size: 30)
}

Thank you for Michael Dautermann, he was right.

Github project link


According to the answers in this related question, you should be able to download your font and register it the way you are already doing (which it sounds like you are doing correctly), but you simply need to get the Postscript name and use that to create a corresponding UIFont:

var uiFont : UIFont?
let fontData = NSData(contentsOfFile: dest)!

let dataProvider = CGDataProviderCreateWithCFData(fontData)
let cgFont = CGFontCreateWithDataProvider(dataProvider)!

var error: Unmanaged<CFError>?
if !CTFontManagerRegisterGraphicsFont(cgFont, &error)
{
    print("Error loading Font!")
} else {
    let fontName = CGFontCopyPostScriptName(fontRef)
    uiFont = UIFont(name: fontName, size: 30)
}

Need Your Help

How to get path of current active application window?

windows delphi lazarus

I want to get the path to the executable file of the current active Window.

JIRA OAuth process in Python

python ssl ssl-certificate jira jira-rest-api

I'm using the below snippet to sign the request and get request tokens for JIRA OAuth process.