1

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

Wild8x
  • 459
  • 4
  • 13

1 Answers1

1

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

Harshil Patel
  • 1,318
  • 1
  • 7
  • 26
  • Thanks a lot for your help. Finally I used the font called "Courier" found in your list you forward me. This is the font that is the closest from the rounded letter I wanted. It is a pitty that I could not use the same font I used on iOS and MacOS. – Wild8x Nov 13 '20 at 18:54
  • @Wild8x If you want to keep fonts the same on all platforms, I prefer you import something your own. For that, I recommend these two [Swift](https://stackoverflow.com/questions/32060384/use-custom-font-in-swift) | [SwiftUI](https://medium.com/better-programming/swiftui-basics-importing-custom-fonts-b6396d17424d). Let me know if you have any questions! – Harshil Patel Nov 14 '20 at 04:36
  • Hi @Luffy, finally I managed to found the missing fonts on 'cufonfonts.com' and I followed the tutorial you pointed to me... It works fine! Thanks again. – Wild8x Nov 25 '20 at 14:59
  • @Wild8x glad to hear that :) – Harshil Patel Nov 25 '20 at 15:01