SFML community forums

Help => Graphics => Topic started by: Scipi on December 01, 2011, 04:39:28 am

Title: Need help with '∞' symbol
Post by: Scipi on December 01, 2011, 04:39:28 am
Hello,

I am trying to display the infinity symbol for a game I am making.

The code I use to get it is:

Code: [Select]

AmmoText = sf::String(sf::Unicode::Text(L"\u221E"), sf::Font::GetDefaultFont(), 10.f);


But nothing shows up for it.

How can I make it so that '∞' will be outputted?

Thanks
Title: Need help with '∞' symbol
Post by: Laurent on December 01, 2011, 07:33:12 am
The font that you use must contain this symbol. The default font is Arial, loaded with the Latin-1 characters set. So it does not have the infinity symbol.
Title: Need help with '∞' symbol
Post by: Scipi on December 01, 2011, 03:26:01 pm
Ok, I see. What font can I use that includes the symbol?
Title: Need help with '∞' symbol
Post by: Laurent on December 01, 2011, 03:40:33 pm
Maybe Arial includes it, but the SFML default font doesn't load it.

So first you must load your own font, passing it a characters set that contains your symbol. Once it works, you can find a font which works with that. Maybe Arial does it, it has a lot of Unicode symbols. You can check with the "characters table" if you're under Windows.
Title: Need help with '∞' symbol
Post by: Scipi on December 01, 2011, 04:40:47 pm
I checked and Arial does seem to include it. However it's still not showing up.

Here's the code I have now:

Code: [Select]

    sf::Font Font;
    sf::Uint32 CharSet[] = {0x221E,0x0};
    Font.LoadFromFile("arial.ttf", 30, CharSet);

...

    AmmoText = sf::String(sf::Unicode::Text(L"\u221E"), Font, 10.f);
Title: Need help with '∞' symbol
Post by: Scipi on December 03, 2011, 06:39:15 pm
Sorry for the double post, but when I use the code above I get this message in the console:

Code: [Select]

     Failed to load font "arial.ttf" (Cannot open Resource"


It only occurs when I pass the character set to the font.

How do I fix this? Thanks :D
Title: Need help with '∞' symbol
Post by: Laurent on December 03, 2011, 11:09:44 pm
So maybe it doesn't have this symbol.