- Published on
How to add custom fonts to a Swift project
- Authors
- Name
- Jenny Kim
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
andAdd to targets
are checked.
Let the project know about the fonts
- Go to your
Info.plist
file.- if you can't find it, click on your app target, then go to the
Info
tab.
- if you can't find it, click on your app target, then go to the
- Add the key "Fonts provided by application".
- 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))
}