ENGINE PLUGIN: AGSBMFontRenderer - UTF-8 Text Renderer

Started by birthggd, Mon 25/05/2015 14:55:36

Previous topic - Next topic

Crimson Wizard

Quote from: shaun9991 on Wed 23/12/2020 16:37:53
Thanks Crimson Wizard! Would you need the source files or just a build of the game?

I think game build may be enough for starters, because I just want to see what's going inside the engine when game runs. It would be also a great help if I knew how to reproduce a problem (maybe some debug command that prints text on screen, or a save to load).

shaun9991

Thanks so much CW, I've just sent you a PM with a link :)
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

Crimson Wizard

#22
Ok, I looked into this, and situation is following.

Even though you have this plugin that can understand utf8 text, AGS still does not know that it's utf8. So when it comes to line splitting, it tries it byte by byte, and since utf8 character can be multibyte, AGS may unknowlingly cut a character code in half.
I don't know utf8 codes very well, but apparently AGS cannot even find a "space" there (are there regular spaces between words in Chinese?)
Plugin does not like it when it happens and does not have any safe countermeasures, so it reports weird line widths (sometimes 0 or 1).
And even if it could workaround that, the text data is cut incorrectly so some letters would not be displayed anyway.

The trivial (but manual) solution is to try adding line breaks (either '\n' or '[' characters) to prevent AGS from trying to cut in the middle of the word. I think that even spaces would work, but like I said, I don't know if Chinese is allowed to have these.

Crimson Wizard

In theory there could be automated solutions too, but not certain which to recommend here.

For example, you could use custom Say function, which calculates linebreaks itself before calling real Say (note that AGS 3.5.0 supports using custom Say function when compiling dialogs too).

Or, you may make a custom version of the engine with UTF-aware line splitting.

shaun9991

Hi CW,

Sorry for my delayed reply - thanks so much for looking into this, I really appreciate it. I'll look into adding line breaks/creating a custom function for sure.

Daneeca confirmed he had the exact same issue with the Chinese translation for "Falcon City" - his workaround was asking the translator to insert regular spaces in the Chinese text. Chinese language doesn't have spaces between words so that's what is causing the issue with the plugin - but apparently Chinese text is still perfectly readable when spaces are indeed inserted in the right places. I tested this out in our game and it does fix things. Feels like a bit of a weird workaround though so I will keep trying to get to the bottom of it!
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

Crimson Wizard

#25
Quote from: shaun9991 on Mon 11/01/2021 14:44:39
Daneeca confirmed he had the exact same issue with the Chinese translation for "Falcon City" - his workaround was asking the translator to insert regular spaces in the Chinese text

That might be the easiest solution.


Quote from: shaun9991 on Mon 11/01/2021 14:44:39Feels like a bit of a weird workaround though so I will keep trying to get to the bottom of it!

AGS treats spaces as points where it may break a text. As I mentioned in my post above, without linebreaks or spaces it does not know where to break it correctly, and splits in the middle of the word. But because it cannot handle UTF-8 text it sees it just as a sequence of bytes, and so the split may occur inside UTF-8 wide character, corrupting the text data.

SMF spam blocked by CleanTalk