From: c dot madmax at gmail dot com Operating system: Ubuntu 12.04 PHP version: Irrelevant Package: GD related Bug Type: Bug Bug description:imageTTFText text shifted right
Description: ------------ Hello PHP Developers, I want to inform you about a imageTTFText() bug that exists since four years. The problem is that imageTTFText text is shifted right. The bug is only visible when using a large fontsize. The bigger the font the larger the shift. The bug was introduced with PHP 5.2.10 and reported here: http://bugs.php.net/bug.php?id=49600 As you can see in the history of bug 49600, a fix was made in revision 293268 and the bug was closed. But then the fix was reverted in revision 296693 and obviously no one has noticed that. I strongly urge you to fix this problem. I am using PHP 5.4.0 on Ubuntu 12.04. I am sure the bug still exists in all php versions >=5.2.10 until this day (except revision 293268-296693). I have made a test script and uploaded a sample image on two image hosters to illustrate how massive the shift is: http://img407.imageshack.us/img407/1888/mbxe.png (best quality) http://img223.imagevenue.com/img.php?image=61219_imagettftext_shifted_122_1017lo.jpg As you can see on the image, the character 'C' is NOT left aligned as it should because the x position is zero. The character is shifted approximately 20 pixels instead and overlap the polygon (which is properly left-aligned). Some characters like 'A' or 'V' are only a little bit shifted, but also overlap the polygon. It does not matter what font you use, all are right shifted. Note: The array that is returned from imagettfbbox produces values that differ 1 pixel from the values returned from imageTTFText (when using x=0; y=0) which is also a bug. Please use my test script and verify the problem. If a php developper whould use this test script each time he made a change in imageTTFText, then such bugs would not occour. It seems the developer do not have enough carefulness. That's a point you should think about. Test script: --------------- <?php $im = imagecreatetruecolor(500, 500); $bgcolor = imagecolortransparent($im, imagecolorallocate($im, 255, 255, 255)); $fgcolor = imagecolorallocatealpha($im, 0, 0, 255, 64); imagefill($im, 0, 0, $bgcolor); $polygon = imagettftext( $im, 480, // size 0, // angle 0, // x 480, // y $fgcolor, '/usr/share/fonts/truetype/msttcorefonts/verdana.ttf', 'C' // text ); imagesetthickness($im, 2); imagepolygon( $im, $polygon, sizeof($polygon) / 2, imagecolorallocatealpha($im, 255, 0, 0, 64) ); header('Content-Type: image/png'); imagepng($im); exit; ?> Expected result: ---------------- The polygon should enclose the character 'C' without overlapping the character. Actual result: -------------- The polygon overlap the character 'C' because every character is shifted right. -- Edit bug report at https://bugs.php.net/bug.php?id=65837&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65837&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65837&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65837&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65837&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65837&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65837&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65837&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65837&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65837&r=support Expected behavior: https://bugs.php.net/fix.php?id=65837&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65837&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65837&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65837&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65837&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65837&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65837&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65837&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65837&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65837&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65837&r=mysqlcfg