Unicode support via plugin?

Started by Snarky, Sat 15/04/2017 14:46:11

Previous topic - Next topic

Snarky

It occurred to me today: Given that implementing Unicode support in the engine is apparently a daunting task, would it be possible to provide it via a plugin for now?

What I'm thinking is that you'd export a translation file, which you would then edit and save in Unicode format. The plugin would read the file (parsing the Unicode) and render the text (using a font library), passing it back as an overlay to AGS â€" basically the same thing (I assume) the Sprite Font plugin does. Since the bitmap font formats used by AGS can't support an extensive set of Unicode glyphs, the plugin would only need to work with TTF fonts.

Am I overlooking some major roadblock, or is it worth a shot?

Crimson Wizard

Yes, this could be a way to go.
Although, there are other things, like raw drawing (printing text on surface), word parsing, string comparison in scripts, which won't be covered by this, but I guess there could be workarounds for that.

Snarky

#2
Cool! Good to know. A plugin could probably offer APIs for some of those other things too, at least DynamicSprite.DrawString() and String comparisons, though I'm not sure you could get text input from the user, and some stuff wouldn't be 100%. And there are other concerns, of course. (Like, does adding plugin-based Unicode support for the sake of one translation mean that the whole game now depends on the plugin even for other languages?) Still, it wouldn't hurt to try... I've never written a plugin before, so it's an interesting project.

Edit: I've had a look at the engine plugin API, and it looks feasible... in fact, it looks pretty simple. Here's what I'm currently thinking:

Create a translation file that contains the Unicode text in some UTF format.

Implement the IAGSFontRenderer interface. In the RenderText() method, simply render it as Unicode (which it appears FreeType supports).

And... voilà ?

One possible stumbling block might be that perhaps AGS can't deal with (as in: store and correctly transmit) the UTF text. If so, I might have to also implement IAGSEngine, and set a RequestEventHook() for AGSE_TRANSLATETEXT to intercept the translation process. I'd then just pass back some kind of identifier to AGS, and then look it up again when it was time to render the text.

The plugin would also need to offer a replacement method for DrawingSurface.DrawString(). I'm not yet clear on how it would affect word parsing or script string comparisons (because I'm not clear on how it works with translations in general). A possible further extension would be an option to intercept keyboard input so you could get user-input text in Unicode as well, but that seems like a v2.0 feature.

SMF spam blocked by CleanTalk