SFML community forums

Help => Graphics => Topic started by: on February 04, 2012, 09:42:32 am

Title: Problem with sf::Font and cyrillic charset
Post by: on February 04, 2012, 09:42:32 am
Hello!
I use SFML 1.6 in my game, and when i draw russian letter, i saw strange ieroglyphs. I found threads on this forum, read it, but this don't help.

Code: [Select]
Font1.LoadFromFile("arial.ttf", 24,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя");

  String ControlString(Unicode::Text("Жми Р.\nPress P for play."),Font1,24);
 


Latin character draw normaly, but russian text stay as ieroglyphs.
And now i don't want use SFML2.0

Sorry my bad English.=)
Title: Re: Problem with sf::Font and cyrillic charset
Post by: on February 04, 2012, 03:22:19 pm
On SFML2 i have the same problem, because MinGW has only "C" locale.
Title: Problem with sf::Font and cyrillic charset
Post by: Laurent on February 04, 2012, 06:04:52 pm
Yes, it's probably an encoding issue. It should work if you provide the UTF-32 values of your characters directly ("\uXXX" with XXX the hexadecimal Unicode codepoint of the character). Maybe a wide string would be enough (L"blahblah").
Title: Problem with sf::Font and cyrillic charset
Post by: on February 05, 2012, 07:54:57 pm
Thanks for help!
When i trying to use wstring, compiller return error"Illegal byte sequence". And \u sequence didn't help.
Title: Problem with sf::Font and cyrillic charset
Post by: Laurent on February 05, 2012, 09:03:02 pm
Quote
When i trying to use wstring, compiller return error"Illegal byte sequence"

Show your code ;)

Quote
And \u sequence didn't help

Show your code ;)
Title: Problem with sf::Font and cyrillic charset
Post by: on February 05, 2012, 09:13:01 pm
I set editor encoding to UTF8, and wstring now working.
 
Code: [Select]
Font Font1;
   wstring str=L"абв!";
  Font1.LoadFromFile("arial.ttf", 24,"\u0410\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437"); //some russian character
  String SFstr(str,Font1,24);
Title: Problem with sf::Font and cyrillic charset
Post by: on February 05, 2012, 09:14:36 pm
It's working!
Code: [Select]

   Font Font1;
   wstring str=L"Русский текст тут абв!";
  Font1.LoadFromFile("arial.ttf", 24,str);
  String SFstr(str,Font1,24);

Thank you very much!