|
发表于 2019-3-13 21:52:11
|
显示全部楼层
//中文字体设置
osg::ref_ptr<osgText::Font> font = osgText::readFontFile("Fonts/msyh.ttc");
//2. 设置标题
LabelControl* title = new LabelControl("ViewPoint", 14, osg::Vec4f(1, 1, 0, 1));
title->setEncoding(osgText::String::ENCODING_UTF8);
title->setFont(font.get());
title->setText(unicodeToUTF8(L"信息"));
3. 转换函数
string unicodeToUTF8(const wstring &src)
{
string result = "";
int n = WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, 0, 0, 0, 0);
result.resize(n);
::WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, (char*)result.c_str(), (int)result.length(), 0, 0);
return result;
}
4. 哦啦.
|
|