Friday 1 March 2013

Listing the Fonts Available in iOS

The CCLabelTTF class relies on the fonts available in the iOS, and Apple is always adding to the available fonts with each iOS release. The best way to know what fonts you can use is to query the iOS for available fonts under the UIFont class. Jonathan Saggau wrote an excellent bit of compact code to list out the fonts. A modified version of it is given here and can be dropped in the init method of GameScene.m to print out the available fonts to your console.









Fonts are part of a font family, and the UIFont class returns a list of all of the font families available in iOS as well as the fonts under each font family. The code above first gets a list of all the font families, and then a list of all the fonts under each fam- ily, printing those font names out to the console window.

No comments:

Post a Comment