logo
Published on

How to add custom fonts to a Swift project

Authors
  • avatar
    Name
    Jenny Kim
    Twitter

How to add custom fonts to a Swift project

Prepare the fonts

You can add True Type Font (.ttf) and Open Type Font (.otf)

Add fonts

  • Two-finger click on the folder in the Project Navigator and select Add Files to "Project Name".
  • Make sure both Copy items if needed and Add to targets are checked.

Let the project know about the fonts

  1. Go to your Info.plist file.
    • if you can't find it, click on your app target, then go to the Info tab.
  2. Add the key "Fonts provided by application".
  3. Add an item for each font you want to use.
    • The value should be the name of the font file, including the extension.

Use the fonts

VStack {
    Text("Hello, this is a custom font!")
        .font(.custom("FontName", size: 20))
}