From: robertks at hotmail dot com
Operating system: OpenBSD 3.1
PHP version: 4.3.1
PHP Bug Type: GD related
Bug description: imageftbbox gives anomalous values when first called

Description:
------------
Can anyone explain the bizarre behavior of this code?

<?
$text = "Lorem ipsum dolor sit amet,\n\rconsetetur sadipscing elitr, sed
diam nonumy eirmod tempor invidunt";
$size = 15;
$fontfile = "Cyberbit.ttf"; // from
[url]ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/Cyberbit.ZIP[/url]
print_r(imageftbbox($size, 0, $fontfile, $text, array()));
echo '<br />';
print_r(imageftbbox($size, 0, $fontfile, $text, array()));
?>

Output:
Array ( [0] => -1 [1] => 5 [2] => 598 [3] => 5 [4] => 598 [5] => -33554432
[6] => -1 [7] => -33554432 )
Array ( [0] => -1 [1] => 37 [2] => 598 [3] => 37 [4] => 598 [5] => -16 [6]
=> -1 [7] => -16 )

Particulars:
Freetype 2.0.4
GD 2.0.9
PHP 4.3.1

What's going on? The [5] and [7] values of the output array (Y positions
of the upper corners of the bounding box) are anomalous the first time the
imageftbbox function is called. When the function is called again in an
identical manner, the values are good.

imagettfbbox does not exhibit this behavior on my system.

If this is a known bug, cursory searches haven't brought up anything about
it.

Help!

All the best,
Robert K S

Reproduce code:
---------------
<?
$text = "Lorem ipsum dolor sit amet,\n\rconsetetur sadipscing elitr, sed
diam nonumy eirmod tempor invidunt";
$size = 15;
$fontfile = "Cyberbit.ttf"; // from
[url]ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/Cyberbit.ZIP[/url]
print_r(imageftbbox($size, 0, $fontfile, $text, array()));
echo '<br />';
print_r(imageftbbox($size, 0, $fontfile, $text, array()));
?>

Expected result:
----------------
Output:
Array ( [0] => -1 [1] => 37 [2] => 598 [3] => 37 [4] => 598 [5] => -16 [6]
=> -1 [7] => -16 )
Array ( [0] => -1 [1] => 37 [2] => 598 [3] => 37 [4] => 598 [5] => -16 [6]
=> -1 [7] => -16 )

Actual result:
--------------
Output:
Array ( [0] => -1 [1] => 5 [2] => 598 [3] => 5 [4] => 598 [5] => -33554432
[6] => -1 [7] => -33554432 )
Array ( [0] => -1 [1] => 37 [2] => 598 [3] => 37 [4] => 598 [5] => -16 [6]
=> -1 [7] => -16 )

--
Edit bug report at [url]http://bugs.php.net/?id=26033&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=26033&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=26033&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=26033&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=26033&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=26033&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=26033&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=26033&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=26033&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=26033&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=26033&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=26033&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=26033&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=26033&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=26033&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=26033&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=26033&r=float[/url]