Ryan
Ryan

Reputation: 4884

Load font in iOS 11 (or Xcode 9)

I have been using Futura-Demi.otf font for a while.

With the below code, I could confirm this file contains multiple fonts.

for fname in UIFont.familyNames {
    for name in UIFont.fontNames(forFamilyName: fname) {
        print(name)
    }
}

Font family is Futura and it contains fonts as below:

Futura-CondensedExtraBold
Futura-Dem
Futura-Medium
Futura-Bold
Futura-CondensedMedium
Futura-MediumItalic

I have used Futura-Dem font with UIFont(name: "Futura-Dem", size: 21) without any trouble so far. However after iOS 11 is released, I can't use this font anymore. All Futura-Dem font are changed to Futura-Medium even in the app which already in App Store.

I checked that the font loaded by UIFont(name: "Futura-Dem", size: 21) is Futura-Medium font and I also found that I can use Futura-Dem font with

let des = UIFontDescriptor(name: "Futura-Dem", size: 21)
let font = UIFont(descriptor: des, size: 21)

The above code loads Futura-Dem successfully but I have no idea why I can't just use UIFont(name: "Futura-Dem", size: 21) as I did before.

Upvotes: 6

Views: 1635

Answers (1)

Testounet Testounet
Testounet Testounet

Reputation: 137

I've had the same issue, with a custom Futura font as well.

I used the software Birdfont ( https://birdfont.org/ *) to rename the font to something different (not starting with Futura, just a single word starting with an upper case). And changing the filename as well but really what was important was to change the font name in the font's meta data.

Then I linked that renamed font to the iOS app and it worked. I don't know why the problem with Futura occurred though, but this trick solved the problem.

*Note: there is also FontForge ( http://fontforge.github.io/en-US/ ) if for some reasons Birdfont doesn't work for you.

Upvotes: 4

Related Questions