茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1729107 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00027.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2011/11/29 7:47:40
  1. 測試 GD 的中文支援性

    1. 確定 PHP、GD中文運作正常
      Header( "Content-type: image/gif" );
      $im = imagecreate( 400, 150 );
      $black = ImageColorAllocate( $im, 0, 0, 0 );
      $white = ImageColorAllocate( $im, 255, 255, 255 );
      $fnt = "/usr/share/fonts/corefonts/fireflysung.ttf";
      $str = iconv("BIG5","UTF-8","中文");
      ImageTTFText($im, 30, 0, 50,50, $white, $fnt, $str);
      ImageGif($im);
      ImageDestroy($im);
      ?>

      如果這裡沒問題,代表 PHP、GD 沒問題了~


  2. jpgraph

    1. 更新 dotproject/lib/jpgraph
      到官方網站更新至新版:
      http://www.aditus.nu/jpgraph/
    2. 修改 jpg-config.inc.php 設定,加入中文字型
      1. 加入 DEFINE("TTF_DIR"," /usr/share/fonts/corefonts/");
      2. DEFINE('CHINESE_TTF_FONT','bkai00mp.ttf');
        改為 DEFINE('CHINESE_TTF_FONT',' fireflysung.ttf');
    3. 修改 jpgraph.php

      1. 取消內建的 UTF-8 轉碼

        由於本來就是使用UTF-8,所以要把內部的自動轉換關閉。
        搜尋「iconv」,找到

        elseif( $aFF === FF_CHINESE ) {
        if( !function_exists('iconv') ) {
        JpGraphError::RaiseL(25006);
        //('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By de$
        }
        return iconv('BIG5','UTF-8',$aTxt);
        )

        修改為


        elseif( $aFF === FF_CHINESE ) {
        return $aTxt;
        }
      2. 修改字型對應

        找到

        FF_CHINESE => array(FS_NORMAL=>CHINESE_TTF_FONT, FS_BOLD=>'', FS_ITALIC=>'', FS_BOLDITALIC=>''),

        修改成

        FF_CHINESE => array(FS_NORMAL=>CHINESE_TTF_FONT, FS_BOLD=>CHINESE_TTF_FONT, FS_ITALIC=>CHINESE_TTF_FONT, FS_BOLDITALIC=>CHINESE_TTF_FONT ),

        如果要設定粗體、斜體為不同字型,要另外設定別的字型檔給 FS_BOLD、FS_ITALIC。

      3. 加入區域偵測

        應該是用來設定日期的格式的,原則上應該是要給正確的值給他,但是寫在這比較方便。
        找到 function Set($aLocale),在下方加入

        $query = "SELECT 'config_value' FROM 'config' WHERE 'config_name = host_locale'";
        $aLocale = mysql_query ($query);

    4. 測試設定:
      include ("../jpgraph.php");
      include ("../jpgraph_gantt.php");
      $bar1 = new GanttBar(0, iconv("BIG5","UTF8","中文 1"),"2001-12-21","2002-01-20");
      $bar1->SetCSIMTarget('#','Go back 1');
      $bar1->title->SetCSIMTarget('#','Go back 1 (title)');
      $bar1->title->SetFont( FF_CHINESE, FS_NORMAL, 8 );
      $bar2 = new GanttBar(1,"Activity 2","2002-01-03","2002-01-25");
      $bar2->SetCSIMTarget('#','Go back 2');
      $bar2->title->SetCSIMTarget('#','Go back 2 (title)');
      $graph = new GanttGraph(500);
      $graph->title->Set("Example with image map");
      $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
      $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
      $graph->scale->week->SetFont(FF_FONT1);
      $graph->Add(array($bar1,$bar2));
      // And stroke
      $graph->StrokeCSIM('ganttcsimex01.php');
      ?>

      如果這裡沒問題,應該代表 jpgraph 的設定沒問題。

  3. dotProject

    1. 修改 dotproject/modules/projects/gantt.php

      1. 取消內建的 UTF-8 轉碼

        由於本來就是使用UTF-8,所以要把內部的自動轉換關閉。

        找到

        if ( $locale_char_set=='utf-8' && function_exists("utf8_decode") ) {
        $name = strlen( utf8_decode($p["project_name"]) ) > 25 ? substr( utf8_decode($p["project_name"]), 0, 22 ).'...' : utf8_decode($p["project_name"]) ;
        } else {
        //while using charset different than UTF-8 we need not to use utf8_deocde
        $name = strlen( $p["project_name"] ) > 25 ? substr( $p["project_name"], 0, 22 ).'...' : $p["project_name"] ;
        }

        改成

        $name = strlen( $p["project_name"] ) > 25 ? substr( $p["project_name"], 0, 22 ).'...' : $p["project_name"] ;

      2. 修改字型設定

        1. 找到 //$graph->scale->actinfo->SetFont(FF_ARIAL);

          改為 $graph->scale->actinfo->SetFont(FF_CHINESE);
        2. 找到
          // Use TTF font if it exists
          // try commenting out the following two lines if gantt charts do not display
          if (is_file( TTF_DIR."arialbd.ttf" ))
          $graph->scale->tableTitle->SetFont(FF_ARIAL,FS_BOLD,12);

          修改為 $graph->scale->tableTitle->SetFont(FF_CHINESE,FS_BOLD,12);

        3. 找到

          $bar->title->SetCOlor('red');
          $graph->Add($bar);

          加入一行,變成

          $bar->title->SetCOlor('red');
          $bar->title->SetFont(FF_CHINESE,FS_BOLD,8);
          $graph->Add($bar);

        4. 找到 $bar->title->SetFont(FF_FONT1,FS_NORMAL,10);
          改為 $bar->title->SetFont(FF_CHINESE,FS_NORMAL,10);
        5. 找到
          $bar->caption = new TextProperty($caption);
          在之後加入 $bar->caption->SetFont(FF_CHINESE,FS_NORMAL,10);
        6. 找到 $graph->Add($bar2);
          共兩處,在前面加上 $bar2->title->SetFont(FF_CHINESE,FS_NORMAL,10);
        7. 找到 $graph->Add($bar3);
          在前面加上 $bar3->title->SetFont(FF_CHINESE,FS_NORMAL,10);
        8. 找到 $graph->Add($vline);
          在前面加上 $vline->title->SetFont(FF_CHINESE,FS_BOLD,8);

    2. 修改 dotproject/modules/tasks/gantt.php
      1. 取消內建的UTF-8轉碼

        由於本來就是使用UTF-8,所以要把內部的自動轉換關閉。

        找到


        if( $local_char_set==』 utf-8' && function_exists('utf8_decode') ) {
        $name = utf8_decode($name);
        }

        把這三行刪除。

      2. 修改字型設定:

        1. 找到
          if (is_file( TTF_DIR.'arialbd.ttf' )){
          $graph->scale->actinfo->SetFont(FF_ARIAL);
          }

          修改為 $graph->scale->actinfo->SetFont(FF_CHINESE);

        2. 找到
          // Use TTF font if it exists
          // try commenting out the following two lines if gantt charts do not display
          if (is_file( TTF_DIR.'arialbd.ttf' ))
          $graph->scale->tableTitle->SetFont(FF_ARIAL,FS_BOLD,12);

          修改為 $graph->scale->tableTitle->SetFont(FF_CHINESE,FS_BOLD,12);

        3. 找到 $graph->Add($bar);
          共兩處,在前面加上
          $bar->title->SetFont(FF_CHINESE,FS_NORMAL,10);
        4. 找到
          if (is_file( TTF_DIR.'arialbd.ttf' )) {
          $vline->title->SetFont(FF_ARIAL,FS_BOLD,10);
          }

          修改為 $vline->title->SetFont(FF_CHINESE,FS_BOLD,8);



雖然我是用在mantis,不過問題總算是解決了~~~原來是utf-8的問題。

原文出處:kaowoei的自爽地: dotProject 的甘特圖中文修改
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|