Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Alfont characters

This thread is locked; no one can reply to it. rss feed Print
Alfont characters
CursedTyrant
Member #7,080
April 2006
avatar

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.

---------
Signature.
----
[My Website] | [My YouTube Channel]

BAF
Member #2,981
December 2002
avatar

Are you using a font with the characters in it?

Jakub Wasilewski
Member #3,653
June 2003
avatar

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.

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

miran
Member #2,407
June 2002

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.

--
sig used to be here

CursedTyrant
Member #7,080
April 2006
avatar

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

---------
Signature.
----
[My Website] | [My YouTube Channel]

Matt Smith
Member #783
November 2000

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.

Go to: