bug50194.phpt 1.1 KB

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