php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33404 imagettftext doesn't work
Submitted: 2005-06-20 09:18 UTC Modified: 2005-06-21 14:16 UTC
From: david dot perianghendra at gmail dot com Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5.0.3 OS: Linux
Private report: No CVE-ID: None
 [2005-06-20 09:18 UTC] david dot perianghendra at gmail dot com
Description:
------------
I use PHPv5.0.3,Freetype v1.4, GD2 Library v2.0.28
I use imagettftext in my script with font file reside in the same directory, but it seems that it doens't work though i have tried to set 'GDFONTPATH' environtment variable. The result is always the same. The resulting image doesn't contain the text with specified TTF and no error occured.

Reproduce code:
---------------
<?php
header("Content-type: image/png");
$im = imagecreate(400, 30);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$text = 'Bleh...';
$font = 'COUR.ttf';
putenv( 'GDFONTPATH='.realpath('.') );
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagejpeg()
imagepng($im);
imagedestroy($im);
?>

Expected result:
----------------
The image should contain image with text written on it with specified TTF.

Actual result:
--------------
Image without the text with specified TTF.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-20 09:31 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

AFAIK, this was fixed long time ago.

 [2005-06-21 09:07 UTC] pajoye@php.net
Please provide a link to your TTF font. But it works well here (using windows cour.ttf or any other valid ttf).

--Pierre
 [2005-06-21 09:36 UTC] david dot perianghendra at gmail dot com
I have add the full path link to my ttf font file but it's still produce the same result.
 [2005-06-21 09:55 UTC] pajoye@php.net
We need the TTF file, provide a link where we can dowload it.

I still have no idea what your result is, provide a link to the result image as well.

iirc, links could something like http://youdomainhere.com/cour.ttf or http://youdomainhere.com/result_img.png


 [2005-06-21 10:32 UTC] david dot perianghendra at gmail dot com
http://bilbo.kgblogger.com/testing/cour.ttf
 [2005-06-21 12:37 UTC] sniper@php.net
This works fine for me:

<?php
header("Content-type: image/png");
$im = imagecreate(400, 30);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$text = 'Bleh...';
$font = 'cour.ttf';
putenv( 'GDFONTPATH='.realpath('.') );
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagepng($im);
imagedestroy($im);
?>

Your font-filename is in lowercase, I hope you knew that.. :)
And I'm using the PHP's bundled GD, and freetype 2.1.9

 [2005-06-21 12:42 UTC] david dot perianghendra at gmail dot com
Here come the bad news...
- I finally managed to ugrade my GD library (from 1.8.4 => 2.0.33) and compile it into php.
The good news is 
- It works. Resulting image contain text with specified TTF.

I'm sorry be4 n thxs
 [2005-06-21 12:44 UTC] david dot perianghendra at gmail dot com
Thxs
 [2005-06-21 12:55 UTC] derick@php.net
This is why you should *always* use the bundled GD library!
 [2005-06-21 14:16 UTC] pajoye@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Works here using your font.

You may have another problem in your script, tip of the day: E_ALL

--Pierre
 [2013-09-10 15:26 UTC] daverandom@php.net
Automatic comment from SVN on behalf of daverandom
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331339
Log: From doc bug 65614

This change makes the wording clearer for byref arguments being allowed a default value in the function signature.

--
Provided by anonymous #33404 (leight@gmail.com)
 [2013-09-13 09:31 UTC] daverandom@php.net
Automatic comment from SVN on behalf of daverandom
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331381
Log: Changes the description for user.ini files to make them sound less like they use the same format as .htaccess. The last sentence of the paragraph draws the parallel with .htaccess files so isn't really necessary in the first.

--
Provided by anonymous #33404 (leight@gmail.com)
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jul 11 04:01:26 2020 UTC