xref: /PHP-5.6/ext/gd/tests/bug50194.phpt (revision 7bfb7b62)
1--TEST--
2Bug #50194 (imagettftext broken on transparent background w/o alphablending)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6if (!function_exists('imagettftext')) die('skip imagettftext() not available');
7//die('skip freetype issues');
8?>
9--FILE--
10<?php
11require_once __DIR__ . DIRECTORY_SEPARATOR . 'func.inc';
12
13$im = imagecreatetruecolor(240, 55);
14$background = imagecolorallocatealpha($im, 60, 60, 60, 0); // no tranparency
15$black = imagecolorallocate($im, 0, 0, 0);
16imagealphablending($im, false);
17imagefilledrectangle($im, 0, 0, 239, 54, $background);
18$text = 'Testing ... ';
19$font = __DIR__ . DIRECTORY_SEPARATOR . 'Tuffy.ttf';
20imagettftext($im, 40, 0, 10, 40, $black, $font, $text);
21imagesavealpha($im, true);
22
23ob_start();
24test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'bug50194.png', $im);
25$output = ob_get_clean();
26assert(preg_match('/The images are equal|The images differ in (\d+) pixels/', $output, $matches));
27if (isset($matches[1]) && $matches[1] > 2000) {
28    echo "The images differ in {$matches[1]} pixels.\n";
29} else {
30    echo "The images are similar.\n";
31}
32
33imagedestroy($im);
34?>
35===DONE===
36--EXPECT--
37The images are similar.
38===DONE===
39