Game Development Community

Any way to draw Chinese (or other wide character) in TGE?

by Douglas Tai · in Torque Game Engine · 01/15/2003 (7:36 am) · 1 replies

hi all~

i'm a game developer in HK, and i'm going to develop a chinese game on Windows platform. However i'm facing a big problem: TGE cannot display Chinese text!!! i've tried to add Chinese text in aboutDlg.gui as below:

function aboutDlg::onWake(%this)
{
   %text="<just:center><font:Arial Bold:20>Torque Game Engine Test Application\n( v1.1.1 )\n"@
         "<font:Arial:12>"@ getCompileTimeString() @", "@ getBuildString() @"Build\n\n"@
         "<font:MingLiU:16>Copyright &#25105;&#26159;&#20154; (c) 2001 <a:www.garagegames.com>GarageGames.Com</a>\n"@
         "Portions Copyright (c) 2001 by Sierra Online, Inc.\n\n"@
         "<bitmap:"@ ExpandFilename("./gglogo150.png") @">";
   aboutText.setText(%text);   
}

but when running the game, it just display some strange characters to me...
www.angelfire.com/mac/dt_dojo/pic/chi.JPG

does anyone got a solution or two for me? i'm thinking of 2, but still dunno how to make it done

1. use Windows GDI, DirectX, CDX etc. to draw Chinese text on an image, then ask TGE to load the image and display it. But it will have bottleneck coz there will be lots of FileIO
2. i GUESS the TGE seem to read text in byte by byte pattern (if wrong pls tell me), so make the TGE can read wide character then everything will be fine. however i dunno where i should start the modification.

it would be very great for any suggestion or discussion for this!

#1
01/15/2003 (7:45 pm)
Torque generates ASCII font sets at the moment, so far as I know the system. Basically, it takes a platform font and generates a bitmap so that all text rendering is bitmap based.

You could easily write your own code that has a text control that uses GDI calls to render into a texture surface (or into a buffer that you copy into a texture) and then straight-map the section of the texture with the text you want.

My old engine (RIVET, from Reality Bytes) did no pregenerated fonts -- everything was originally rendered live into the backbuffer. While this is slow, it works with any GDI calls. The next level of abstraction is to render into a 512x256 or so buffer that's mapped into a texture and the text is rendered via the texture.

I don't know of any direct-GDI facilities, especially since the code is so crossplatform. I'd think I would have stumbled on it if it was a general function.

SO, in closing, you can easily do it, you just need to code up the best solution that fits your needs... ;) There's a half dozen approaches, I'm sure, depending on how much text, how many fonts, how many characters in the fontset, etc.

d