Wild8x
Wild8x

Reputation: 459

How to use custom font in a tvOS project using SwiftUI?

I made an App for iOS and MacOS and I am now working on the tvOS version. The issue I am facing is that the custom font is not working when I use the following code for tvOS!

import SwiftUI

struct TestView: View {
    var body: some View {
      Text("R")
      .font(.custom("Arial Rounded MT Bold", size: 160))
      .bold()
      .shadow(color: Color.black, radius: 15, x: 15, y: 5)
      .foregroundColor(Color(red: 255 / 255.0, green: 194 / 255.0, blue: 58 / 255.0))
    }
}

struct TestView_Previews: PreviewProvider {
    static var previews: some View {
        TestView()
    }
}

The wrong result with the above code is the below letter:

Wrong Letter

The good letter that should be displayed by the above code should look like the one below:

Good letter I want to writte

What am I missing? Thanks

Upvotes: 1

Views: 408

Answers (1)

Harshil Patel
Harshil Patel

Reputation: 1474

You are right that works for iOS & macOS but doesn't work for tvOS. Maybe because there are different built-in fonts available for iOS and tvOS? I don't have expertise in tvOS, so please don't assume I'm right. I'm guessing it from this available font list.

tvOS: Try something from this list, and I'm sure it'll work.

enter image description here

iOS:

enter image description here

Upvotes: 1

Related Questions