Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Can't display infinity symbol

This thread is locked; no one can reply to it. rss feed Print
Can't display infinity symbol
Bingocat
Member #15,424
December 2013

I am just trying to display an infinity symbol for ammo in my game, but I can't get it to work. Can Allegro not display special characters like that? Here is one of the things I tried.

#SelectExpand
1string text = player.defaultWeaponNames[player.type] + ":"; 2text.push_back(char(236)); 3al_draw_filled_rectangle(cameraPos[0] + screenWidth / 2 - 100, cameraPos[1] + 5, cameraPos[0] + screenWidth / 2 + 100, cameraPos[1] + 25, al_map_rgb(255, 90, 0)); 4al_draw_rectangle(cameraPos[0] + screenWidth / 2 - 100, cameraPos[1] + 5, cameraPos[0] + screenWidth / 2 + 100, cameraPos[1] + 25, al_map_rgb(0, 0, 0), 2); 5al_draw_text(font18, al_map_rgb(255, 255, 255), cameraPos[0] + screenWidth / 2, cameraPos[1] + 5, ALLEGRO_ALIGN_CENTRE, text.c_str());

Thomas Fjellstrom
Member #476
June 2000
avatar

It can display non ASCII characters, but you need to use UTF-8 encoding and a font that has that character in it.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Bingocat
Member #15,424
December 2013

So would I have to do something with an ALLEGRO_USTR? Why can't it just display the character?

Elias
Member #358
May 2000

char(236) is -20, the range of char is -128 to 127 only. What you can do is this:

al_draw_text(..., "∞");

or

al_draw_text(..., "\u221e");

--
"Either help out or stop whining" - Evert

Go to: