ID:               48555
 Comment by:       a dot schilder at gmx dot net
 Reported By:      a dot schilder at gmx dot net
 Status:           Open
 Bug Type:         GD related
 Operating System: Windows XP
 PHP Version:      5.3.0RC3
 New Comment:

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);
?>


Previous Comments:
------------------------------------------------------------------------

[2009-06-15 10:05:09] 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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48555&edit=1

Reply via email to