Hi,
I wanna known how in Allegro 4.9.21 can I write characters like áçñÑè among others. Using .TTF (TrueTypeFonts)
I used to use set_uformat(U_ASCII) in Allegro 4.2 but I cannot found an equivalent here.
Thanks in advance.
Marce.
You can input them as UTF-8 characters. See the ex_font example.
I wanna known how in Allegro 4.9.21 can I write characters like áçñÑè among others.
Allegro 5's new string api uses utf8. So you can generally just use utf8 anywhere and it ought to work. Though I think things will work more reliably if you use the _ustr functions when you have the option, rather than the functions that take plain char*. like al_draw_ustr rather than al_draw_text.
Thanks, but where should I look up those examples ?
In the example/ directory that comes with Allegro.
Example of ex_font doesn't helps me because I have to use TrueTypeFont.
I also tried with utf8 but no extended characters appears.
In both cases, print function works until first extended characters is found.
In the attachment the resulting file.
Here the code:
Any idea ?
Thanks, Marce.
In your editor, make sure the file is encoded as UTF8.
Yes, my editor was set to Auto-dectect UTF8.
Still not working...
Does ex_ttf work?
Make sure your font contains that particular character.
I've never done unicode in C/C++, but I've seen L"some unicode string" before... Try that?
That's the syntax for a wide character strings, which is too ambigous to be usable in portable programs. Allegro only accepts UTF-8 encoded strings.
When you source code is in UTF-8 every string you put in will work with Allegro. UCS-2 (L"" syntax) is supported in modern compilers, but usually there are not standard libraries which allow to convert between UCS-2 and UTF-8. Allegro have handy routines to deal with such conversion, look at al_utf8_width() and al_utf8_encode().
In case, when you want full Unicode support you need to use native system routines or external library.
Finally the problem was the encode of the main.pp file.
example ex_ttf.c works fine.
Eventhought UTF-8 was in auto-detect mode (Visual Studio 2010 express), each file has to be save as unicode-UTF8.
Save File AS -> Save with encoding -> Unicode (UTF-8 widthout signature) - Codepage 65001
Nota: I have to save to another encode, save, close (IDE), open and then set the correct codepage.
Thanks All !!!!
Marce.