php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18062 Generating true type font images not working
Submitted: 2002-06-29 12:03 UTC Modified: 2002-07-09 20:20 UTC
From: usenet at watson-wilson dot ca Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.2.1 OS: Linux 2.4.18
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: usenet at watson-wilson dot ca
New email:
PHP Version: OS:

 

 [2002-06-29 12:03 UTC] usenet at watson-wilson dot ca
Compiled php 4.2.1 for Apache 1.3.26 using these options:

CPPFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib
./configure --prefix=/usr/local \
  --with-apache=/usr/src/Apachetoolbox-1.5.54/apache_1.3.26 \
--enable-exif \
--enable-track-vars \
--with-calendar=shared \
--enable-safe-mode \
--enable-magic-quotes \
--enable-trans-sid \
--enable-wddx \
--enable-ftp \
--with-xpm-dir=/usr/X11R6 \
--with-gd=/usr/local \
--enable-gd-native-ttf \
--enable-gd-imgstrttf \
--with-freetype-dir=/usr/local/include/freetype2/freetype/ \
--with-ttf=/usr/local/lib \
--with-zlib \
--with-t1lib=/usr/local \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-openssl=/usr \
--with-mysql=/usr/local/mysql \

There are no errrors reported during the configure, compile or install.

This script: 
http://watson-wilson.ca/starfrontiers/images/title.php?size=35&text=Test

It is no longer working.  There are no entries in the apache error logs.  It was working prior to php 4.2.1.  I was using 4.0.? but can't remember the exact version (sorry).  I have searched the web, usenet, php.net, and phpbuilder.com.  I have asked to help on usenet and phpbuilder.com.  The only reply I had suggested that this might be a bug.  If it is not I apologize for wasting your time but I am out of options.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-29 12:18 UTC] sniper@php.net
Did you happen to update GD library?
And we really need a short example script too..

 [2002-06-29 12:22 UTC] sniper@php.net
And this is wrong:

--with-ttf=/usr/local/lib 

It should be:

--with-ttf=/usr/local

 [2002-06-30 11:07 UTC] usenet at watson-wilson dot ca
1.  I have not updated or changed GD in anyway.
2.  I've  tried --with-ttf=/usr/local but there was no improvement.

Here is the script:

<?
Header("Content-type: image/png");
// note - must use the absolute font path
// be careful about blank lines in your code which will output a blank and confuse browser
$font = "/usr/X11R6/lib/X11/fonts/drakfont/WORLDOFW.ttf";

$box = imagettfbbox($size, 0, $font, $text);

$xsize = $box[2]-$box[0]+10;
$ysize = $box[1]-$box[7]+10;

$xstart = ($xsize - ($box[2] - $box[0])) / 2;
$ystart = ($ysize - ($box[1] - $box[7])) / 2 - $box[7];

$im = imagecreate($xsize,$ysize);
$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0,0,0);
$trans=ImageColorTransparent($im,$white);

ImageTTFText($im, $size, 0, $xstart, $ystart, $black, $font, $text);

Imagepng($im);
ImageDestroy($im);
?>
 [2002-07-02 21:43 UTC] sniper@php.net
Provide a complete, self-contained script. The one here now can't be copy'pasted and run..

 [2002-07-03 08:25 UTC] usenet at watson-wilson dot ca
The very nature of this problem is generating an image using an externally referenced true type font.  There is no way that I know of to include the font in the php script.
 [2002-07-03 08:29 UTC] derick@php.net
Can you provide the font then?

Derick
 [2002-07-03 09:39 UTC] usenet at watson-wilson dot ca
Here is the URL for the font:

http://www.scifi2k.com/fonts85231647/download/worldofwater.zip
 [2002-07-09 17:34 UTC] sniper@php.net
Does the suggestion from Dmitry fix this 'bug'?
Or setting 'register_globals=on' in php.ini? 

 [2002-07-09 18:00 UTC] dpetrov at nchcapital dot com
Apparently, $size and $text are undefined. To understand the reason, check this place:

http://www.php.net/manual/en/language.variables.predefined.php

Because of that, $xsize and $ysize gets equal to 10, and you end up generating blank 10x10 PNG image.

Try to add this at the beginning of your script (before $box =):

$size = $_GET['size'];
$text = $_GET['text'];

Hope it helps,
Dmitry
 [2002-07-09 20:16 UTC] usenet at watson-wilson dot ca
Setting register_globals = on did the trick.  Thanks!

Seems this is not a bug buy my own inexperience.  Sorry to have bothered everyone.
 [2002-07-09 20:20 UTC] eru@php.net
User Error -> Bogus
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 16:01:37 2025 UTC