|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
Patchesext_gd_tests_bug48555.patch (last revision 2010-04-08 15:11 UTC by tsisaruk dot v at gmal dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
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); ?>