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

Author Topic: Displaying non-ascii chars - sf::Font and sf::Text  (Read 2300 times)

0 Members and 1 Guest are viewing this topic.

chronotrigger21

  • Newbie
  • *
  • Posts: 2
    • View Profile
Displaying non-ascii chars - sf::Font and sf::Text
« on: April 14, 2016, 04:58:49 am »
I want to display non-Ascii characters. (specifically box-drawing characters for a roguelike game - my renderWindow will basically look like a console/terminal to the user; I'm just using SFML behind the scenes because it gives me so much more power)

But I just get boxes or question marks if I try to use a non-ascii character. I have spent hours upon hours poring over every scrap of documentation - sf::Font, sf::Text, Uint32, L"string", wstring, sf::string, ASCII codes, unicode strings... but all I seem to be accomplishing is exasperating myself.

All I want to do is draw some boxes with text! :)  Any advice pointing me in the right direction would be immensely appreciated.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Displaying non-ascii chars - sf::Font and sf::Text
« Reply #1 on: April 14, 2016, 06:22:35 am »
First make sure that the font that you use contains the glyph that you want to display. Then show us some code, so that we can find out what you did wrong ;)
Laurent Gomila - SFML developer

chronotrigger21

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Displaying non-ascii chars - sf::Font and sf::Text
« Reply #2 on: April 14, 2016, 03:19:40 pm »
Ah! Indeed it wasn't my code at all. The font I was trying to use did not contain those glyphs. I switched to Courier New for now, and all my box-drawing glyphs are showing up correctly.

I would really prefer to use a perfectly square font though... however I'm having a hard time finding one that contains all the box-drawing characters. It seems that most fonts I download only contain the Ascii characters and maybe a few special latin characters. Oh well!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Displaying non-ascii chars - sf::Font and sf::Text
« Reply #3 on: April 14, 2016, 10:22:31 pm »
my renderWindow will basically look like a console/terminal to the user
I think you may very well be interested in Console Screen (it's SFML-based). I created it for this sort of stuff (it can do other stuff too!). Since it uses square tiles from a texture, you could easily create and use your own fonts with it  :)
(click to show/hide)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*