Edit report at https://bugs.php.net/bug.php?id=55545&edit=1

 ID:                 55545
 Comment by:         phpbugs at exaseb dot de
 Reported by:        phpbugs at exaseb dot de
 Summary:            imagettftext() antialiasing depends on color
                     allocation order
 Status:             Open
 Type:               Bug
 Package:            GD related
 Operating System:   Windows XP, 32bit
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

I compared this problem with #21554, #7769, #18455 and #15405 and think that it 
is slightly different so I opened a new issue.


Previous Comments:
------------------------------------------------------------------------
[2011-08-31 03:27:57] phpbugs at exaseb dot de

Description:
------------
GD version: bundled (2.0.34 compatible)

Using a negative $color parameter for imagettftext() does not produce 
antialiased text if the image is created with imagecreate() (as opposed to 
imagecreatetruecolor()) and the text color is the first color allocated.

I have not looked into this but I suppose the first color recieves an index of 
0, thus a test for <0 always fails and antialiasing is never used. Using a 
negative color index is a really awful hack. imagettftext() should receive an 
additional parameter instead.


Test script:
---------------
<?php

$im = imagecreate(210, 50);
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, 209, 49, $background_color);
imagettftext($im, 20, 0, 10, 20, -$text_color, "arial.ttf", "Antialiasing");
imagetruecolortopalette($im, FALSE, 255);
imagepng($im, "as_intended.png");
imagedestroy($im);

$im = imagecreate(210, 50);
$text_color = imagecolorallocate($im, 255, 255, 255);
$background_color = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 209, 49, $background_color);
imagettftext($im, 20, 0, 10, 20, -$text_color, "arial.ttf", "Antialiasing");
imagetruecolortopalette($im, FALSE, 255);
imagepng($im, "not_as_intended.png");
imagedestroy($im);

?> 

Expected result:
----------------
The script should produce two identical PNG images with not antialiased text.

Actual result:
--------------
The image as_intended.png shows the expected result whereas not_as_intended.png 
shows antialiased text where the text should not be antialiased.


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



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

Reply via email to