From: gert-rainer dot bitterlich at ima-dresden dot de Operating system: Windows 7 Pro PHP version: 5.5.0RC1 Package: GD related Bug Type: Bug Bug description:Wrong results with imagettfbbox(..)
Description: ------------ The function imagettfbbox(...) calculates wrong result with PHP 5.5.0RC1. With older PHP Version the result is correct. Test script: --------------- <?php function calculateTextBox($text,$fontFile,$fontSize,$fontAngle) { /************ simple function that calculates the *exact* bounding box (single pixel precision). The function returns an associative array with these keys: left, top: coordinates you will pass to imagettftext width, height: dimension of the image you have to create *************/ $rect = imagettfbbox($fontSize,$fontAngle,$fontFile,$text); $minX = min(array($rect[0],$rect[2],$rect[4],$rect[6])); $maxX = max(array($rect[0],$rect[2],$rect[4],$rect[6])); $minY = min(array($rect[1],$rect[3],$rect[5],$rect[7])); $maxY = max(array($rect[1],$rect[3],$rect[5],$rect[7])); return array( "left" => abs($minX) - 1, "top" => abs($minY) - 1, "width" => $maxX - $minX, "height" => $maxY - $minY, "box" => $rect ); } // Example usage - gif image output $text_string = "Hello World"; $font_ttf = "c:/windows/fonts/arial.ttf"; $font_size = 22; $text_angle = 0; $text_padding = 10; // Img padding - around text $the_box = calculateTextBox($text_string, $font_ttf, $font_size, $text_angle); echo'<pre>';print_r($the_box);echo'</pre>'; ?> Expected result: ---------------- Array ( [left] => 0 [top] => 21 [width] => 149 [height] => 21 [box] => Array ( [0] => -1 [1] => -1 [2] => 148 [3] => -1 [4] => 148 [5] => -22 [6] => -1 [7] => -22 ) ) Actual result: -------------- Array ( [left] => 1729848214 [top] => -1 [width] => 3723327540 [height] => 1993479376 [box] => Array ( [0] => 1993479325 [1] => 1716 [2] => 0 [3] => 1993479376 [4] => -1729848215 [5] => 0 [6] => 0 [7] => 1516706532 ) ) -- Edit bug report at https://bugs.php.net/bug.php?id=64856&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64856&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64856&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64856&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64856&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64856&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64856&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64856&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64856&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64856&r=support Expected behavior: https://bugs.php.net/fix.php?id=64856&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64856&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64856&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64856&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64856&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64856&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64856&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64856&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64856&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64856&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64856&r=mysqlcfg