Skip to content

Commit

Permalink
Use OS provided DejaVu font for RHEL/CentOS/SLES/Ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
ddb4github committed Mar 5, 2022
1 parent 2f189bd commit 7da16bb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
Binary file removed include/fonts/DejaVuSans-Bold.ttf
Binary file not shown.
Binary file removed include/fonts/DejaVuSansCondensed-Bold.ttf
Binary file not shown.
6 changes: 6 additions & 0 deletions include/global_arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -2796,4 +2796,10 @@
3 => __('Aggregate'),
);

$dejavu_paths = array(
'/usr/share/fonts/dejavu/', //RHEL/CentOS
'/usr/share/fonts/truetype/', //SLES
'/usr/share/fonts/truetype/dejavu/' //Ubuntu
);

api_plugin_hook('config_arrays');
10 changes: 8 additions & 2 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5436,7 +5436,7 @@ function padleft($pad = '', $value = '', $min = 2) {
}

function get_classic_tabimage($text, $down = false) {
global $config;
global $config, $dejavu_paths;

$images = array(
false => 'tab_template_blue.gif',
Expand Down Expand Up @@ -5464,8 +5464,14 @@ function get_classic_tabimage($text, $down = false) {
$wrapsize = 12;

if (file_exists($config['base_path'] . '/images/' . $images[$down])) {
foreach ($dejavu_paths as $dejavupath) {
if (file_exists($dejavupath)) {
$font_path = $dejavupath;
}
}

$originalpath = getenv('GDFONTPATH');
putenv('GDFONTPATH=' . $config['base_path'] . '/include/fonts/');
putenv('GDFONTPATH=' . $font_path);

$template = imagecreatefromgif ($config['base_path'] . '/images/' . $images[$down]);

Expand Down
9 changes: 7 additions & 2 deletions lib/rrd.php
Original file line number Diff line number Diff line change
Expand Up @@ -3577,7 +3577,7 @@ function rrdtool_parse_error($string) {
}

function rrdtool_create_error_image($string, $width = '', $height = '') {
global $config;
global $config, $dejavu_paths;

$string = rrdtool_parse_error($string);

Expand All @@ -3592,7 +3592,12 @@ function rrdtool_create_error_image($string, $width = '', $height = '') {
$shadeb = '999999';

if ($config['cacti_server_os'] == 'unix') {
$font_file = '/usr/share/fonts/dejavu/DejaVuSans.ttf';
foreach ($dejavu_paths as $dejavupath) {
if (file_exists($dejavupath . '/DejaVuSans.ttf')) {
$font_file = $dejavupath . '/DejaVuSans.ttf';
break;
}
}
} else {
$font_file = 'C:/Windows/Fonts/Arial.ttf';
}
Expand Down

0 comments on commit 7da16bb

Please sign in to comment.