Unicode fonts in XNA

Originally posted to Shawn Hargreaves Blog on MSDN, Thursday, April 26, 2007

The XNA font system supports full Unicode character sets.

The default XML font description includes only characters 0x20 to 0x7E, which corresponds to the "Basic Latin" Unicode range, but you can easily add other character regions by modifying the XML file. For European languages you will typically want some of the "Latin-1" and perhaps the "Latin Extended" ranges. See http://www.unicode.org/charts for a complete list of what is available.

Japanese, Chinese, and Korean characters are located in the "Unified CJK Ideographs" range, but these languages present a special challenge for game developers. Because they have so many characters, converting their entire Unicode range would produce an enormous font and take up way too much memory. Fortunately most games only ever use a tiny subset of the possible characters, so you can optimize the font size by including only those characters the game is going to need. You can do this by writing a custom processor that reads in whatever text resources the game is using, scans over all the characters in this text, and selectively adds just those characters to the font being converted.

Our text layout engine is very simple and does not support combining characters, so it cannot handle languages with complex layout rules such as Arabic or Thai.

Blog index   -   Back to my homepage