How to Add Custom Fonts to Your Sprite Kit Game
A great looking font is as important as any other graphic in your game. Relying on system apps just won’t cut it! Fortunately adding your own fonts to use in your Xcode project (and ultimately your app) is easy.
- Find the font file in your Finder. Easiest way to do this is to open Font Book. Select the font, right click and choose Show in Finder. I’m going to pick one of my favorite author’s fonts: Back Issues (available at Blambot.com)
2. Drag the font file into the file navigator area of Xcode…
3. When you import the file, be sure you click Add to Targets.
4. Next find your Info.plist file, and add a new entry.
- Hover over an existing entry, or at the top of the plist, and click a + sign.
- Xcode will add a new key.
- Set it to an Array (it should be by default)
- Just begin typing “Font” for the key name, and Fonts Provided by Application should fill itself in.
- Unfold the Array and tap another + to add the first array item (Item 0).
- For the value, enter the exact filename of the font, including the extension.
- Do this for as many custom fonts as you require.
How to Set the Font on an SKLabelNode
Using Swift / Sprite Kit you’d write this…
var countLabel:SKLabelNode = SKLabelNode(fontNamed: "Back Issues BB")
countLabel.fontSize = 25
countLabel.text = String (theCount) //if theCount was a number
How to Set the Font in the Scene Editor
Add a Label to your scene, then set the font in the Attribute Inspector.