Special font characters for GUI

Started by daneeca, Sun 16/10/2016 23:04:17

Previous topic - Next topic

daneeca

Hi guys!
I hope it's a beginner question. So I'm working on a game with Hungarian subtitle. And the Hungarian alphabet contains some double accented letters. These: Ö,Š,Ü,Š°. I use a truetype font and everything is working fine, except in GUIs. In the GUIs the little "Š‘" letter turns into the big "Q". I don't know what is the problem, because the font contains this letter. How can I fix this?

Monsieur OUXX

I don't know the real answer but my instinct tells me that the GUIs mishandle something (the characters codes?)  because of sominternal limitations in the engine. Like, characters being stored on 2 bytes instead of 4 or something. It's not visible in the Editor because it's based on .Net, but then it's visible in-game because Allegro fucks up, still because of these hard-coded AGS limitations. It's also not visible for English games or French/German/Western Eirope special characters because they're "closer" to plain ASCII in terms of character codes?

This is all just speculation.
 

Scavenger

#2
That's really weird, those double accented characters shouldn't be rendered at all, because they're above 256. That it's rendering characters outside out that range for dialogue is... quite honestly astounding. The way your font is formatted, Š‘ is character number 337. AGS is probably putting that number back within the 0-255 range it can render, leading to:

337%256 = 81. The ascii code for capital Q. AGS holds 1 byte of memory for each character, no more. You could probably reencode your TTF font to use Windows-1250 (it contains the hungarian characters you seek), but that might make writing text in AGS really difficult, because I'm not sure if there's anyway to change the encoding format of the script editor and stuff.

m0ds

#3
You may need to re-encode your TRS (translation script) file from UTF8 to WindowsCryllic [make a backup of your UTF8 version just in case first!!], so that AGS can read the appropriate part of the TTF font file. Your TRS [translated lines] may appear "gibberish" after the conversion, this is normal. As scavenger says it's out of range, I don't know the full workings inside the engine, but converting the TRS should put it "back in range" or such. Luckily if you're using a TTF then no changes need to be made to the font itself. Typically, just making sure the TRS file is in the right format (to correctly align with the TTF). Google search "charco.exe" for a thing that converts UTF8 (or whatever) to WindowsCyrllic (or whatever is appropriate for Hungarian) :) I've had mixed results (usually terrible) with online converters, but charco does it right every time.

Here is how I would do, Russian for example:

Import a TTF font to AGS that supports Russian
Use charco to turn the translators UTF8 (in which normal Russian texts can be seen) TRS file into a WindowsCryllic copy.
The TRS then all looks gibberish in the translated lines.
Paste back in game folder and Compile in translation AGS menu. Make sure the appropriate font is called/loaded at start of game (advise not encouraging using the winsetup selector, do language & font changes in-game).
Start a new game (you typically can't load games to see changes with languages, unless you put in some code to check & change things on load/repeatedly).

This also applies to some European languages. Have to find a TTF font that supports it, then convert it from UTF8 over to WindowsCryllic (I think, I know Cryllic is for Russian, I can't remember if some Euro languages use another). Often, a TTF already has a lot of symbols in it, and no conversion from UTF8 is needed. But some absolutely will require it (a particular font) and a particular conversion. Anyway, as long as you use one that is designed in full for the language(s) you intend, it's simply a matter of getting AGS to read it correctly, which is where charco.exe saves the day!

With Tales, we've just done it a different way because we use an SCI font, this involved 'tricking' the TRS to find a particular number of a character, like to use the 245th character, had to put a / in TRS, cos in the edited font, /'s number would represent é character or whatnot. AprilSkies can explain this method nicely. But don't worry if that doesn't make sense, when you're using a TTF font it's irrelevant I think, so long as your font has all the correct characters for your language (and you know it does)...!

daneeca

The point is that it's not a translation. Hungarian is the basic language in the game. So I can't edit the TRS file.

I opened the font in a font editor and these are the properties. Can I somehow put it into the range 0-255? I'm not the expert on this :-\

Scavenger

Doing it natively is gonna be a pain, yeah. I think AGS has a way to export all your strings and reimport them after editing, though.

In order to change a font from UTF-8/Unicode to something AGS would be able to display:

1) Download Fontforge.
2) Download and extract this encoding file. You should end up with "Encoding.ps". 7zip should be able to open .gz files.
3) Open your font in Fontforge (make sure to back it up first)
4) Encoding-->Load Encoding, choose Encoding.ps.
5) Encoding-->Reencode-->Windows-1250
6) Save your font.

You should now have a font with all the Hungarian characters within 0-255. Getting it to appear correct in AGS is another thing, you'll need to reencode every string to Windows-1250 as well. I'm sure there'd be a way to do it automatically using the Translation feature (by copying every line down to the blank line below it, reencoding the TRS file and then importing it as the default language, it should be something possible for someone who knows how to program text stuff to do it very trivially). If the AGS editor had codepage support for text input this would be a lot easier, having UTF-8/Unicode for the editor and 8-bit encoding for the engine has caused no end of strife.

Crimson Wizard

#6
Quote from: Scavenger on Fri 21/10/2016 13:25:59Getting it to appear correct in AGS is another thing, you'll need to reencode every string to Windows-1250 as well. I'm sure there'd be a way to do it automatically using the Translation feature (by copying every line down to the blank line below it, reencoding the TRS file and then importing it as the default language, it should be something possible for someone who knows how to program text stuff to do it very trivially). If the AGS editor had codepage support for text input this would be a lot easier

I think it supports what Windows supports, in the sense that if you switch to native codepage (same codepage your font complies to) with Windows language switcher you can type your native letters in the script editor and they will appear and save properly in 1-byte text format.
At least if I remember correctly I was able to do so with russian language (Windows-1251 code page).
I may be mistaken though, because that was pretty long ago, but it may be worth a try.


Danvzare

May I make a suggestion.
Why not edit the font, and replace the generally unused symbols such as {,},[,] with Ö,Š,Ü,Š°.
Then just use {,},[,] when writing your text. It's a nice and simple work around, and is pretty much what I would do in your position.

daneeca

I downloaded Fontforge and opened the font. I loaded the encoding file, but I can't find Windows-1250 in the list. I tried to do it with ISO 8859-2 because I read on wikipedia it's similar. And then I made a new font file this way: File/Generate Fonts. Unfortunately it didn't work. The little Š‘ is still Q in GUIs. I reopened the new font file into Fontforge, and I noticed, everything is the same as before encoding. Is it normal?

SMF spam blocked by CleanTalk