|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 12:00:02 2025 UTC |
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