1、将windows字体文件(simhei.ttf,simsun.ttc等)复制到 /usr/X11R6/lib/X11/fonts/truetype/,如果目录不存在,则建立;
2、找到src/jpgraph.php文件,将FF_CHINESE部分屏蔽
/*
elseif( $aFF === FF_CHINESE ) {
if( !function_exists('iconv') ) {
JpGraphError::Raise('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).');
}
return iconv('BIG5','UTF-8',$aTxt);
*/
3、应用,以srcExamples的accbarex1.php为例
$graph->title->Set("Accumulated bar plots");
改为
$graph->title->Set("中文测试");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
改为
$graph->title->SetFont(FF_SIMSUN,FS_BOLD);
//如果有x或y轴,则用下面语句
$graph->legend->SetFont(FF_SIMSUN,FS_NORMAL);
运行程序,中文乱码问题OK