php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33692 imagettftext produces no output
Submitted: 2005-07-14 09:50 UTC Modified: 2005-07-27 15:01 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: a dot vent at procommerz dot de Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 4.4.0 OS: Debian Linux 3.0 "Woody"
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: a dot vent at procommerz dot de
New email:
PHP Version: OS:

 

 [2005-07-14 09:50 UTC] a dot vent at procommerz dot de
Description:
------------
The ImageTTFText function produces no result, but also no  
error. I've tried several font files (Microsoft TT core 
fonts and also from other sources), several paths (the  
same dir as the PHP script, relative to DocRoot, absolute 
path a.s.o.).  
  
It looks like not calling imagettftext - the function  
silently does nothing...  
  
I have Debian "Woody" with Apache 1.3.29 / PHP 4.4.0. The  
GD lib is the bundled one (phpinfo says: "2.0.28  
compatible"). The Freetype lib version is 1.4pre, as  
provided from Debian package manager. 
 
PHP configure options: 
 
'./configure' '--with-apxs=/var/www/bin/apxs' 
'--with-mysql' '--enable-ftp' '--enable-shared' 
'--with-iconv' '--with-gd' '--with-curl' 
'--with-jpeg-dir=/usr' '--with-png-dir=/usr' 
'--with-dom=/usr' '--with-zlib' '--enable-cli'  
'--with-ttf=/usr' 
 
Output snippet from phpinfo: 
 
GD Support  
enabled  
 
GD Version  
bundled (2.0.28 compatible)  
 
FreeType Support  
enabled  
 
FreeType Linkage  
with TTF library  
 
GIF Read Support  
enabled  
 
GIF Create Support  
enabled  
 
JPG Support  
enabled  
 
PNG Support  
enabled  
 
WBMP Support  
enabled  
 
XBM Support  
enabled 

Reproduce code:
---------------
<?php
header("Content-type: image/png");
$im = imagecreatetruecolor(400, 30);
$grey = imagecolorallocate($im, 102, 102, 102);
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);

imagefill($im, 0, 0, $grey);

$fontfile = realpath("./Arial.ttf");

imagettftext($im, 20, 0, 10, 20, $white, $fontfile, "Hello World!");

imagepng($im);
imagedestroy($im);
?>

Expected result:
----------------
Displays an image with white-colored text "Hello World" in 
Arial font face on grey background.  

Actual result:
--------------
Displays an grey-colored image without any text (empty  
grey box). No error messages. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-15 11:59 UTC] a dot vent at procommerz dot de
Additional note: 
 
After further dealing with this issue I found that 
imagettftext works fine on 8 bit images (when using 
"imagecreate" instead of "imagecreatetruecolor"), but not 
on true color images. 
 
There is a workaround proposal published by 
"persa" (http://www.webdeveloper.com/forum/showthread.php?threadid=30767) 
that is to create two images (one of them at 8 bit) and 
then merging them together after putting the text onto the 
8 bit image. 
 
It actually seems to be a bug, doesn't it? 
 
Best regards, 
Andreas
 [2005-07-18 02:39 UTC] sniper@php.net
Why don't you try with Freetype 2? That might actually work..
 [2005-07-24 18:58 UTC] a dot vent at procommerz dot de
Well, I've tried Freetype 2.1.10 now. The result was that 
imagettftext produce an unknown function error and didn't 
work at all... 
 
The freetype compile went through perfectly as the php 
compile did, too. 
 
Maybe there's another error (e.g., in my freetype 
configuration before compiling), but these days I haven't 
got time enough to discover. For the moment, I can live 
with creating text only on 8 bit images. 
 
Best regards, 
Andreas
 [2005-07-27 15:01 UTC] pajoye@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Please use bug #33489 from now.

Provide the font Arial.ttf (btw, all windows arial work here).
http://bugs.php.net/bug.php?id=334
--Pierre
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 23:01:33 2025 UTC