php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48555 ImageFTBBox() differs from previous versions for texts with new lines
Submitted: 2009-06-15 10:05 UTC Modified: 2011-09-16 10:46 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: a dot schilder at gmx dot net Assigned: tabe (profile)
Status: Closed Package: GD related
PHP Version: 5.3.0RC4 OS: Windows XP SP3
Private report: No CVE-ID: None
 [2009-06-15 10:05 UTC] a dot schilder at gmx dot net
Description:
------------
The results of ImageFTBBox() differs from previous versions for texts with new lines. 

The image creation works for PHP 5.04 to 5.2.9 (5.2.10 not tested). but with PHP 5.3RC3 the results are very strange...

Reproduce code:
---------------
<?php
header('Content-Type: text/plain');

$font_file = './arial.ttf';

$box = ImageFTBBox(13, 0, $font_file, "Text without line-break");
echo 'Top without line-break: ' . $box[7] . "\n";

$box = ImageFTBBox(13, 0, $font_file, "Text with\nline-break");
echo 'Top with line-break: ' . $box[7] . "\n";
?>

Expected result:
----------------
Top without line-break: -14
Top with line-break: -14

(result with PHP 5.2.9 and previous versions)

Actual result:
--------------
Top without line-break: -14
Top with line-break: -36

Patches

ext_gd_tests_bug48555.patch (last revision 2010-04-08 15:11 UTC by tsisaruk dot v at gmal dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-19 11:57 UTC] a dot schilder at gmx dot net
This bug still exists in RC4 and it's critical for me, because with the wrong value it's no more possible to create valid images (because this is used for the basline value in ImageFTText()). 

Try this to see it:

<?php
$font_file = './arial.ttf';
$text = "Text with\nline-break";

// get minimum size
$box     = ImageFTBBox(13, 0, $font_file, $text);
$left    = 0;
$top     = abs($box[7]);
$width   = abs($box[2]) + abs($box[6]);
$height  = abs($box[3]) + abs($box[7]);

// add 1px border
$left++;
$top++;
$width+=2;
$height+=2;

// create image and add text
$img   = ImageCreateTruecolor($width, $height);
$color = imagecolorallocate($img, 233, 14, 91);
ImageFTText($img, 13, 0, $left, $top, $color, $font_file, $text);

// output
header("Content-Type: image/png");
ImagePng($img);
?>
 [2009-06-19 12:06 UTC] a dot schilder at gmx dot net
Find examples for the previous script here...

PHP 5.2.9:
https://www.sendthisfile.com/TsuYvRJwezhz3UCRzlHzIQsm

PHP 5.3.0RC4:
https://www.sendthisfile.com/z8UK5VlTqiUUSKMKQ2lgoplp
 [2009-06-19 12:08 UTC] a dot schilder at gmx dot net
Version and OS updated
 [2009-06-19 15:20 UTC] a dot schilder at gmx dot net
This is possibly a side effect of the fix for Bug #43073.
 [2009-06-21 06:13 UTC] tabe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2011-09-16 10:21 UTC] dirk at haun-online dot de
The test for this bug fails when building PHP 5.4.0beta1:

FAILED TEST SUMMARY
---------------------------------------------------------------------
Bug #48555 (ImageFTBBox() differs from previous versions for texts with new lines) [ext/gd/tests/bug48555.phpt]

Also see:
http://news.php.net/php.qa.reports/30327
http://qa.php.net/reports/viewreports.php?version=5.4.0beta1&test=%2Fext%2Fgd%2Ftests%2Fbug48555.phpt
 [2011-09-16 10:46 UTC] pajoye@php.net
We need to know which Freetype version and OS you use
 [2011-09-16 10:55 UTC] dirk at haun-online dot de
That's why I linked to the QA reports, hoping that they include all the information you need:

FreeType Version => 2.4.4

OS:
Linux - Linux metis 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:05:14 UTC 2011 i686
(that's Ubuntu 11.04)
 [2011-11-05 13:12 UTC] dirk at haun-online dot de
The same test also fails for PHP 5.3.9rc1 now.

Here's the report from my machine:
http://news.php.net/php.qa.reports/30659

And here is someone else's, with the same failure:
http://news.php.net/php.qa.reports/30658
 [2011-11-10 21:59 UTC] dirk at haun-online dot de
Still failing in PHP 5.4.0RC1, if anyone cares:
http://news.php.net/php.qa.reports/30686
 [2012-04-04 17:16 UTC] ab@php.net
Automatic comment on behalf of mattficken
Revision: http://git.php.net/?p=php-src.git;a=commit;h=381edb425e16bd5d472c84d757465aa42cb39d0f
Log: Fix bug #61480 test bug - ext/gd/tests/bug48555.phpt
 [2014-10-07 23:27 UTC] stas@php.net
Automatic comment on behalf of mattficken
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=381edb425e16bd5d472c84d757465aa42cb39d0f
Log: Fix bug #61480 test bug - ext/gd/tests/bug48555.phpt
 [2014-10-07 23:38 UTC] stas@php.net
Automatic comment on behalf of mattficken
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=381edb425e16bd5d472c84d757465aa42cb39d0f
Log: Fix bug #61480 test bug - ext/gd/tests/bug48555.phpt
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC