Sign in to follow this  
slicer4ever

Handling other languages and font.

Recommended Posts

slicer4ever    6760

my current font system is pretty simple, at the game launch, I build a texture palette of common letters, with ascii this is generally between glyphs 32 to 96 covers the English language pretty decently.  Then when i draw a string, I just create a mesh, with the appropriate texture coordinates for the glyph, and do a check that the glyph is inside my range of supported glyphs.

 

However, i've been thinking of how to extend this to other languages, my palette system can be modified to use unicode glyphs relatively easily, but I don't know what a good range is for covering a good variety of common characters in say Chinese, Japanese, french, German, russian etc.  since the input from players is likely going to be in their language, rather than english(particularly if targeting mobile platforms), these would mean that when i'm drawing something with my font code, it wouldn't draw anything as all the input glyphs could be outside my supported range.  creating a texture with all possible glyphs seems rather insane as well.  I've also considered having "pages" of textures, but that would be rather inefficient as it means having to switch textures every time a glyph in a different "page" is detected.

 

so what are other people's solutions for dealing with this problem?

Share this post


Link to post
Share on other sites

creating a texture with all possible glyphs seems rather insane as well.  I've also considered having "pages" of textures, but that would be rather inefficient as it means having to switch textures every time a glyph in a different "page" is detected.

 

That's usually how it's done. You can make it more efficient by drawing all your glyphs from one page before changing the texture (need to prepass the string and batch the location and image uv's of glyphs from each page, then draw a page at a time).

Share this post


Link to post
Share on other sites
tanzanite7    1410
To get a minimum passable support you need to support at least every code point between 0 and 65535 (thous that have anything valid defined). To get a reasonably good support one should also support combining characters and code points above 65535.

Generating any texture to cover it is impossible. You have to generate and prune them on the fly as needed and possibly combine them yourself in the CPU side as GPU tends to be very inefficient/limiting to hack text together.

Share this post


Link to post
Share on other sites
C0lumbo    4411

For EFIGS (English, French, German, Italian, Spanish) the ANSI range between 0-256 should suffice.

 

When you add more exotic languages (e.g. Japanese), then there's really two options:

 

1. Tie an offline font generation tool into your localisation spreadsheet so that you can generate a list of required glyphs, and output just the ones that are required, plus maybe a few extras for user input (e.g. roman alphabet, common punctuation and hiragana/katakana alphabets).

2. Generate the glyphs you need on the fly from a truetype font using a library like FreeType.

 

The advantage of #1 is that the performance and memory impact is more predictable, it's the approach I've always used on console/handheld games. The advantage of #2 is that it's more flexible, particularly for user input.

 

I'd say that if your user input is quite a small part of the game (e.g. player enters their name for multiplayer), then use approach #1 as it's probably easier to implement and easier to test. I think Chinese/Japanese games players are quite used to having restricted characters for name entry.

 

If text entry is central to your app (e.g. a messaging app or something), then go with option 2.

Share this post


Link to post
Share on other sites
slicer4ever    6760

Thanks everybody for the input.  I think my best bet is going to be using something like the bmfont tool with pre-parsing text to draw as many of the glpyhs on the same texture as possible in as few passes as possible.

Share this post


Link to post
Share on other sites
SiCrane    11839
Note that not all fonts are equal when it comes to rendering East Asian languages. For instance, there are some characters that are written differently in Japanese and Simplified Chinese that share the same unicode code point. Same with traditional Chinese and simplified Chinese. Getting it right for the different languages involves using the right font for each supported language. What's worse is that a font for one language may not have the information for characters from another language. So if you use a Japanese font for Chinese text occasionally you'll get the outcome where it looks like your text is rendered in two different fonts. What's happening is that font fallback kicks in for the unknown characters and the system tries to find a font that does support that language, so you really are rendering in two different fonts at the same time. Needless to say, this all adds up to quite a bit of a pain in the rear if you want "proper" East Asian language support.

Share this post


Link to post
Share on other sites
LorenzoGatti    4442

If you want to support all Unicode characters for which you have fonts in arbitrary user input, you could use fonts directly in the input phase (with the game paused, inefficiency should be tolerable) and then build a texture atlas at runtime containing either the actually used characters or rendered strings.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this