From: kni at exactal dot com
Operating system: FreeBSD
PHP version: 4.3.11
PHP Bug Type: GD related
Bug description: poor quality imagettftext
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
--
Edit bug report at http://bugs.php.net/?id=33599&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33599&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33599&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33599&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33599&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33599&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33599&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33599&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33599&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33599&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33599&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33599&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33599&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33599&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33599&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33599&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33599&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33599&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33599&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33599&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33599&r=mysqlcfg