ID: 49600 Updated by: t...@php.net Reported By: ch+php at 1111-internet dot com -Status: Assigned +Status: Feedback Bug Type: GD related Operating System: FreeBSD 7.0 PHP Version: 5.2.11 Assigned To: tabe New Comment:
Please try using this snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Previous Comments: ------------------------------------------------------------------------ [2010-01-08 12:18:53] s...@php.net Automatic comment from SVN on behalf of tabe Revision: http://svn.php.net/viewvc/?view=revision&revision=293268 Log: Bug #49600 (imageTTFText text shifted right) - fix difference of horizontal position between imagettftext() and imagettfbbox() ------------------------------------------------------------------------ [2009-09-25 05:00:53] ch+php at 1111-internet dot com Just noticed that the text positioning between the two examples is exactly the same - it's the bounding coordinates that changed. This suggests that in <=5.2.9 BOTH the text and the boxes were shifted right (which was less noticeable in practice since they were in sync - but a closer inspection of the 5.2.9 example does show this). The bounding coordinates are now where one would expect them to be, but that's not where the text is. ------------------------------------------------------------------------ [2009-09-19 17:49:44] paj...@php.net Tabe, can you take a look at this bug please? The only change in this area was the latest patch about bbox. ------------------------------------------------------------------------ [2009-09-19 17:34:59] ch+php at 1111-internet dot com Here's the correct result produced by the same code example with 5.2.9: http://www.1111-internet.com/images/php5_2_9_gdft_hpos.png ------------------------------------------------------------------------ [2009-09-19 15:47:15] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49600&edit=1