Hello, I've been trying to get Japanese characters to render in SFML 2 RC to no avail. I've used the font from
this thread so that I know the font is compatible.
Direct link for convenience.
The Japanese text comes up as question marks while English text displays normally. Sample code is below, thank you for reading:
#include <SFML/Graphics.hpp>
#include <SFML/System/Utf.hpp>
#include <iostream>
int main()
{
sf::Font font;
sf::String msg, hdr;
sf::Text text;
if(!font.loadFromFile("test.ttf"))
{
text.setString("Load failed");
hdr = "Warning!";
}
else
{
font.loadFromFile("test.ttf");
//char jp[2] = { '\u70B9','\u83DC' }; //error even worse here
//msg = jp;
msg = "こんにちはSMFL"; //tested this first, Japanese characters come up as "??????SMFL"
hdr = "こんにちはSMFL";
//Set up for potential conversion from different utf types
/*sf::Utf<8>::toUtf32(msg.begin(), msg.end(), msg.begin());
sf::Utf<8>::toUtf32(hdr.begin(), hdr.end(), hdr.begin());*/
text.setFont(font);
text.setString(msg);
}
sf::RenderWindow window(sf::VideoMode(300, 200), hdr);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
window.display();
}
return 0;
}