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.
To add a font file to your Xcode project, select File > Add Files to “Your Project Name” from the menu bar, or drag the file from Finder and drop it into your Xcode project. You can add True Type Font (. ttf) and Open Type Font (. otf) files.
Add the font file to your Xcode project Select File menu > Add Files to "Your Project Name"... from the menu bar, select all the fonts you need to add, then click the Add button. Or drag the file from Finder and drop it into your Xcode project. Drag the font files from Finder and drop it into your Xcode project.
SF Mono. This monospaced variant of San Francisco enables alignment between rows and columns of text, and is used in coding environments like Xcode.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With