Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When selecting font, attempt to use system-based font before internally supplied version #4594

Merged
merged 1 commit into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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#4598: Plugin tab does not stay visible when main poller is offline
-issue#4594: Prefer to use OS supplied Devaju Fonts fiels
-issue#4597: Selective Device Debug does not work with Remote Data Collectors
-issue#4598: Plugin tab does not stay visible when main poller is offline
-issue#4603: Cacti refuses to use the php-gettext module when installed
-issue#4607: Cacti's config.php file is improperly moved into the resource cache
-issue#4609: In some cases Cacti cacti session renewal lacks the HTTP_USER_AGENT resulting in errors in the Cacti Log
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 @@ -5559,7 +5559,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 @@ -5587,8 +5587,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