1
General / display Chinese characters ???
« on: November 07, 2009, 04:28:56 am »
logo.h
logo.cpp
simkai.ttf is chinese font, mText1 and mText2 is chinese characters.
The above code is correct, if not correct please give me an example.
My English is not good[/code]
Code: [Select]
sf::Font mFont1;
sf::Font mFont2;
sf::String mText1;
sf::String mText2;
logo.cpp
Code: [Select]
void Logo::Init()
{
// load background Image
if (!mBgImage.LoadFromFile("Data\\gfx\\secondlife.png"))
{
// Error...
cout << "[!] Wasn't able to load the secondlife.png File" << endl;
}
// link background image to sprite
mBgSprite.SetImage(mBgImage);
mBgSprite.SetPosition((WINWIDTH-mBgImage.GetWidth())/2,(WINHEIGHT-mBgImage.GetHeight())/2);
if(!mFont1.LoadFromFile("Data\\fonts\\simkai.ttf",30,L" SecondLife Present"))
{
cout << "[!] Wasn't able to load the simkai.ttf File" << endl;
}
if(!mFont2.LoadFromFile("Data\\fonts\\simkai.ttf",30,L"第二人生游戏开发俱乐部发行"))
{
cout << "[!] Wasn't able to load the simkai.ttf File" << endl;
}
int start = (WINHEIGHT - mBgImage.GetHeight()) / 2 + mBgImage.GetHeight() + 1;
mText1.SetFont(mFont1);
mText1.SetText(L" SecondLife Present");
mText1.SetSize(18);
mText1.SetPosition(WINHEIGHT/2,start+16);
mText1.SetColor(sf::Color(0,255,0));
mText2.SetFont(mFont2);
mText2.SetText(L"第二人生游戏开发俱乐部发行");
mText2.SetSize(18);
mText2.SetPosition(WINHEIGHT/2,start+48);
mText2.SetColor(sf::Color(0,255,0));
mClock.Reset();
}
simkai.ttf is chinese font, mText1 and mText2 is chinese characters.
Code: [Select]
void Logo::Draw(sf::RenderWindow &Window)
{
Window.Clear();
Window.Draw(mBgSprite);
Window.Draw(mText1);
Window.Draw(mText2);
if( i < 20 )
i = 0;
else
i -= 10;
Window.Draw(sf::Shape::Rectangle(0, 0, WINWIDTH, WINHEIGHT, sf::Color(0,0,0,i)));
Window.Display();
}
The above code is correct, if not correct please give me an example.
My English is not good[/code]