Thursday, August 21, 2014

Spritebuilder Font Not Working in Game

Adding a custom font using Spritebuilder is not that hard if you have a TTF file.  You name the file the same as the font name, drag it into Spritebuilder, and select that font file in  your CCLabelTTF.

All was good in Spritebuilder, but Xcode did not show the font.  After trying other fonts which worked I concluded that maybe the font name needs to not have spaces in them.  So I looked for a TTF editor on the web.  This is very hard to find and the 2 that I found were source code only.  I'm not a Python person so installing using Python was a bit scary.  Luckily this blog helped me through it:  http://www.fontgeek.net/blog/?p=435

The tool that I found was TTX (http://www.fontgeek.net/blog/?p=343).  It supposedly converts a TTF file into XML which you can edit via a text editor and then you can convert it back to TTF.  So I converted it to XML and found that the font name was not in too many places.  The font name was supposed to be "KenPixel Mini Regular", but I found more of "KenPixel Mini".  Anyway I replaced the text to "KenPixelMiniRegular".  Then I tried converting it back to TTF and it FAILED.  Great.

Last resort, I tried renaming the filename to KenPixel Mini.ttf.  It worked in SpriteBuilder, and by some miracle it worked in the simulator.  Success!

No comments:

Post a Comment