com php-src: Fix #50194: imagettftext broken on transparent background w/o alphablending: NEWS ext/gd/libgd/gdft.c ext/gd/tests/bug50194.phpt
ext/gd/tests/bug50194.png

From: Date: Wed, 14 Sep 2016 13:47:32 +0000
Subject: com php-src: Fix #50194: imagettftext broken on transparent background w/o alphablending: NEWS ext/gd/libgd/gdft.c ext/gd/tests/bug50194.phpt
ext/gd/tests/bug50194.png
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94519@lists.php.net to get a copy of this message
Commit: 09eb6ed35eb5b0d164aa9fbad52dd8d873166294 Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 14 Sep 2016 14:59:17 +0200 Parents: 05baa927277c820de4deee0991c24c7f4c545105 Branches: PHP-5.6 PHP-7..0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=09eb6ed35eb5b0d164aa9fbad52dd8d873166294 Log: Fix #50194: imagettftext broken on transparent background w/o alphablending We must not draw the background pixels of the character glyphs, what has already been fixed in GD 2.0.26. Bugs: https://bugs.php.net/50194 Changed paths: M NEWS M ext/gd/libgd/gdft.c A ext/gd/tests/bug50194.phpt A ext/gd/tests/bug50194.png Diff: diff --git a/NEWS b/NEWS index b7f466d..61f9609 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,8 @@ PHP NEWS - GD: . Fixed bug #67325 (imagetruecolortopalette: white is duplicated in palette). (cmb) + . Fixed bug #50194 (imagettftext broken on transparent background w/o + alphablending). (cmb) - Mbstring: . Fixed bug #72994 (mbc_to_code() out of bounds read). (Laruence, cmb) diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index ba905dc..be9ae61 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -659,6 +659,8 @@ static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, } else { return "Unsupported ft_pixel_mode"; } + if (level == 0) /* if background */ + continue; if ((fg >= 0) && (im->trueColor)) { /* Consider alpha in the foreground color itself to be an * upper bound on how opaque things get, when truecolor is diff --git a/ext/gd/tests/bug50194.phpt b/ext/gd/tests/bug50194.phpt new file mode 100644 index 0000000..91b7b35 --- /dev/null +++ b/ext/gd/tests/bug50194.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #50194 (imagettftext broken on transparent background w/o alphablending) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +if (!function_exists('imagettftext')) die('skip imagettftext() not available'); +?> +--FILE-- +<?php +require_once __DIR__ . DIRECTORY_SEPARATOR . 'func..inc'; + +$im = imagecreatetruecolor(240, 55); +$background = imagecolorallocatealpha($im, 60, 60, 60, 0); // no tranparency +$black = imagecolorallocate($im, 0, 0, 0); +imagealphablending($im, false); +imagefilledrectangle($im, 0, 0, 239, 54, $background); +$text = 'Testing .... '; +$font = __DIR__ . DIRECTORY_SEPARATOR . 'Tuffy.ttf'; +imagettftext($im, 40, 0, 10, 40, $black, $font, $text); +imagesavealpha($im, true); + +test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'bug50194.png', $im); + +imagedestroy($im); +?> +===DONE=== +--EXPECT-- +The images are equal. +===DONE=== diff --git a/ext/gd/tests/bug50194.png b/ext/gd/tests/bug50194.png new file mode 100644 index 0000000..5bbf5ba Binary files /dev/null and b/ext/gd/tests/bug50194.png differ

« previous php.cvs (#94519) next »