但是如果仔细查看mantisGraph的配置会发现实际上可以配置使用的字体文件是什么字体,目前支持配置Sans-serif、Serif、Monospace等字体。修改该配置后,却发现不生效。进一步仔细研究mantisGraph的代码,发现了以下代码(于文件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 = ”;这行代码是的配置信息在这儿被重置,于是后的将会执行$t_font = ‘arial.ttf’;这行代码。所以无论如何修改配置都不生效。
为了使得配置能生效,则注释掉$t_font = ”;这行。同时新增一个t_font_map的数据项, ’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的配置界面中看到相应的配置了。当然好是进一步修改文件实现搜索字体文件的功能,将搜索到的字体文件提供给用户选择。