0

Can't find any issue about this, so:

SceneKit, Xcode 10.1

Applying font to SCNText:

enter image description here

Result:

enter image description here

Even when I'm:

textNode.geometry?.font = UIFont(name: "SF Mono Heavy", size: 170)

it is still in default font look.

I'm also tried a lot of other different fonts, but no luck.

What do I do wrong?

  • 1
    Just because the font name appears on the Font drop-down menu there, that doesn't mean your app is ready to utilize it. – El Tomato Mar 18 '19 at 09:09
  • You mean for SceneKit? How to do it properly? – lenyapugachev Mar 18 '19 at 10:46
  • Please Try With This I hope in Font Name Can't Give Space. textNode.geometry?.font = UIFont(name: "SFMono-Heavy", size: 170) – Kops Mar 18 '19 at 11:32
  • 1
    1. Write out all font names with let familyList = UIFont.familyNames to make sure that you have the right font name. 2. Select the font file and make sure that the target checkbox is on. 3. Run a search for custom fonts ios to read other topics. – El Tomato Mar 18 '19 at 13:09

2 Answers2

0

The first level of debugging would be to verify that the UIFont object isn't nil. What happens if you print the object? The editor is used on macOS. Are you sure the font exists on iOS?

mnuages
  • 13,049
  • 2
  • 23
  • 40
0

It's very likely the SIZE IS INCREDIBLY TOO LARGE.

The typical size you use for text in SCNText is 0.1.

SCNText is not measured in points, it is measured in meters.

  1. put a 1 meter cube in your scene

  2. run the scene and be sure you can see all of the cube

  3. now add some text with size "1". sit it in front of the cube towards the camera.

Now you should see it.

Font names:

for family in UIFont.familyNames.sorted() {
 print("family: \(family) names: (UIFont.fontNames(forFamilyName: family))")
}

Put that code anywhere in the app in a viewDidLoad. You will get the exact names you must use.

Fattie
  • 27,874
  • 70
  • 431
  • 719