SFML community forums
Help => Graphics => Topic started 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:
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
-
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.
-
Ok, I see. What font can I use that includes the symbol?
-
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.
-
I checked and Arial does seem to include it. However it's still not showing up.
Here's the code I have now:
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);
-
Sorry for the double post, but when I use the code above I get this message in the console:
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
-
So maybe it doesn't have this symbol.