php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33599 poor quality imagettftext
Submitted: 2005-07-07 05:10 UTC Modified: 2005-07-08 07:37 UTC
From: kni at exactal dot com Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 4.3.11 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kni at exactal dot com
New email:
PHP Version: OS:

 

 [2005-07-07 05:10 UTC] kni at exactal dot com
Description:
------------
On my local Linux environment (running PHP 4.3.4 / GD bundled (2.0.15 compatible)) -- all is well. My script produces the following image:
http://www.exactal.com/tmp/phpbugs/wrap-local.png

In my live FreeBSD environment (running PHP 4.3.11 / GD bundled (2.0.28 compatible)) -- output from the same script is of lower quality:
http://www.exactal.com/tmp/phpbugs/wrap-remote.png

Note in particular poor character widths and character spacing (note also that imagettfbbox used to assess the type width returns a value that results in the type being truncated).

This is reproducable with different font files, sizes, etc, and is more noticeable with smaller font sizes.

Reproduce code:
---------------
<?php
$font_size = '11';
$font = "zapf.ttf";
$text = "environmentally sustainable";

$bbox=imagettfbbox($font_size,0,$font,$text);
$left=($bbox[0]>$bbox[6])?$bbox[6]:$bbox[0]; // determine most far points
$right=($bbox[2]>$bbox[4])?$bbox[2]:$bbox[4];
$width=$right-$left+$margin; // get total width

$newImg = ImageCreateTrueColor($width,30);
$background = imagecolorallocate($newImg, 255, 255, 255);
ImageFill($newImg, 1, 1, $background);
$foreground = imagecolorallocate($newImg, 0, 0, 0);

imagettftext($newImg, $font_size, 0, 0, 20, $foreground, $font, $text);
header("Content-type: image/png");
ImagePNG($newImg);
ImageDestroy($newImg);
?>

Expected result:
----------------
http://www.exactal.com/tmp/phpbugs/wrap-local.png

Actual result:
--------------
http://www.exactal.com/tmp/phpbugs/wrap-remote.png

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-07 05:18 UTC] kni at exactal dot com
Looks like someone else is experiencing a similar problem --

Comment from: http://www.php.net/imagettftext

gerritvg at gmail dot com
20-May-2005 05:24 
The ImageTTFText() function alway work correct. Until the've installed GD version 2.0.23 on the server.
The quality of the generated buttons is much lower.
 [2005-07-07 08:14 UTC] pajoye@php.net
Please use the bundled library ("configure --with-gd"). Take care to do not have the developement package of the system GD installed or available while configuring and installing.

Which Freetype version do you have?

--Pierre
 [2005-07-07 08:27 UTC] kni at exactal dot com
I didn't configure the live env myself (only the dev. env, which, alas, works). How does one work out which freetype version is running? Sorry for sounding like a goof! Perhaps this can help you --

http://d144091.tmp56.quadrahosting.com/phpinfo.php
 [2005-07-07 08:32 UTC] kni at exactal dot com
Locally I'm running freetype-2.1.8
 [2005-07-07 08:34 UTC] pajoye@php.net
Do you have a link to the TTF font you use?

Check your ports to see which Freetype version.

--Pierre
 [2005-07-07 08:37 UTC] kni at exactal dot com
http://d144091.tmp56.quadrahosting.com/resources/zapf.ttf

I've tested it and reproduced the same problem with other fonts also.
eg.
http://d144091.tmp56.quadrahosting.com/resources/GNMI____.TTF
 [2005-07-07 08:53 UTC] pajoye@php.net
I just checked your phpinfo. It sounds like you have an old FT version, probably version 1. Please check that and update the freetype lib to a more recent (and decent) version if needed.

--Pierre
 [2005-07-08 00:36 UTC] kni at exactal dot com
The server is running freetype 2.1.7

Is this too old?
 [2005-07-08 01:23 UTC] sniper@php.net
No, but are you SURE that's the one PHP is linked with??
Are you compiling PHP with the bundled GD? (--with-gd without any paths)

 [2005-07-08 02:06 UTC] kni at exactal dot com
The configure command is thus:

Configure Command  './configure' '--localstatedir=/var/hsphere/php' '--with-apxs=/hsphere/shared/apache/bin/apxs' '--with-openssl=/usr' '--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-bz2=/usr/local' '--with-jpeg-dir=/usr/local' '--enable-ftp' '--enable-calendar' '--with-gd' '--with-freetype-dir=/usr/local' '--enable-gd-native-ttf' '--with-png-dir=/usr/local' '--with-gettext=/usr/local' '--with-imap=/hsphere/shared' '--with-mysql=/usr/local' '--with-pgsql=/usr/local' '--enable-sockets' '--with-zip=/usr/local' '--enable-versioning' '--enable-track-vars' '--enable-trans-sid' '--disable-debug' '--enable-exif' '--with-regex=system' '--with-mhash=/usr/local' '--with-mcrypt=/usr/local' '--with-curl=/usr/local' '--with-ming=/usr/local' '--with-dom=/usr/local' '--with-iconv=/usr/local' '--with-ttf' '--enable-memory-limit' '--enable-sqlite-utf8'
 [2005-07-08 02:20 UTC] pajoye@php.net
'--with-ttf'
This is freetype 1.0 support. You activated both, it's no good idea. I have the feelings that 1.0 is used and not 2.0.

--Pierre
 [2005-07-08 02:31 UTC] kni at exactal dot com
Thanks for the advice. I'll pass this onto the admin and see what they say. Meanwhile, our local environment (that works) is configured similarly (--with-ttf):

Configure Command  './configure' '--with-gd' '--with-jpeg-dir=../jpeg-6b/' '--with-apxs=/usr/local/apache/bin/apxs' '--with-mysql=/usr/local/mysql' '--with-zlib-dir=../zlib-1.2.1/' '--enable-sockets' '--with-mcrypt' '--with-ttf' '--enable-gd-native-ttf' '--with-freetype-dir=../freetype-2.1.8/' 

...?
 [2005-07-08 02:43 UTC] pajoye@php.net
Remove freetype 1.x from the system (include development package) may help them...

--Pierre

ps: keep this report on feedback until you got an answer and write it here :)
 [2005-07-08 03:09 UTC] kni at exactal dot com
--with-ttf has been removed. The problem remains. The configure command is now:

'./configure' '--localstatedir=/var/hsphere/php' '--with-apxs=/hsphere/shared/apache/bin/apxs' '--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-bz2=/usr/local' '--with-jpeg-dir=/usr/local' '--enable-ftp' '--enable-calendar' '--with-gd' '--with-freetype-dir=/usr/local' '--enable-gd-native-ttf' '--with-png-dir=/usr/local' '--with-gettext=/usr/local' '--with-imap=/hsphere/shared' '--with-mysql=/usr/local' '--with-pgsql=/usr/local' '--enable-sockets' '--with-zip=/usr/local' '--enable-versioning' '--enable-track-vars' '--enable-trans-sid' '--disable-debug' '--enable-exif' '--enable-mbstring' '--with-regex=system' '--with-mhash=/usr/local' '--with-mcrypt=/usr/local' '--with-curl=/usr/local' '--with-ming=/usr/local' '--with-dom=/usr/local' '--with-iconv=/usr/local' '--enable-memory-limit' '--enable-sqlite-utf8'
 [2005-07-08 03:18 UTC] pajoye@php.net
I'm sorry but if it works locally using ft 2 and not on your host, there is install problem.

I suggest you to move to php-install and/or fbsd lists. Not much I can do without an access to the host. Neither I will do the setup for free. By the way, php+bundled gd +ft2 do work well on freebsd...

A last try is to see if they active the smart subpixel support (could require a manual change in the ft2 include before make), but does not seem to be the problem.

--Pierre
 [2005-07-08 07:37 UTC] sniper@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.

Installation error.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 20:01:31 2024 UTC