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

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

4 Comments

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 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 | SwiftUI. Let me know if you have any questions!
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 glad to hear that :)
0

While your font indeed does not seem to work on tvOS note that you can use a system font with rounded design which looks quite similar (but not exactly the same) to the rounded Arial font you wanted:

Text("R")
    .font(.system(size: 160, weight: .bold, design: .rounded))
    .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))

enter image description here

Also in case someone wants to use a rounded system font in UIKit on tvOS it can also be done:

UIFont.boldSystemFont(ofSize: 160).rounded()

// ...

extension UIFont {
    func rounded() -> UIFont {
        if #available(iOS 13.0, tvOS 13.0, *) {
            guard let descriptor = fontDescriptor.withDesign(.rounded) else {
                return self
            }
            return UIFont(descriptor: descriptor, size: pointSize)
        } else {
            return self
        }
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.