By using larger textures, I could get the characters to display, but they looked so awful that I ended up using images for text. Because we only have 20 strings in game (and no dynamic text except for numbers), the following simple scheme worked well.
I implemented an editor feature to render the text. Because it requires System.Drawing which is unaccessible from the Unity project, I had to compile the core function into a DLL. The basic function takes a string, and several parameters to control the color, font, etc.
Anti-aliasing does not work correctly on a transparent background, so I drew white text on black, and then used this for the alpha of the final image (in a single color - the color of the font).
void RenderText(string text, ... /*lots of parameters.*/)
{
Bitmap image = new Bitmap(width, height);
Graphics g = Graphics.FromImage(image);
g.SmoothingMode = SmoothingMode.AntiAlias;
//render white text on black
g.DrawString(text, /*lots of parameters*/);
// Pseudocode follows!
// this happens at development time
// there is no concern for efficiency
foreach pixel in image
{
alpha = pixel.r; //r, g, and b are all the same - see note below
pixel.rgb = fontColor;
pixel.a = alpha;
}
image.Save(filename);
}
Note: On windows, the `Quality` smoothness type results in text that is rendered using cool type. In this case, the channels are not the same; I assume an aggregate of the channels can be used, but it should probably be the same as plain `AntiAlias`ed text.
My editor plugin simply calls this function for each string in the game.
The actual game then uses these images (loaded as Textures) for labels, instead of strings when the language is Chinese.
The method is crude - here are the disadvantages:
- Not suitable for massive amounts of texts or dynamic text.
- Not suitable to support large number of languages.
- It's a pain to keep the look-and-feel the same as the text for other languages, especially if many styles are used. (I store a style type each string, and then render it out accordingly).
On the upside, for a small number of strings and one or two languages, it is simple to implement (much simpler than to implement your own character-based font renderer), and it looks pretty.