From: Christoph M. Becker Date: Wed, 14 Sep 2016 12:59:17 +0000 (+0200) Subject: Fix #50194: imagettftext broken on transparent background w/o alphablending X-Git-Tag: php-7.0.12RC1~57^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09eb6ed35eb5b0d164aa9fbad52dd8d873166294;p=php 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. --- diff --git a/NEWS b/NEWS index b7f466dc2e..61f96093d6 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 ba905dc0a8..be9ae6177b 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 0000000000..91b7b35139 --- /dev/null +++ b/ext/gd/tests/bug50194.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #50194 (imagettftext broken on transparent background w/o alphablending) +--SKIPIF-- + +--FILE-- + +===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 0000000000..5bbf5babae Binary files /dev/null and b/ext/gd/tests/bug50194.png differ