xref: /php-src/ext/gd/tests/bug49600.phpt (revision a375d547)
1--TEST--
2Bug #49600 (imageTTFText text shifted right)
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7    if(!function_exists('imagettftext')) die('skip imagettftext() not available');
8    if(!function_exists('imagettfbbox')) die('skip imagettfbbox() not available');
9?>
10--FILE--
11<?php
12$cwd = __DIR__;
13$font = "$cwd/Tuffy.ttf";
14$image = imagecreatetruecolor(50, 50);
15$color = imagecolorallocate($image, 255, 255, 255);
16foreach (array("E", "I", "P", "g", "i", "q") as $c)
17{
18    $x = imagettftext($image, 32, 0, 0, 0, $color, $font, $c);
19    $y = imagettfbbox(32, 0, "$cwd/Tuffy.ttf", $c);
20    if ( abs($x[0] - $y[0]) > 1
21      || abs($x[2] - $y[2]) > 1
22      || abs($x[4] - $y[4]) > 1
23      || abs($x[6] - $y[6]) > 1 ) {
24      echo "FAILED: \n";
25      var_dump($x);
26      var_dump($y);
27      exit;
28    }
29}
30echo 'OK';
31?>
32--EXPECT--
33OK
34