9

Now that Apple has taken away the Plist, naturally it has changed the way we add custom fonts to our app. Before we just added the file to our bundle and set a property for it and our plist and viola..

Now I am curious.. can it be done without adding a custom plist as shown here or is that the only option?

3 Answers 3

19
  1. drag and drop your font-file into the project (make sure you hit copy if needed and check the target box)

drag&drop

  1. choose Project -> Targets -> Info -> Custom iOS Target Properties and klick the small + icon under the "key" property. Start typing "Fonts provided by application"

enter image description here

  1. enter the full font-filename inside this property-list

enter image description here

  1. now you can use the font by its name

  2. (Bonus: if you have trouble to find the font name, you can print all available fonts with [see detail explanation for this at code with chris ]:

 for family: String in UIFont.familyNames
        {
            print(family)
            for names: String in UIFont.fontNames(forFamilyName: family)
            {
                print("== \(names)")
            }
        }

Sign up to request clarification or add additional context in comments.

Comments

3

You can add font files name same as you add in project directory info.plist

Just go to

Project -> Targets -> Info -> Custom iOS Target Properties

Add your all permission or file here.

enter image description here

1 Comment

I don't think that's what he or she is talking about if you read the forwarding topic.
0

Also when using the font in swiftui you need to remove the .ttf

so Silkscreen-Regular.ttf is Silkscreen-Regular

struct ContentView: View {
var body: some View {
//run this init to get a list of all of the fonts you project can see
 init() {
    for familyName in UIFont.familyNames {
        print(familyName)
        for fontName in UIFont.fontNames(forFamilyName: familyName){
            print("--\(fontName)")
        }
    }
   }
  }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.