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:5
Avg. Score:4.4 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:3 (60.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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dimante at jmgservices dot org
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 22:01:28 2024 UTC