首先确保将simsun.ttc文件拷贝到/usr/X11R6/lib/X11/fonts/truetype下。该文件可以直接从winodws的字体库文件中找到。
$graph->title->set($title)乱码解决
在此jpGraph默认支持gb2312编码,如果出现乱码肯定是$title的编码是utf-8。
修改方法:
$title = iconv("UTF-8", "gb2312", $title);
$graph->title->Set($title);
如果需要修改的地方比较多,而且你确信代码中基本都用的是utf-8编码,可以直接修改jpGraph源文件
方法:修改文件:src/jpgraph_ttf.inc.php
elseif( $aFF === FF_SIMSUN ) {
//('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
将这里直接改为
elseif( $aFF === FF_SIMSUN ) {
SetLegend函数乱码解决
3、打开jpgraph.php文件,找到
private $font_family=FF_FONT1,$font_style=FS_NORMAL,$font_size=12;
用
private $font_family=FF_SIMSUN,$font_style=FS_NORMAL,$font_size=8;