Using custom fonts in SwiftUI
iOS comes with many preinstalled fonts that can be safely used in SwiftUI. However, the design sometimes needs some custom fonts because they might be a part of the brand of the app maker, for example.
In this recipe, we'll see how to import a couple of custom fonts to use for building a menu page of an Italian restaurant.
Getting ready
Create a SwiftUI app called RestaurantMenu
.
Copy the Sacramento, Oleo Script Regular, and Oleo Script Bold custom fonts, which you can find in the repository at https://github.com/PacktPublishing/SwiftUI-Cookbook-2nd-Edition/tree/main/Resources/Chapter15/recipe5.
The fonts must be added to the project:
Finally, the fonts must be copied during the installation, so add them in the Copy Bundle Resources phase:
How to do it…
Besides the...