Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Font engine for asian languages

This topic is 6007 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Out of curiosity, I was wondering how could I make a font system for a 3D game for a unicode character set? Normally, a simple way of handling text on screen is to have a texture with 16 rows of 16 characters (or two groups of about 130, NeHe style... but that''s beside the point), representing the 256 ASCII characters. That''s all good for most common languages, but what can we do for other languages like japanese or arabic? How is japanese text rendered in today''s 3D games? I was saying to myself that using unicode in my code would solve all my localization problems, but no... I forgot about displaying the text on the screen. I have a nice text rendering system working and I didn''t have any problem writing it. But for a language with for example 3000 characters, I am clueless. Of course, I could make a big texture, or multiple normal textures. But it could take a lot of memory pretty fast. ---------------- Blaster Computer game programmer and part time human being Strategy First - http://www.strategyfirst.com BlasterSoft - http://www.blastersoft.com

Share this post

Link to post
Share on other sites
I've done this before using either Windows Forms (.Net) or GDI+ to render to a DX8 texture in memory, if you have the right fonts installed it's no problem. You can even turn on antialiasing for the fonts, and write to the alpha channel... It looks quite good. Instead of preloading a texture with the characters you will need to draw the text onto a texture each time.

For Win32 coders, gdiplus has a really great C++ interface which is basically equivalent to System::Drawing in .Net.


[edited by - Corngood on June 4, 2002 7:40:10 PM]

Share this post

Link to post
Share on other sites
Two common solutions for PC games (its usually not practical to have all possible characters in memory - performance wise, memory wise, disk space wise, development time wise etc):

1. As Corngood says, use Windows font/GDI calls to generate each required text string (e.g. "Game Over", "Press Start" etc) into a texture. Very simple, allows all characters user has installed, doesn''t require artists for localisation (i.e. you don''t need to hire a Japanese/Korean/Chinese etc artist to draw new fonts, instead you get a much cheaper translation house to do text->text for you). Downside is past the usual font effects, you don''t really get much in the way of game specific stylisation, and colourful fonts are out.

2. For each string required in game, get an artist to draw the localised string into a texture. Preferably the artist should be able to write the language natively rather than a western artist trying to "hand stylise" script they don''t understand!
The big problem with #2 is if you allow any kind of user text input (player name etc). You''ll notice many Japanese arcade games display pre-defined text in Japanese script, and accept user input in western characters for this reason.

If you''re trying to localise a game which hasn''t been written with wide character/Unicode in mind, #2 is a good idea, particularly if you have a flexible font engine. What you can do is assign one ASCII code per string , and tell your font engine to fetch the pre-drawn string as a single character.

So displaying "GAME OVER" in English might be something like:
MyDisplayText("GAME OVER");

and a cheap/easy localisation of that to Korean with the above method in an engine without Unicode support might be:


Where the engine font definition for the @ symbol would fetch the whole Korean string for GAME OVER from the texture.

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites
In the 2D engine we have at work for the game Disciples 2, we render the text manually to a surface, and update only when the text changes.

I think that''s pretty much the only way for a game with a lot of text.

Computer game programmer and part time human being
Strategy First - http://www.strategyfirst.com
BlasterSoft - http://www.blastersoft.com

Share this post

Link to post
Share on other sites
see how japanese was used in games for nes, snes and other older consoles. if using an emulator, you can see how the buffers are stored etc. most games tended to use katakana and hiragana which reults in only about 90 or so basic symbols (yes you can write any word using them since they are phonetic). it may not look as professional as using the entire >3000 kanji system, but will still be perfectly readable by any japanese native. in fact you could even represent english words using those symbols (ie katakana or hirgana). you can use a symbol managment system, which handles copy the required kanji to the texture buffer (i cant see you needing more then 200 symbols at once).

do some research on the japanese langauge (i will assume you dont know it since you dont know about the katakana/hirigana symbol sets).

personally i plan on use katakana/hiragana approach in my font engine.

btw, i dont know japanese, but have done research on the symbol sets and can confidently say that using the katakana/hiragana symbol sets will be perfectly readable to any japanese native (especially since many games seem to use those symbol sets).

unfortunatly i know nothing about arabic.

Share this post

Link to post
Share on other sites
The system we used for Traditional Chinese (20.000+ characters) is something like this:

Create a Texture (512x512).
Let''s assume one character is 32x32 pixels; that gives us 16x16 characters in the texture, or 256 characters.
Create a buffer-set, of 256.
For each buffer, store
Unicode (init to 0)
Last used (for swapping out)
UVs for the 32x32 space on texture that belongs to this character


When you write a string:
For each character,
if Character in buffer, render
if Character NOT in buffer,
and space available,
add to buffer and render
if no space,
Find least recently used
Replace the node with the new character

This can run into thrashing if you have more than 256 unique characters on-screen at the same time. This is quite unlikely to happen with chinese scripts (a lot of characters are repeating anyways (such as pronouns, some simple verbs, etc), but you can always re-create a larger cache-texture if you find that you''re having to swap out nodes that were entered current frame.

One optimization is to work out all the nodes that need replacing at the start of the drawing-cycle, drawn them all at once, and then blit them into the texturemap.

Good luck,

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!