首先將帶有中文的字符串轉換成stringide
void 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(), result.length(), 0, 0 );
}字體
osgEarth::Style style;
osgEarth::Symbology::TextSymbol *textStyle=style.getOrCreateSymbol();
textStyle->font()="simsun.ttc";//必定要制定一種中文字體,不然即便w2s成功了也沒法顯示中文
textStyle->size()=30.0;
textStyle->encoding()=osgEarth::Symbology::TextSymbol::ENCODING_UTF8;spa