Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Need help with '∞' symbol  (Read 3310 times)

0 Members and 1 Guest are viewing this topic.

Scipi

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Need help with '∞' symbol
« 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
I issa Cat Person =^w^=

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Need help with '∞' symbol
« Reply #1 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.
Laurent Gomila - SFML developer

Scipi

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Need help with '∞' symbol
« Reply #2 on: December 01, 2011, 03:26:01 pm »
Ok, I see. What font can I use that includes the symbol?
I issa Cat Person =^w^=

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Need help with '∞' symbol
« Reply #3 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.
Laurent Gomila - SFML developer

Scipi

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Need help with '∞' symbol
« Reply #4 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);
I issa Cat Person =^w^=

Scipi

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Need help with '∞' symbol
« Reply #5 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
I issa Cat Person =^w^=

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Need help with '∞' symbol
« Reply #6 on: December 03, 2011, 11:09:44 pm »
So maybe it doesn't have this symbol.
Laurent Gomila - SFML developer

 

anything