Game Development Reference
In-Depth Information
be drawn at the right position, rather than each outline and curve having to be calculated
by the CPU and then drawn onto the frame buffer. With the font being sprites, you can
also use any image as a glyph. The screenshot of Glyph Designer in Figure 11-13 illus-
trates this perfectly.
Figure 11-13 . Any image can be used as a glyph in a bitmap font
As long as a label's text doesn't change at all, the rendering performance of TrueType and
bitmap fonts in Cocos2D is the same. Both are drawn just like sprites. If you are consider-
ing having multiple labels using the same font, bitmap fonts will be faster because the bit-
map font can draw all glyphs from the same texture, whereas the TrueType label uses a
unique texture for each label. This also affects memory usage—with few labels, TrueType
fonts may require less memory, but each additional TrueType font label eats up signific-
antly more memory than additional bitmap font labels using the same font.
Also, if the text of a TrueType font changes, a new texture needs to be created with the
new text rendering. It's the throwing away the old texture and replacing it with a new one
part that makes TrueType labels particularly unfitting for text that frequently changes. The
larger the area occupied by the label, the longer it takes to update its text.
So while you can make decent menus with TrueType fonts and get to choose from a great
variety of fonts, for any in-game UI text that changes frequently (scores, lives, timers, unit
names, etc.), you should consider using bitmap fonts. In fact, the performance hit of a
TrueType font label can be so severe that updating even a single timer label every second
can cause the game to hiccup slightly when the label is updated.
Search WWH ::




Custom Search