|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12956 libgd2 + TTF = ugly fonts.
Submitted: 2001-08-25 03:15 UTC Modified: 2001-08-26 03:45 UTC
From: php-bugs at c0de dot net Assigned:
Status: Closed Package: GD related
PHP Version: 4.0CVS-2001-08-25 OS: Debian GNU/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
30 - 25 = ?
Subscribe to this entry?

 [2001-08-25 03:15 UTC] php-bugs at c0de dot net
It all started when my boss wanted better looking thumbnails.  I found that imagecopyresampled() would make better thumbnails.  It requires libgd2 for it to work.  I removed libgd1 and installed libgd2.  The thumbnails are great now, but the ttf's are very bad.  They are larger and I think that the anti-alias is turned off or something.  I went back to libgd1 and the fonts look good.  I downloaded the CVS php4 and tried with that, still same problem.

I can't use libgd2 and have nice fonts.  I can't use libgd1 and have nice thumbnails.  I'm stuck.

Here is my configure line:
./configure  --with-apxs=/www/bin/apxs --enable-track-vars --enable-trans-sid --with-gd --enable-gd-native-ttf --with-pgsql --without-mysql --with-imap --with-openssl

and also:
./configure  --with-apxs=/www/bin/apxs --enable-track-vars --enable-trans-sid --with-freetype-dir=/usr/lib --with-gd --enable-gd-native-ttf --with-ttf --with-t1lib --with-pgsql --without-mysql --with-imap --with-openssl


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-25 07:50 UTC]
First, create a short but complete example script and
include it here so we can test it.

Second, you should use the correct paths for the configure


And btw. This configure option is for freetype2. 
( --with-ttf is for freetype 1.x )

Also note that GD2 is in BETA.
This might instead being a bug in PHP, be a bug in GD2.


 [2001-08-25 13:47 UTC] php-bugs at c0de dot net
More on the problem. (This could be a libGD bug, but the libGD test works fine, but I'm not sure if its doing the same thing)

This is from the ./configure to show that it is configured right (I have removed some lines to make it shorter):

checking whether to include GD support... yes
checking whether to enable truetype string function in gd... yes

checking for freetype(2)... yes
checking whether to include include FreeType 1.x support... no
checking whether to include T1lib support... yes
checking for T1_LoadFont in -lt1... yes
checking for gdImageCreateFromPng in -lgd... yes
checking for gdImageCreateFromJpeg in -lgd... yes
checking for gdImageCreateTrueColor in -lgd... Yes

So here is the script:
Header ("Content-type: image/jpeg");
$im = imagecreatetruecolor (400, 30);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);
ImageTTFText ($im, 20, 0, 10, 20, $white, "/Fonts/arial.ttf", "Testing... Omega: &#937;");
ImageJPEG ($im);
ImageDestroy ($im);

I have also found out if I do not use truecolor, then the font is ok, but if I create from a jpeg or png, I get crap fonts.  I guess its a truecolor problem.  I dont know if it is in PHP or in GD.  Maybe I'm posting this to the wrong place.  Is anyone else using libGD2 and truecolor TTF graphics?
Here is some samples that I made:

Thank you for your help.
 [2001-08-25 16:59 UTC]
Yes, this is known.  Anti-aliasing of TTF fonts in GD2 only works with paletted images.  No idea why.  Try asking the GD folks.
 [2001-08-25 20:59 UTC]
Not a PHP bug then..


 [2001-08-25 21:12 UTC]
How do you know?  All I said was that this was known, but that I don't know what causes truecolour images to not support anti-aliasing.  ie. whether the bug is in PHP or GD or a combination of both is yet to be determined.
 [2001-08-26 03:45 UTC]
It's a GD bug; I know this because my patched GD works fine with TTF.  I submitted the patch to the GD folks a while ago.
 [2002-01-16 21:12 UTC] abreu at diatech dot com dot br
Where can I found the GD2 patch for work with TTF ?
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 03 06:05:53 2022 UTC