0

So I'm trying to use a custom font "Impact". It works fine if the font is installed on the computer, but if it's not I can't seem to get it to work. I bring in the .ttf file to the project, add it to the info.plist like this:

Impact.ttf

And I've tried multiple methods for using that font on a SKLabel but nothing works. Here's what I've tried:

let restartLabel: SKLabelNode =  SKLabelNode(fontNamed: "Impact-Regular")
let restartLabel: SKLabelNode = SKLabelNode(fontNamed: "Impact")
let restartLabel: SKLabelNode = SKLabelNode(fontNamed: "Impact.ttf")

Any ideas? I would really appreciate the help, thanks!

CodyMace
  • 646
  • 1
  • 8
  • 19
  • 1
    possible duplicate of [Using custom fonts in Xcode 6 - Swift](http://stackoverflow.com/questions/25290400/using-custom-fonts-in-xcode-6-swift) – sangony Mar 19 '15 at 15:18
  • @sangony sadly nothing from that works. I've got the font in copy bundle resources, it's part of the target, everything. I've done this before but on iOS but not OSX, I guess I can check and see if it works on iOS. – CodyMace Mar 19 '15 at 21:16
  • Ok, I just tested the same exact code and process on iOS and it worked. So it must be some issue with spriteKit on Mac or something. – CodyMace Mar 19 '15 at 21:22

2 Answers2

0

You need to use the exact same name of your font. So if you want to use the Impact Regular font, you need to call it like that:

SKLabelNode(fontNamed: "Impact Regular")

Without the -.

Christian
  • 22,585
  • 9
  • 80
  • 106
0

The correct answer is here Custom font in a Cocoa application

It turns out that the app didn't know where to look for the font, but setting the Application fonts resource path in info.plist made it work. I actually left the value blank since the font in just in MyApp.app/Contents/Resources/

Community
  • 1
  • 1
CodyMace
  • 646
  • 1
  • 8
  • 19