]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 287682: UTF-8 characters are incorrectly displayed in New Charts and graphical...
authorFrédéric Buclin <LpSolit@gmail.com>
Wed, 6 Nov 2013 14:08:45 +0000 (15:08 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Wed, 6 Nov 2013 14:08:45 +0000 (15:08 +0100)
r=wurblzap a=sgreen

Bugzilla/Config/Common.pm
Bugzilla/Config/DependencyGraph.pm
docs/en/xml/administration.xml
template/en/default/admin/params/dependencygraph.html.tmpl
template/en/default/reports/chart.png.tmpl
template/en/default/reports/report-bar.png.tmpl
template/en/default/reports/report-line.png.tmpl
template/en/default/reports/report-pie.png.tmpl

index 64c7ebcbb591c99877501bc2c5b18e8b62e4df9a..5872ae1e1cfe59b394549b7d78232a3261552e85 100644 (file)
@@ -24,7 +24,7 @@ use parent qw(Exporter);
     qw(check_multi check_numeric check_regexp check_url check_group
        check_sslbase check_priority check_severity check_platform
        check_opsys check_shadowdb check_urlbase check_webdotbase
-       check_user_verify_class check_ip
+       check_user_verify_class check_ip check_font_file
        check_mail_delivery_method check_notification check_utf8
        check_bug_status check_smtp_auth check_theschwartz_available
        check_maxattachmentsize check_email check_smtp_ssl
@@ -242,6 +242,20 @@ sub check_webdotbase {
     return "";
 }
 
+sub check_font_file {
+    my ($font) = @_;
+    $font = trim($font);
+    return '' unless $font;
+
+    if ($font !~ /\.ttf$/) {
+        return "The file must point to a TrueType font file (its extension must be .ttf)"
+    }
+    if (! -f $font) {
+        return "The file '$font' cannot be found. Make sure you typed the full path to the file"
+    }
+    return '';
+}
+
 sub check_user_verify_class {
     # doeditparams traverses the list of params, and for each one it checks,
     # then updates. This means that if one param checker wants to look at 
@@ -479,6 +493,8 @@ Checks that the value is a valid regexp
 
 =item check_webdotbase
 
+=item check_font_file
+
 =item get_param_list
 
 =item check_maxattachmentsize
index 42f34e30e95d5ec7983d302f8961d72564ad6e08..51836405cd36cddb059c973259eb06d5425d57e1 100644 (file)
@@ -22,7 +22,14 @@ sub get_param_list {
    type => 't',
    default => 'http://www.research.att.com/~north/cgi-bin/webdot.cgi/%urlbase%',
    checker => \&check_webdotbase
-  } );
+  },
+
+  {
+   name => 'font_file',
+   type => 't',
+   default => '',
+   checker => \&check_font_file
+  });
   return @param_list;
 }
 
index d803beb100b22725ba98463421c847d8352d18d7..0d32cdb52004e0b458d46454983ab22e61020ab4 100644 (file)
 
         </section>
 
-        <section id="param-dependency-graphs">
-          <title>Dependency Graphs</title>
+        <section id="param-graphs">
+          <title>Graphs</title>
           <para>
-            This page has one parameter that sets the location of a Web Dot
-            server, or of the Web Dot binary on the local system, that is used
-            to generate dependency graphs. Web Dot is a CGI program that creates
-            images from <filename>.dot</filename> graphic description files. If
-            no Web Dot server or binary is specified, then dependency graphs will
-            be disabled.
+            This page contains parameters to control how graphs are generated.
           </para>
+
+          <variablelist>
+
+          <varlistentry>
+            <term>
+              webdotbase
+            </term>
+            <listitem>
+              <para>
+                This sets the location of a Web Dot server, or of the Web Dot
+                binary on the local system, that is used to generate dependency
+                graphs. Web Dot is a CGI program that creates images from
+                <filename>.dot</filename> graphic description files. If no Web Dot
+                server or binary is specified, then dependency graphs will be disabled.
+              </para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>
+              font_file
+            </term>
+            <listitem>
+              <para>
+                This defines the full path to a TrueType font file which will be
+                used to display text in charts and graphical reports. The recommended
+                font is Unifont which supports all languages in the Basic Multilingual
+                Plane. On Linux, the path is of the form
+                <filename>/usr/share/fonts/TTF/unifont/unifont-6.3.20131006.ttf</filename>
+                and on Windows, the path would be
+                <filename>C:\Windows\Fonts\unifont-6.3.20131006.ttf</filename>.
+              </para>
+              <para>
+                If you don't have this font installed, you can download it from the
+                <ulink url="http://unifoundry.com/unifont.html">Unifoundry.com</ulink>
+                website and install it at the location specified above. This font
+                is free of charge and can be installed on all operating systems.
+              </para>
+            </listitem>
+          </varlistentry>
+
+          </variablelist>
         </section>
 
         <section id="param-group-security">
index e8baf4572a96cd4e5cb5ecd3804c2ad4af4ba5be..64a334a2020956c878408f2781864fbbc1b13248 100644 (file)
@@ -6,8 +6,8 @@
   # defined by the Mozilla Public License, v. 2.0.
   #%]
 [%
-   title = "Dependency Graphs"
-   desc = "Optional setup for dependency graphing"
+   title = "Graphs"
+   desc = "Optional setup to generate graphs"
 %]
 
 [% param_descs = {
                  this value, make certain that the webdot server can read files from your
                  webdot directory. On Apache you do this by editing the .htaccess file,
                  for other systems the needed measures may vary. You can run <kbd>checksetup.pl</kbd>
-                 to recreate the .htaccess file if it has been lost."}
+                 to recreate the .htaccess file if it has been lost.",
+
+  font_file => "You can specify the full path to a TrueType font file which will be used " _
+               "to display text (labels, legends, ...) in charts and graphical reports. " _
+               "To support as many languages as possible, we recommend to specify a TrueType " _
+               "font such as <a href=\"http://unifoundry.com/unifont.html\">Unifont</a> " _
+               "which supports all printable characters in the Basic Multilingual Plane. " _
+               "If you leave this parameter empty, a default font will be used, but " _
+               "its support is limited to English characters only and so other characters " _
+               "will be displayed incorrectly.",
+  }
 %]
index a464accd4ca95072e53747375e2167b97a73d005..91944fee5286a24b2a397874a23ac8ca47fce565 100644 (file)
@@ -6,9 +6,6 @@
   # defined by the Mozilla Public License, v. 2.0.
   #%]
 
-[% y_label = "$terms.Bugs" %]
-[% x_label = "Time" %]
-
 [% IF chart.cumulate %]
   [% USE graph = GD.Graph.area(width, height) %]
   [% graph.set(cumulate => "true") %]
@@ -19,8 +16,8 @@
 [% FILTER null;
   x_label_skip = (30 * chart.data.0.size / width);
   
-  graph.set(x_label           => x_label,
-            y_label           => y_label,
+  graph.set(x_label           => "Time",
+            y_label           => terms.Bugs,
             y_tick_number     => 8, 
             y_max_value       => chart.y_max_value,
             x_label_position  => 0.5,
                                   "lpurple", "lorange", "black", "green",
                                   "blue", "dpink", "lbrown", "gray", 
                                   "red", "dpurple", "gold", "marine"]);
-   
-  # Workaround for the fact that set_legend won't take chart.labels directly, 
-  # because chart.labels is an array reference rather than an array.
-  graph.set_legend(chart.labels.0, chart.labels.1, chart.labels.2,
-                   chart.labels.3, chart.labels.4, chart.labels.5,
-                   chart.labels.6, chart.labels.7, chart.labels.8,
-                   chart.labels.9, chart.labels.10, chart.labels.11,
-                   chart.labels.12, chart.labels.13, chart.labels.14,
-                   chart.labels.15);
-                      
-  graph.plot(chart.data).png | stdout(1);
+
+  graph.set_legend(chart.labels);
   END;
 -%]
+
+[% IF Param("font_file") %]
+  [% graph.set_x_axis_font(Param("font_file"), 9);
+     graph.set_x_label_font(Param("font_file"), 10);
+     graph.set_y_axis_font(Param("font_file"), 9);
+     graph.set_y_label_font(Param("font_file"), 10);
+     graph.set_legend_font(Param("font_file"), 9);
+  %]
+[% END %]
+
+[% graph.plot(chart.data).png | stdout(1) %]
index 70d482ec9e0ab873081e05f7e87c49dabc0402fb..d879f6dd1752c14b43763b58f5a7f9a070e939cc 100644 (file)
@@ -6,10 +6,6 @@
   # defined by the Mozilla Public License, v. 2.0.
   #%]
 
-[% y_label = "$terms.Bugs" %]
-
-[% col_field_disp = field_descs.$col_field || col_field %]
-
 [% FOR i IN [ 0 .. data.0.0.max ] %]
   [% data.0.0.$i = display_value(col_field, data.0.0.$i) %]
 [% END %]
@@ -21,8 +17,8 @@
 [% FILTER null;
   USE graph = GD.Graph.bars(width, height);
 
-  graph.set(x_label           => col_field_disp,
-            y_label           => y_label,
+  graph.set(x_label           => field_descs.$col_field || col_field,
+            y_label           => terms.Bugs,
             y_tick_number     => 8,
             y_number_format   => "%d",
             x_label_position  => 0.5,
   graph.set(cumulate          => "true",
             show_values       => 0) IF cumulate;
 
-  # Workaround for the fact that set_legend won't take row_names directly,
-  # because row_names is an array reference rather than an array.
-  graph.set_legend(row_names.0, row_names.1, row_names.2, row_names.3,
-                   row_names.4, row_names.5, row_names.6, row_names.7,
-                   row_names.8, row_names.9, row_names.10, row_names.11,
-                   row_names.12, row_names.13, row_names.14, row_names.15);
-
-  graph.plot(data.0).png | stdout(1);
+  graph.set_legend(row_names);
   END;
 -%]
+
+[% IF Param("font_file") %]
+  [% graph.set_x_axis_font(Param("font_file"), 9);
+     graph.set_x_label_font(Param("font_file"), 10);
+     graph.set_y_axis_font(Param("font_file"), 9);
+     graph.set_y_label_font(Param("font_file"), 10);
+     graph.set_legend_font(Param("font_file"), 9);
+  %]
+[% END %]
+
+[% graph.plot(data.0).png | stdout(1) %]
index 073e69bccd28d688e003fb3572ac3122c9f36a45..585133afd4d09162258c832e305cec14938a6dee 100644 (file)
@@ -6,10 +6,6 @@
   # defined by the Mozilla Public License, v. 2.0.
   #%]
 
-[% y_label = "$terms.Bugs" %]
-
-[% col_field_disp = field_descs.$col_field || col_field %]
-
 [% FOR i IN [ 0 .. data.0.0.max ] %]
   [% data.0.0.$i = display_value(col_field, data.0.0.$i) %]
 [% END %]
@@ -26,8 +22,8 @@
 [% END %]
 
 [% FILTER null;
-  graph.set(x_label           => col_field_disp,
-            y_label           => y_label,
+  graph.set(x_label           => field_descs.$col_field || col_field,
+            y_label           => terms.Bugs,
             y_tick_number     => 8,
             x_label_position  => 0.5,
             x_labels_vertical => x_labels_vertical,
                                   "blue", "dpink", "lbrown", "gray", 
                                   "red", "dpurple", "gold", "marine"]);
 
-  # Workaround for the fact that set_legend won't take row_names directly,
-  # because row_names is an array reference rather than an array.
-  graph.set_legend(row_names.0, row_names.1, row_names.2, row_names.3,
-                   row_names.4, row_names.5, row_names.6, row_names.7,
-                   row_names.8, row_names.9, row_names.10, row_names.11,
-                   row_names.12, row_names.13, row_names.14, row_names.15);
-
-  graph.plot(data.0).png | stdout(1);
+  graph.set_legend(row_names);
   END;
 -%]
+
+[% IF Param("font_file") %]
+  [% graph.set_x_axis_font(Param("font_file"), 9);
+     graph.set_x_label_font(Param("font_file"), 10);
+     graph.set_y_axis_font(Param("font_file"), 9);
+     graph.set_y_label_font(Param("font_file"), 10);
+     graph.set_legend_font(Param("font_file"), 9);
+  %]
+[% END %]
+
+[% graph.plot(data.0).png | stdout(1) %]
index 9d3f16fa3c9b35ee5462de7e7498a3e37dd0275d..cc2a1325ae74a52fd4c78216b66ac1263fd247c4 100644 (file)
@@ -6,20 +6,24 @@
   # defined by the Mozilla Public License, v. 2.0.
   #%]
 
-[% col_field_disp = field_descs.$col_field || col_field %]
-
 [% FOR i IN [ 0 .. data.0.0.max ] %]
   [% data.0.0.$i = display_value(col_field, data.0.0.$i) %]
 [% END %]
 
 [% FILTER null;
   USE graph = GD.Graph.pie(width, height);
-    
-  graph.set(title          => col_field_disp,
+
+  graph.set(title          => field_descs.$col_field || col_field,
             pie_height     => 20,
             suppress_angle => 2,
             start_angle    => 180);
-    
-  graph.plot(data.0).png | stdout(1);
   END;
 -%]
+
+[% IF Param("font_file") %]
+  [% graph.set_title_font(Param("font_file"), 10);
+     graph.set_value_font(Param("font_file"), 9);
+  %]
+[% END %]
+
+[% graph.plot(data.0).png | stdout(1) %]