php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75773 imgttftext not rendering text
Submitted: 2018-01-07 15:25 UTC Modified: 2018-05-05 21:52 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: dimante at jmgservices dot org Assigned: cmb (profile)
Status: No Feedback Package: GD related
PHP Version: 7.2.1 OS: Windows Server 2012 R2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-01-07 15:25 UTC] dimante at jmgservices dot org
Description:
------------
imgttftext is not rendering text on generated images. (This issue exists on the 7.1 branch as well)

Test script:
---------------
<?php
// Set the content-type
header('Content-Type: image/png');

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = '../e107_core/fonts/chaostimes.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

Expected result:
----------------
Expected the graphic to be rendered with the text Testing...



Actual result:
--------------
Empty image was the result.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-07 15:29 UTC] dimante at jmgservices dot org
-Operating System: Server 2012 R2 +Operating System: Windows Server 2012 R2
 [2018-01-07 15:29 UTC] dimante at jmgservices dot org
Specified Windows.
 [2018-01-07 15:31 UTC] dimante at jmgservices dot org
More information can be found here:

https://github.com/e107inc/e107/issues/2956#issuecomment-355813801
 [2018-01-07 18:15 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-01-07 18:15 UTC] cmb@php.net
That looks like a duplicate of bug #75656.  Please check the
return value of imagettftext() and/or enable error_reporting to
show warnings.

As quick fix: call realpath() on the font file name.
 [2018-05-05 21:52 UTC] requinix@php.net
-Status: Feedback +Status: No Feedback
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 21:01:26 2019 UTC