How to use custom font in a SpriteKit project? - fast

I am new to fast and I would like to add my own font to my SpriteKit project, however, after inspecting, I cannot find a solution.

+7
source share
1 answer
  1. First of all, you need to drag the font into the project.
  2. After that, you need to select the font and set the target “Membership” checkbox for your application, as shown in the figure.

Xcode window with selected target membership for the custom font

  1. After that, you go to your Info.plist and add the font name (with extension) to "Fonts provided by the application"

  2. Now you can use the font just like any other font. If this does not work as it should, you can find out the name that Xcode gave the font with

Swift:

for name in UIFont.familyNames() { println(name) if let nameString = name as? String{ println(UIFont.fontNamesForFamilyName(nameString)) } } 

Swift 3:

 for name in UIFont.familyNames { print(name) if let nameString = name as? String { print(UIFont.fontNames(forFamilyName: nameString)) } } 
  1. Now just use the font, for example, in your SKLabelNode.
+9
source

Source: https://habr.com/ru/post/973647/


All Articles