Skip to content

Commit

Permalink
Use OS provided DejaVu font for RHEL/CentOS/SLES/Ubuntu(PR#4594)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddb4github committed Mar 12, 2022
1 parent 7d92b1b commit b8664ca
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ Cacti CHANGELOG
-issue#4587: Cacti could benefit from reducing turns to settings table by caching common variables ahead of time
-issue#4588: Cannot use multibyte in host.php
-issue#4589: db_update_table should ALTER table engine/row_format/charset before ADD/ALTER column/index
-issue#4594: Prefer to use OS supplied Devaju Fonts fiels
-issue#4598: Plugin tab does not stay visible when main poller is offline
-issue#4503: Cacti refuses to use the php-gettext module when installed
-issue#4603: Cacti refuses to use the php-gettext module when installed
-feature: Expose hidden Language Translation setting l10n_language_handler
-feature: Allow a Device to be a part of a Report outside of a Tree
-feature: Allow Basic Authentication to display customer login failed message
Expand Down
13 changes: 13 additions & 0 deletions include/global_arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -2796,4 +2796,17 @@
3 => __('Aggregate'),
);

if ($config['cacti_server_os'] == 'unix') {
$dejavu_paths = array(
'/usr/share/fonts/dejavu/', //RHEL/CentOS
'/usr/share/fonts/truetype/', //SLES
'/usr/share/fonts/truetype/dejavu/', //Ubuntu
__DIR__ . '/fonts' //Build-in
);
} else {
$dejavu_paths = array(
'C:/Windows/Fonts/' //Windows
);
}

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 @@ -5502,7 +5502,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 @@ -5530,8 +5530,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 b8664ca

Please sign in to comment.