PHP :: Bug #49600 :: imageTTFText text shifted right
| Bug #49600 | imageTTFText text shifted right | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-09-19 15:47 UTC | Modified: | 2010-02-03 19:38 UTC |
|
||||||||||
| From: | ch+php at 1111-internet dot com | Assigned: | tabe (profile) | |||||||||||
| Status: | Closed | Package: | GD related | |||||||||||
| PHP Version: | 5.2.11 | OS: | FreeBSD 7.0 | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2009-09-19 15:47 UTC] ch+php at 1111-internet dot com
Description: ------------ imageTTFText appears to have an issue with horizontal positioning of characters. This was introduced with 5.2.10 (which also had a vertical positioning issue cited in Bug #48801) and continues with 5.2.11 (where the vertical issue appears to have been corrected). Nothing special in my config, but here it is just in case: './configure' '--prefix=/usr/local/php5' '--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-track-vars' '--with-mysql=/usr/local/mysql' '--with-gd' '--with-zlib-dir=/usr/local' '--enable-zip' '--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-tiff-dir=/usr/local' '--with-mcrypt=/usr/local' '--with-pdflib=/usr/local' '--with-curl=/usr/local' '--enable-ftp' '--without-iconv' '--without-pear' Reproduce code: --------------- $image=imagecreatetruecolor(401, 51); imagefill($image, 0, 0, imagecolorallocate($image, 255, 255, 255)); list($fontcolor, $outlinecolor, $gridcolor)=array(imagecolorallocate($image, 0, 0, 0), imagecolorallocatealpha($image, 255, 0, 0, 64), imagecolorallocate($image, 222, 255, 255)); for ($x=0; $x<=imagesx($image)-1; $x+=5) {imageline($image, $x, 0, $x, imagesy($image)-1, $gridcolor);} for ($y=0; $y<=imagesy($image)-1; $y+=5) {imageline($image, 0, $y, imagesx($image)-1, $y, $gridcolor);} foreach (array(array("face"=>"arial", "text"=>"E"), array("face"=>"arial", "text"=>"I"), array("face"=>"arial", "text"=>"P"), array("face"=>"arial", "text"=>"g"), array("face"=>"arial", "text"=>"i"), array("face"=>"arial", "text"=>"q"), array("face"=>"wingdng2", "text"=>""), array("face"=>"webdings", "text"=>"")) as $index=>$array) { list($xl, $yb, $xr, $yb2, $xr2, $yt)=imagettftext($image, 32, 0, 10+$index*50, 36, $fontcolor, "/www/fonts/". $array["face"]. ".ttf", $array["text"]); imagerectangle($image, $xl, $yt, $xr, $yb, $outlinecolor); } header("Content-Type: image/png"); imagepng($image); imagedestroy($image); exit; Expected result: ---------------- characters should fit neatly inside the rectangle outlines drawn using the return values from imagettftext, and should left align to the $x parameter of imagettftext Actual result: -------------- http://www.1111-internet.com/images/php5_2_11_gdft_hpos.png outline rectangles appear to be correct sizes and positions, but characters are often shifted right
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-09-19 17:49 UTC] pajoye@php.net
[2009-09-25 05:00 UTC] ch+php at 1111-internet dot com
[2010-08-05 16:44 UTC] barts at hexon dot cx