idea for using a Chinese font: would this work?

Started by EnterTheStory (aka tolworthy), Wed 28/01/2009 09:09:23

Previous topic - Next topic

EnterTheStory (aka tolworthy)

I've been thinking of how to display a Chinese font in my game. What do you think? It would be a big job and don't speak Chinese so I thought I'd run it past you guys first.

1. Create a sprite for each Chinese character (I gather that simplified Chinese has 6500 characters.)

2. write a non-AGS program to convert this:

Code: ags

"random string in unicode font"


to this:

Code: ags

"12 345 6 78 901 2345 67..."  // sprite numbers and spaces, in a normal TTF font


3. Write a non-AGS program to convert a translation source. So this

Code: ags
"English line
Chinese line
English line
Chinese line"


becomes this

Code: ags
English line
12 345 6 78 901 2345 67
English line
890 12 345 67 8 901 23


4. Create 5 GUIs to act as speech balloons, with 20 buttons each
(for 20 sprites - i.e. you allow up to 100 words per Chinese sentence)

5. Create an alternative 'say' function

Code: ags

function sayChinese(String chinese_as_numbers)
{	// split the string into numbers
	// change the sprites used on the GUIs
	// decide the best x,y positions for GUIs and buttons, make visible
	// decide the best delay, etc.
}


Do you think that would work?

Gilbert

It may work, but it wouldn't be a good thing to have thousands of files scattered around in the game's folder.

Actually I have an idea, but never had the interest to try it out, maybe it can give you some inspirations.

My idea is to have one (or a few) large bitmaps with characters put onto it (them) systematically. So when you want to display a certain character, make some calculations based on its code to find out on (which bitmap,) which line and which entry it should be and use the dynamic sprite functions to crop the required region as a sprite.

Furthermore, you don't really need to use GUI with lots of buttons. Instead, you may print the required string of characters on a single, larger dynamic sprite and display it as an overlay, character, GUI or whatever.

However, if in one day AGS starts to support multibyte character TTF we don't need this so this is also one reason I don't want to try it.

EnterTheStory (aka tolworthy)

#2
Quote from: Gilbet V7000a on Wed 28/01/2009 09:51:26it wouldn't be a good thing to have thousands of files scattered around in the game's folder.

You mean inside the AGS internal sprite manager? I already have 5000 sprites there, so another 6000 wouldn't make much difference.

Quote from: Gilbet V7000a on Wed 28/01/2009 09:51:26use the dynamic sprite functions

I agree that would be a better plan, but I use 2.72. There's a known bug with releasing the memory for dynamic sprites in 2.72 (sorry, can't find the link). Dynamic sprites are fine for the occasional use, but for frequent use a crash is almost guaranteed (as I discovered the hard way - e.g. with repeated use of the Simple Snow module)

SSH

12

EnterTheStory (aka tolworthy)

#4
Quote from: SSH on Wed 28/01/2009 12:22:16my SpriteFonts module?

Your modules are always excellent, but can this one handle a font with 6500+ characters? Doesn't it rely on an input font in a form that AGS recognizes? And doesn't it use dynamic sprites and would thus be susceptible to the 2.72 bug in not always returning memory correctly?

Gilbert

Quote from: tolworthy on Wed 28/01/2009 10:37:06
You mean inside the AGS internal sprite manager? I already have 5000 sprites there, so another 6000 wouldn't make much difference.
Either way, be they be thousands of imported sprites or loaded from external files, they still cause a mess.

Quote
I agree that would be a better plan, but I use 2.72. There's a known bug with releasing the memory for dynamic sprites in 2.72 (sorry, can't find the link). Dynamic sprites are fine for the occasional use, but for frequent use a crash is almost guaranteed (as I discovered the hard way - e.g. with repeated use of the Simple Snow module)
Hmmm Can't you upgrade to V3+ then? Though personally I'll wait until AGS really support multibyte TTF as displaying Chinese in my games is never my priority.

SSH

Quote from: tolworthy on Wed 28/01/2009 13:02:10
Quote from: SSH on Wed 28/01/2009 12:22:16my SpriteFonts module?

Your modules are always excellent, but can this one handle a font with 6500+ characters?
No, not yet, but it wouldn't be hard to adapt it. Are you actually using all the characters?

Quote
Doesn't it rely on an input font in a form that AGS recognizes?
Well, it needs the font in the format of sprites.

Quote
And doesn't it use dynamic sprites and would thus be susceptible to the 2.72 bug in not always returning memory correctly?

Its quite easy to write dynamic sprite code badly. I'm not sure that there actually is a bug in AGS.

Also, have you considered pre-rendering the whole translations as sprites rather than working on a character-by-character basis? Are just a few characters talking in Chinese, or do you mean translating the whole game to Chinese?
12

EnterTheStory (aka tolworthy)

#7
Quote from: SSH on Wed 28/01/2009 15:40:41Are you actually using all the characters? ... do you mean translating the whole game to Chinese

Someone has offered to translate my Les Miserables game into Chinese. It has a huge amount of text (the translation source file is about 2 MB) so it probably uses a fair few. And if I got o the trouble of making it possible in one game, I'd like to make it a general purpose solution that can be adapted to other games and other large character sets.

Quote from: SSH on Wed 28/01/2009 15:40:41
Quote
And doesn't it use dynamic sprites and would thus be susceptible to the 2.72 bug in not always returning memory correctly?
Its quite easy to write dynamic sprite code badly. I'm not sure that there actually is a bug in AGS.
Your snow code was perfect. But it crashed under the exact same circumstances described in this thread: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=35654.msg467392#msg467392

Quote from: SSH on Wed 28/01/2009 15:40:41
Quotecan this one handle a font with 6500+ characters?
No, not yet, but it wouldn't be hard to adapt it.
Even by a relative novice like me?

UPDATE:

My Chinese friend is keen to go ahead, and I think I have all the tools I need. Except one: a program to take an AGS translation file, and change unicode characters into their unicode numbers. So this:

Code: ags

"English line
Chinese line
English line
Chinese line"


becomes this:

Code: ags

English line
12 345 6 78 901 2345 67
English line
890 12 345 67 8 901 23


I don't have the skills or tools to write that myself - would any kind person on the board be willing to do it?

SMF spam blocked by CleanTalk