View Issue Details

IDProjectCategoryView StatusLast Update
0013879mantisbtreportspublic2016-07-19 04:19
ReporterTomasC Assigned Tovboctor  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Versiongit trunk 
Target Version2.0.0-beta.1Fixed in Version2.0.0-beta.1 
Summary0013879: Graph plugin uses hard coded font list; ignores any other
Description

The Graph plugin contains a hard coded list of fonts. Despite any (plugin) configuration setting you make, the code does not allow any other font to be specified. Since these are mostly Windows fonts and most Linux servers don't have these pre-installed, it would probably be better to allow the user to specify the font themselves or select one from a list obtained from the system (ls get_font_path()?).

This would also mean the dependency of the Mantis Graph plugin on the corefonts/msfonts package can be dropped.

Steps To Reproduce
  1. Install Mantis without any of the hard coded fonts on your system
  2. Graphs won't work, regardless of any configuration.
Additional Information

Attached patch (works on 1.2.8 and current Git trunk) simply removes the mapping as a proof of concept. You still need to set the font configuration option to a font existing on your system (ls /usr/share/fonts/truetype), for example "DejaVuSans.ttf".

In the Graph plugin, in core/graph_api.php, in function graph_get_font():
[...]
$t_font = plugin_config_get( 'font', 'arial' );
[...]
$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' => 'impact.ttf',
'veramono' => 'VeraMono.ttf',
);

if( isset( $t_font_map[$t_font] ) ) {
$t_font = $t_font_map[$t_font];
} else {
$t_font = 'arial.ttf';
}

TagsNo tags attached.

Relationships

related to 0010589 closeddhx font and other implements for jpgraph 

Activities

TomasC

TomasC

2012-02-09 12:50

reporter  

mantis_graph_font_unhardcode.patch (458 bytes)   
57,73d56
< 		$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';
< 		}
TomasC

TomasC

2012-02-09 13:03

reporter  

mantis_graph_font_config_unhardcode.patch (1,420 bytes)   
119,133c119,120
< 	<td style="vertical-align: top">
< 		Sans-serif:<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 />
< 		<label><input type="radio" name="font" value="verasans"<?php echo print_font_checked( 'verasans' )?>/>Vera Sans</label>
< 	</td>
< 	<td style="vertical-align: top">
< 		Serif:<br />
< 		<label><input type="radio" name="font" value="times"<?php echo print_font_checked( 'times' )?>/>Times</label><br />
< 		<label><input type="radio" name="font" value="georgia"<?php echo print_font_checked( 'georgia' )?>/>Georgia</label><br />
< 		<label><input type="radio" name="font" value="veraserif"<?php echo print_font_checked( 'veraserif' )?>/>Vera Serif</label><br />
< 		<br />Monospace:<br />
< 		<label><input type="radio" name="font" value="courier"<?php echo print_font_checked( 'courier' )?>/>Courier</label><br />
< 		<label><input type="radio" name="font" value="veramono"<?php echo print_font_checked( 'veramono' )?>/>Vera Mono</label>
---
> 	<td class="center" colspan="2">
> 		<input type="text" name="font" value="<?php echo plugin_config_get( 'font' )?>" />
TomasC

TomasC

2012-02-09 13:03

reporter  

mantis_graph_font_configedit_unhardcode.patch (376 bytes)   
48,62c48
< 	switch ( $f_font ) {
< 		case 'arial':
< 		case 'verdana':
< 		case 'trebuchet':
< 		case 'verasans':
< 		case 'times':
< 		case 'georgia':
< 		case 'veraserif':
< 		case 'courier':
< 		case 'veramono':
< 			plugin_config_set( 'font', $f_font );
< 			break;
< 		default:
< 			plugin_config_set( 'font', 'arial' );
< 	}
---
> 	plugin_config_set( 'font', $f_font );
TomasC

TomasC

2012-02-09 13:05

reporter   ~0031210

Last edited: 2012-02-09 13:05

added patch removing the hardcoded option validation from the plugin configuration saving (pages/config_edit.php)

added patch replacing the hardcoded options of the plugin configuration page (pages/config.php) with a text field