[rt-users] Bug in Chart fonts handling

Emmanuel Lacour elacour at easter-eggs.com
Wed Oct 10 11:47:25 EDT 2007


I played with chart module and found that the fonts settings are
incorrect.

In share/html/Search/Chart, the only font setting is made by set_legend_font, but there
is no legends on graphs so ... not very usefull.

Instead it would be better to use one or every of the followings:

For bars:

set_x_label_font
set_y_label_font
set_x_axis_font
set_y_axis_font
set_values_font

For pies:

set_label_font
set_value_font


Also it's often needed to specify the font path, here is a tested
example:

use GD::Text;
GD::Text->font_path("/usr/share/fonts/truetype/ttf-bitstream-vera");

And of course, if those settings can be customized in RT_SiteConfig.pm,
it would be very nice ;)

That's my two cents...


Here is my current diff (RT 3.6.3), also replacing the default non-free (verdana) by free fonts from bitstream:

--- ./share/html/Search/Chart	2007-10-10 17:41:24.000000000 +0200
+++ ./local/html/Search/Chart	2007-10-10 17:46:00.000000000 +0200
@@ -10,6 +10,7 @@
 my $chart_class;
 use GD;
 use GD::Text;
+GD::Text->font_path("/usr/share/fonts/truetype/ttf-bitstream-vera");
 
 if ($ChartStyle eq 'pie') {
     require GD::Graph::pie;
@@ -34,7 +35,15 @@
         y_label => 'Tickets',
         show_values => 1
     );
-    $chart->set_legend_font( ['verdana', 'arial', gdMediumBoldFont], 12);
+    $chart->set_legend_font( ['VeraBd', 'verdana', 'arial', gdMediumBoldFont], 12);
+    $chart->set_x_label_font( ['VeraBd', 'verdana', 'arial', gdMediumBoldFont], 12);
+    $chart->set_y_label_font( ['VeraBd', 'verdana', 'arial', gdMediumBoldFont], 12);
+    $chart->set_x_axis_font( ['Vera', 'verdana', 'arial', gdMediumBoldFont], 10);
+    $chart->set_y_axis_font( ['Vera', 'verdana', 'arial', gdMediumBoldFont], 10);
+    $chart->set_values_font( ['Vera', 'verdana', 'arial', gdMediumBoldFont], 10);
+} elsif ($chart_class eq "GD::Graph::pie") {
+    $chart->set_label_font( ['VeraBd', 'verdana', 'arial', gdMediumBoldFont], 12);
+    $chart->set_value_font( ['Vera', 'verdana', 'arial', gdMediumBoldFont], 10);
 }
 
 my %class = (




More information about the rt-users mailing list