当前位置:首页 > 网络编程 > WEB编程 > PHP > jpgraph图形类库中文乱码解决

jpgraph图形类库中文乱码解决

点击次数:29 次 发布日期:2008-12-24 11:44:57 作者:源代码网
源代码网推荐

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

本文作者:未知
源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华