yuwen_1990 发表于 2014-7-25 12:47:47

osgEarth2.5中文支持 如何解决


重载了源码AnnotationUtils.cpp中
osg::Drawable*
        AnnotationUtils::createTextDrawable(const std::wstring& text,
        const TextSymbol*symbol,
        const osg::Vec3&   positionOffset )
然后又重载了PlaceNode.cpp中
PlaceNode::PlaceNode(MapNode*         mapNode,
        const GeoPoint&    position,
        osg::Image*      image,
        const std::wstring& text,
        const Style&       style ) :

OrthoNode( mapNode, position ),
        _image   ( image ),
        _wtext   ( text ),
        _style   ( style ),
        _geode   ( 0L )
{
        initw();
}

在加载中文地标的时候,出现的还是乱码,如何解决
osgEarth::Annotation::PlaceNode *pn = new osgEarth::Annotation::PlaceNode(mapNode, mappnt,tempImg,"中国",/*strName.GetBuffer(0),*/ style);

cug_osg 发表于 2014-7-25 22:57:55

其实完全不需要这么麻烦。
字体设置为中文字体(譬如:simhei.ttf);并且设置字符编码为:ENCODING_UTF8;传入的字体只需要utf8即可
(如:osgDB::convertStringFromCurrentCodePageToUTF8("中文字体"))

friendbaby 发表于 2014-7-27 12:16:33

楼上的方法完全正确。
不建议修改源码

hitcms 发表于 2015-3-4 09:05:17

cug_osg 发表于 2014-7-25 22:57
其实完全不需要这么麻烦。
字体设置为中文字体(譬如:simhei.ttf);并且设置字符编码为:ENCODING_UTF8; ...

能说的详细些吗?在线等,急求,
我的问题是:
        中文无法显示
        如想 显示“aa啊啊bb”,最终的结果是“aabb”

OSG_wy 发表于 2015-3-4 10:50:38

cug_osg 发表于 2014-7-25 22:57
其实完全不需要这么麻烦。
字体设置为中文字体(譬如:simhei.ttf);并且设置字符编码为:ENCODING_UTF8; ...

遇到同样的问题,可以提供一个示例程序吗?
页: [1]
查看完整版本: osgEarth2.5中文支持 如何解决