Does Xcode take ttf files?

Is it possible to add a font to the possible fonts for a text field from a ttf file?

Answered by QuinceyMorris in 274159022

Yes, it should work. You need be sure the font file is copied to the appropriate resource subdirectory within the bundle (I think Xcode will do this for you if you add the file to the project and target), and you need to point to the custom font(s) in the info.plist. The technique is different for macOS and iOS, but the keys are documented here:


https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html


For macOS, you need the ATSApplicationFontsPath key. For iOS, you need the UIAppFonts key. Note that the values are a different type in each case. You will need to read the appropriate description very carefully to be sure you do it exactly right, otherwise your font won't be available at run time, with no indication why.


Once this is set up, I believe you can choose the custom font in IB for a text field, if you don't want to set the font programmatically, but it's a while since I did this, so I might misremember the details.

Accepted Answer

Yes, it should work. You need be sure the font file is copied to the appropriate resource subdirectory within the bundle (I think Xcode will do this for you if you add the file to the project and target), and you need to point to the custom font(s) in the info.plist. The technique is different for macOS and iOS, but the keys are documented here:


https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html


For macOS, you need the ATSApplicationFontsPath key. For iOS, you need the UIAppFonts key. Note that the values are a different type in each case. You will need to read the appropriate description very carefully to be sure you do it exactly right, otherwise your font won't be available at run time, with no indication why.


Once this is set up, I believe you can choose the custom font in IB for a text field, if you don't want to set the font programmatically, but it's a while since I did this, so I might misremember the details.

Ok. Thanks! I got it to work.

Does Xcode take ttf files?
 
 
Q