2

I have already imported the SOV_Assadong_C.tff file to my project using SwiftUI library. Plus, I added SOV_Assadong_C.tff value under the Fonts provided by application key in Information property list:

enter image description here

When I used the below code, the text still showed the system font.

Text("Hello")
   .font(.custom("SOV_Assadong_C", size: 70))
   .foregroundColor(fontColor)

How to fix it?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
kkk
  • 187
  • 8
  • What platform are you targeting? For macOS, you should use `ATSApplicationFontsPath` instead of `UIAppFonts` – Ranoiaetep Feb 02 '23 at 18:41

1 Answers1

1

Xcode 14.3 beta 1 (target iOS 16.4)

Drag-and-drop your .ttf font into the Navigator pane (don't forget to add it to the target).

enter image description here

Add the .ttf extension to your custom font name in the project's Info tab. Restart Xcode.

enter image description here

DO NOT use .ttf extension in your code:

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Phantasmagoria")
                .frame(maxWidth: .infinity, maxHeight: .infinity)
                .background(.black)
                .foregroundColor(.white)
                .font(.custom("SOV_Assadong_C", size: 120))
        }
    }
}

enter image description here

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220