Topic: [CentOS 7 - php56] Problem with gd and freetype


we recently updated a server running CentOS7 (7.8.2003) with php56 (we currenlty cannot upgrade to php7.3 or .4 - the code of our project has to be rewritten).

We're using jpgraph, which relies on the php gd extension to output images.  It was running fine until the update. 

The update installed (among others) these two packages :
php-gd 5.6.40-20.el7.remi
gd-last 2.3.0-1.el7.remi

When testing, we now encounter the following error :

JpGraph Error: 25092 There is either a configuration problem with TrueType or a problem reading font file "REDACTED/jpgraph/fonts/DejaVuSans.ttf" Make sure file exists and is in a readable place for the HTTP process. (If 'basedir' restriction is enabled in PHP then the font file must be located in the document root.). It might also be a wrongly installed FreeType library. Try upgrading to at least FreeType 2.1.13 and recompile GD with the correct setup so it can find the new FT library.

The font file mentionned is well readable by Apache / PHP, and jpgraph was running perfectly fine before the update.

Deducting from the error message, it seems there is a mismatch between freetype and the gd-last package form the repo.

The system's freetype is :
Package freetype-2.8-14.el7.x86_64 already installed and latest version

Any hints or solutions to this pesky bug are welcome !

Re: [CentOS 7 - php56] Problem with gd and freetype

Sorry but I cannot reproduce on a fully updated CenOS 7.8 VM

Using small example from
and font file from jpgraph 4.3.1

Please provide a minimal script to reproduce.

$ cat foo.php
$im = imagecreatetruecolor(300, 100);
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
imagefilledrectangle($im, 0, 0, 299, 99, $red);
$font_file = __DIR__ . '/fonts/DejaVuSans.ttf';
imagefttext($im, 13, 0, 105, 55, $black, $font_file, 'PHP ' . PHP_VERSION . ' Manual');
var_dump(imagepng($im, __DIR__ . '/foo.png'));

$ php56 -v
PHP 5.6.40 (cli) (built: Apr 14 2020 09:40:39) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

$ php56 --ri gd


GD Support => enabled
GD headers Version => 2.3.0
GD library Version => 2.3.0
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.8.0
T1Lib Support => enabled
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.5.13
WBMP Support => enabled
XPM Support => enabled
libXpm Version => 30411
XBM Support => enabled
WebP Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 0 => 0

$ php56 foo.php


BTW the "REDACTED" in the font path seems really strange

Desktop: Fedora 31 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 32 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: [CentOS 7 - php56] Problem with gd and freetype

Hi Remi, don't mind the redacted, my text editor replaced the full path to the font.

I've checked with your example.  It's working fine. 

The problem seems to be within jpgraph itself and not with GD.

Re: [CentOS 7 - php56] Problem with gd and freetype

Found an explanation here : … J58zFMFNeI