looking to use YaHei simplified chinese in one of my language files.

bit of trouble in getting the unable to locate character thing.

Wondering how i go about knowing a fonts correct character regions? Say if i dip into my fonts folder on MS and pick a random one, how do i know what the values should be on our font importer?

All fonts have the same “regions”, they’re just unicode character ranges. MG spritefont files define those ranges using decimal indexes, as opposed to hex.

Assuming you don’t need to render dynamic content (user-generated input, for example), my preference for dealing with this is to make a tool that generates your .spritefont files with only the exact characters needed for Asian languages. Including the full range of all Chinese characters and/or Japanese kanjis is a BIG list.

Here’s the main meat of one such tool I wrote (a tool designed to read our localization files and spit out character regions for any characters it found in them, for all languages):

List<int> decimalIndexesUsed = new List<int>();
for (int i = 32; i <= 126; i++) // we need basic latan characters 32 to 126 (the standard set) for things like URLs and such that are not found in localization files
foreach (string file in Directory.GetFiles(ROOT_PATH + "Localization"))
	string content = File.ReadAllText(file);
	foreach (char c in content)
		if (!decimalIndexesUsed.Contains(c))


Dictionary<int, int> ranges = new Dictionary<int, int>();
int currStart = decimalIndexesUsed[0];
for (int i = 1; i < decimalIndexesUsed.Count; i++)
	if (decimalIndexesUsed[i] != decimalIndexesUsed[i - 1] + 1) // if not the very next number, need to end the previous range and start a new one
		ranges[currStart] = decimalIndexesUsed[i - 1];
		currStart = decimalIndexesUsed[i];
ranges[currStart] = decimalIndexesUsed[decimalIndexesUsed.Count - 1];

string charRegionsXml = "";
foreach (KeyValuePair<int, int> range in ranges)
	charRegionsXml += "\n\t\t\t<CharacterRegion>\n\t\t\t\t<Start>&#" + range.Key + ";</Start>\n\t\t\t\t<End>&#" + range.Value + ";</End>\n\t\t\t</CharacterRegion>";
1 Like

Hey Thank alot !

Very Interesting!

Here are the defaults using Font Forge to view and edit the font

I love your Import Technique!

1 Like