最近查了一堆词条,总算在一个大佬的博客中找到了解决方法,这里面有一个前提,要使osg、osgearth支持中文,必须要有 freetype,所以在编译它们前,先编译好 freetype。并且在编译osg时,使用freetype库。
加载矢量数据
<model driver="feature_geom">
<features name="china_text" driver="ogr">
<url>maps/shp/tianjin/xian.shp</url>
</features>
<layout>
<tile_size>10000</tile_size>
<level name="xian_text" min_range = "0" max_range="150000"/>
</layout>
<styles>
<style type="text/css">
xian_text {
altitude-clamping:terrain;
altitude-offset:1;
icon:"/images/marker.png";
icon-align:center-center;
icon-declutter:true;
icon-scale:1;
icon-heading:0;
text-fill: #ffffff;
text-content:[Name];
text-size:16;
text-encoding: utf-8;
render-lighting:false;
text-align: center-center;
text-font:"font/msyh.ttc";
}
</style>
</styles>
</model>
添加环境变量
OSGEARTH_DEFAULT_FONT=simsun.ttc
最终效果如下
特别感谢 kl222