Alfont characters
CursedTyrant

It might be stupid, and it probably is, but is there any way I can get regional characters (ie. Polish "ą", "ę") working with alfont? All I get is a bunch of weird symbols.

BAF

Are you using a font with the characters in it?

Jakub Wasilewski

If the answer to BAF's question is 'yes', try setting the Allegro unicode mode to... can't remember the const, I believe it's U_ASCII.

EDIT:
I just looked at the manual... set_uformat(U_ASCII) should help. Of course, this is only valid if this is a "Polish extended" font with the Polish chars in the #128-#255 range. If it's a unicode font, something else must be wrong.

miran

If you use a Polish font and U_ASCII, then you basically limit your output to English (standard 7bit ASCII) and Polish with a few other languages that use the same extended ASCII layout as Polish. The prefered way is to use Unicode (the default mode which is U_UTF8 should work just fine) with a Unicode font. But then all your strings must be written in UTF8. This can be a bit tedious if you hardcode your strings in C/C++ code, because you aren't supposed to encode C/C++ source files in UTF8, so you have to use escape sequences (or whatever they're called), like in the Allegro's Unicode example.

A better way is of course to write all your game strings in a separate UTF8 encoded text file, which you load in your game at start up. If you do this, it is also very easy to add support for other languages to your game. You just write a text file with strings for each language and load only one of them at runtime.

CursedTyrant

Yes, the font supports Polish characters.

string buffer;

...

if (keypressed())
{
  int scancode, c = ureadkey(&scancode);
  
  if (scancode!=KEY_BACKSPACE) { buffer += c; }
  else if (scancode==KEY_BACKSPACE && buffer.size()>0) { buffer.erase(buffer.size()-1, buffer.size()); }
}

I've tried both readkey() and ureadkey() and I get this when typing "ąęó":
590033

Matt Smith

Does your string class work with 32 (or 16) bit unicode? That's what ureadkey() returns.

set_uformat(U_UNICODE) is what you'll need to print these strings with text_printf() etc but I don't know how alfont determines its output encoding.

Thread #587224. Printed from Allegro.cc