php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26033 imageftbbox gives anomalous values when first called
Submitted: 2003-10-29 20:15 UTC Modified: 2003-10-31 06:49 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: robertks at hotmail dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.3 OS: OpenBSD 3.1
Private report: No CVE-ID: None
 [2003-10-29 20:15 UTC] robertks at hotmail dot com
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 ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/Cyberbit.ZIP
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 ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/Cyberbit.ZIP
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 )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-30 20:53 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

And use the bundled GD. (--with-gd)

 [2003-10-31 06:49 UTC] robertks at hotmail dot com
Compiling with the built-in version of gd fixed the issue.

--with-gd

is to be used instead of

--with-gd={$LOCALBASE}
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 26 12:00:02 2025 UTC