SFML community forums

Help => Graphics => Topic started by: chronotrigger21 on April 14, 2016, 04:58:49 am

Title: Displaying non-ascii chars - sf::Font and sf::Text
Post by: chronotrigger21 on April 14, 2016, 04:58:49 am
I want to display non-Ascii characters. (specifically box-drawing characters (https://en.wikipedia.org/wiki/Box-drawing_character) 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.
Title: Re: Displaying non-ascii chars - sf::Font and sf::Text
Post by: Laurent 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 ;)
Title: Re: Displaying non-ascii chars - sf::Font and sf::Text
Post by: chronotrigger21 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!
Title: Re: Displaying non-ascii chars - sf::Font and sf::Text
Post by: Hapax 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 (https://github.com/Hapaxia/SelbaWard/wiki/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)