ngmoco:)


At ngmoco, cultivating an intellectually honest exchange of ideas and dialogue around the development of iPhone games is important to everyone at the company. The purpose of this blog is to highlight what we're learning as a company. In this space, expect to see interviews with leaders in iPhone gamemaking, data analysis and market trends on the iPhone games business, post-mortems, case studies, development techniques and code samples from ngmoco’s games, and regular blog entries on a variety of topics germane to making iPhone games.
Apr 14 2009 :)

Localized iPhone Fonts

Typically during production, adding support for non-ASCII character sets is not exactly a high priority for developers (even though it might be for publishers).  But unlike most consoles, the iPhone delivers a nearly complete solution out of the box.

And I’m not referring to UIFont.  While its results are solid, UIFont is not only slow to load but also carries a heavy performance cost when used in an OpenGL context.

The key is to use the same system that underlies UIFont, which is the Carbon-based CGFont.  CGFont provides the same results as its ObjC counterpart, but also gives us a way to minimize the runtime cost.  This can be done by creating glyph textures by using a CGBitmapContext as an intermediary between CGFont and OpenGL.

There’s a catch, however: we need glyph indices in order to use this function, and CGFont doesn’t give us any way to convert characters into their corresponding glyph indices.  One way to get around this is to use the open source font library FreeType.  FreeType has a flexible license, and can be built for the iPhone fairly easily.

The iPhone provides one more thing that we can take advantage of: localized system fonts.  These can be found in /System/Library/Fonts/Cache/, and can save valuable time and disk space, as Japanese fonts alone can easily weigh into tens of megabytes.  At the same time, there’s also a risk involved: Apple may move or withdraw access to these fonts at any time, so if you use them, be prepared to provide an alternate solution at short notice.

- Andrew

Comments (View)
blog comments powered by Disqus
Page 1 of 1