但是如果仔細查看mantisGraph的配置會發(fā)現(xiàn)實際上可以配置使用的字體文件是什么字體,目前支持配置Sans-serif、Serif、Monospace等字體。修改該配置后,卻發(fā)現(xiàn)不生效。進一步仔細研究mantisGraph的代碼,發(fā)現(xiàn)了以下代碼(于文件core/graph_api.php中):
function graph_get_font() {
$t_font = plugin_config_get( ‘font’, ” );
if ( plugin_config_get( ‘eczlibrary’ ) == ON ) {
$ttf_dir = ”;
$t_font = ”;
$t_font_map = array(
‘arial’ => ‘arial.ttf’,
‘verdana’ => ‘verdana.ttf’,
‘trebuchet’ => ‘trebuc.ttf’,
‘verasans’ => ‘Vera.ttf’,
‘times’ => ‘times.ttf’,
‘georgia’ => ‘georgia.ttf’,
‘veraserif’ => ‘VeraSe.ttf’,
‘courier’ => ‘cour.ttf’,
‘veramono’ => ‘VeraMono.ttf’,
);
if( isset( $t_font_map[$t_font] ) ) {
$t_font = $t_font_map[$t_font];
} else {
$t_font = ‘arial.ttf’;
}
其中$t_font = ”;這行代碼是的配置信息在這兒被重置,于是后的將會執(zhí)行$t_font = ‘arial.ttf’;這行代碼。所以無論如何修改配置都不生效。
為了使得配置能生效,則注釋掉$t_font = ”;這行。同時新增一個t_font_map的數(shù)據(jù)項, ’wqy-zenhei’ => ‘wqy-zenhei.ttf’,接下來修改配置界面使得可以在界面上看到wqy-zenhei的配置。打開文件pages/config.php。變動如下:
diff -uNr mantisbt-1.2.2/plugins/MantisGraph/pages/config.php mantisbt-1.2.2.new/plugins/MantisGraph/pages/config.php
— mantisbt-1.2.2/plugins/MantisGraph/pages/config.php 2010-07-30 00:46:31.000000000 +0800
+++ mantisbt-1.2.2.new/plugins/MantisGraph/pages/config.php 2010-08-11 11:35:55.000000000 +0800
@@ -22,6 +22,7 @@
print_manage_menu( );
$t_current_font_selected = array(
+ ‘wqy-zenhei’ => false,
‘arial’ => false,
‘verdana’ => false,
‘trebuchet’ => false,
@@ -118,6 +119,7 @@
</td>
<td style=”vertical-align: top”>
Sans-serif:<br />
+ <label><input type=”radio” name=”font” value=”wqy-zenhei”<?php echo print_font_checked( ‘wqy-zenhei’ )?>/>WenQuanYi ZenHei</label><br />
<label><input type=”radio” name=”font” value=”arial”<?php echo print_font_checked( ‘arial’ )?>/>Arial</label><br />
<label><input type=”radio” name=”font” value=”verdana”<?php echo print_font_checked( ‘verdana’ )?>/>Verdana</label><br />
<label><input type=”radio” name=”font” value=”trebuchet”<?php echo print_font_checked( ‘trebuchet’ )?>/>Trebuchet</label><br />
打開文件pages/config_edit.php,變動如下:
diff -uNr mantisbt-1.2.2/plugins/MantisGraph/pages/config_edit.php mantisbt-1.2.2.new/plugins/MantisGraph/pages/config_edit.php
— mantisbt-1.2.2/plugins/MantisGraph/pages/config_edit.php 2010-07-30 00:46:31.000000000 +0800
+++ mantisbt-1.2.2.new/plugins/MantisGraph/pages/config_edit.php 2010-08-11 11:36:15.000000000 +0800
@@ -46,6 +46,7 @@
if ( plugin_config_get( ‘font’ ) != $f_font ) {
switch ( $f_font ) {
+ case ‘wqy-zenhei’:
case ‘arial’:
case ‘verdana’:
case ‘trebuchet’:
這樣可以在mantis的配置界面中看到相應的配置了。當然好是進一步修改文件實現(xiàn)搜索字體文件的功能,將搜索到的字體文件提供給用戶選擇。