Timering

Purp

Custom Font import & UIFont Family Names List - IOS, ObjC

Sometimes it's very useful to check, which UIFonts are already available, and which should be imported. In this little tutorial, I will show, how can you import your own custom UIFont, and how can you check the available UIFonts and Families in your Xcode Project. IOS 9.3 Xcode 7.3

Steps

  1. Check the available UIFont Families - Log their names
  2. Import your own UIFont
  3. Check the available Font Families and their Fonts again.

Video

1. Check the available UIFont Families - Log their names

Create a SingleView Xcode Project. In your ViewController.m file put this code to write out in Log your all available UIFonts:

Now run your project and check the logs. My result is this:

UIFont Family Name List - Custom UIFont Import 1_1

2. Import your own UIFont

If you have one ok, if you need on, download here a new Font: www.google.com/fonts

Find one, which isn't in your Log list! :) I use here Lato.

UIFont Custom Import Xcode IOS 9.3

2.1 Download and Add to your Xcode Project 

Download it with click on the right small arrow, and choose .zip. After that, drag and drop in Xcode into your Support Files.

UIFont Family Name List - Custom UIFont Import 1_2

2.2 Now you need to add your new File names at Info.plist file. 

Click on your Info.plist file, and at "Information Property List" click the plus button, and search (start to type) for "Fonts provided by application". 

UIFont Family Name List - Custom UIFont Import 1_3

Add new File names as new Items. (Very important to use the exact name of the Font file!)

UIFont Family Name List - Custom UIFont Import 1_4 - ITem Names file Names

2.3. Check it!

And Check your Target at Build Phases under the "Copy Bundle Resources", that your all imported files are there! 

UIFont Family Name List - Custom UIFont Import 1_5 - copy bundle resources

3. Check the available Font Families and their Fonts again.

If everything works fine, you can check your available UIFonts again. Run your App. And in Log with cmd+f search for your new Font Name. (First trash your log ;) 

UIFont Family Name List - Custom UIFont Import 1_6

Now you can see your new UIFont names. You must to use these names in your log, if you use it with this form for instance: "string.font = [UIFont fontWithName:@"Lato-Black" size:12];" Sometimes what you can see in log is different from your exact File name. Therefore you need to check it always after your import.

And of course, if you don't add your Font name to your Info.plist file, that will be mot available in your App. At me, I added just 4 type of this Font Family, and if I want to use "Lato-Italic", that will be not work, because I didn't add it to the Info.plist file. 

Download:

Download the Xcode template from Github.

Share & Follow

If you would like to be notified of my new solutions, please subscribe to my Newsletter or my youtube channel and/ or follow me on Facebook or Twitter! Check Footer section for these opportunities!