2011年11月30日水曜日

MantisGraphの文字フォント

mantisでのグラフ表示
mantisのグラフ系の処理がjpgraphを別途インストールしないとグラフが表示できなかったが、mantisbt-1.2.8ではMantisGraphとしてPlugin化されているようだ。
このMantisGraphを使ったグラフではそのままでは日本語フォントが設定されていないために日本語が化けてしまう。

Ubuntu12.04でデフォルトで使えるTakaoフォントを使用
日本語のフォントを設定してグラフに日本語を表示できるようにする。

ubuntu12.04ではTakaoフォントの位置が
/usr/share/fonts/truetype/ttf-japanaese-gothic.ttf
→/etc/alternatives/ttf-japanese-gothic.ttf
これらはシンボリックリンクとなっていて
実体は
/usr/share/fonts/truetype/takeo-gothic/TakaoPGothic.ttf
を参照しているがそこにはフォントファイルが存在せず。
/usr/share/fonts/truetype/takeo/TakaoPGothic.ttf
にあるのでシンボリックリンクを修正。
/etc/alternatives$ sudo ln -s /usr/share/fonts/truetype/takao-gothic/TakaoPGothic.ttf ttf-japanese-gothic.ttf

mantisbt-1.2.11/plugins/MantisGraph/MantisGraph.php
config()の'font'識別子に"JAPAN"を追加 識別子なので何でも良い。
      function config() {
                return array(
                        'eczlibrary' => ON,

                        'window_width' => 800,
                        'bar_aspect' => 0.9,
                        'summary_graphs_per_row' => 2,
                        'font' => 'JAPAN',

                        'jpgraph_path' => '',
                        'jpgraph_antialias' => ON,
                );
        }

graph_api.php フォント設定に日本語の設定を追加

上記のフォント識別子('JAPAN')に対するフォント名を指定する。
$f_font_map = array( に'JAPAN' => 'ttf-japanaese-gothic.ttf' を追加