pioneerspacesim/pioneer — pull request #2808 by robn (2014-03-11 11:42:10+00:00)
Title: Select font by Unicode range

Background: http://pioneerspacesim.net/forum/viewtopic.php?f=4&t=165

* Maps a single game font (eg `UIFont`) to one or more underlying font (Freetype objects).
* Font selected by Unicode range. Current fonts include default and Cyrillic ranges. CJK ranges or anything else are trivial to add.
* Font config files changed to JSON due to added complexity.

What it means is that you can now throw arbitrary Unicode characters into a string and provided there's a font defined for that range, they'll be rendered, allowing Latin, Cyrillic, CJK and whatever else all to be on screen at the same time.

![](https://f.cloud.github.com/assets/130670/2384694/78f20388-a911-11e3-9378-1af75bd0ce76.png)

To test, you'll need to throw a selection of characters into a string somewhere. If you want to test CJK support, you'll need to grab an appropriate font and add CJK ranges - see the forum thread for an example.

Some parts of the implementation are suboptimal, particularly in font config and face lookup. Its not really noticeable, and once the glyph atlas is filled with the majority of glyphs then it won't really be a problem. I'm not optimising right now, this works and shouldn't really be noticeable.

Once this is merged, I'll be changing the various `LANG_NAME` translations keys to use their native character set, which should look great. I'd like to select a better font for Cyrillic coverage (particularly for headings), and finally, select an ideal CJK font. And that should, hopefully, be everything for this round of text rendering hackery :)