xref: /PHP-7.2/ext/gd/tests/bug51263.phpt (revision 42c14bf4)
1--TEST--
2Bug #51263 (imagettftext and rotated text uses wrong baseline)
3--SKIPIF--
4<?php
5	if(!extension_loaded('gd')){ die('skip gd extension not available'); }
6	if(!function_exists('imagettftext')) die('skip imagettftext() not available');
7?>
8--FILE--
9<?php
10$cwd = dirname(__FILE__);
11$ttf = "$cwd/Tuffy.ttf";
12$w = 23;
13$h = 70;
14$img = imagecreatetruecolor($w, $h);
15$blk = imagecolorallocate($img, 0, 0, 0);
16imagefilledrectangle($img, 0, 0, $w-1, $h-1, $blk);
17$col = imagecolorallocate($img, 255, 255, 255);
18imagettftext($img, 8, 90, 10, 60, $col, $ttf, "foo bar qux");
19$x = array(0, 1, 2, 3, 13);
20for ($j=0; $j<30; $j++) {
21    foreach ($x as $i) {
22        $c = imagecolorat($img, $i, $j);
23        if ($c != 0) {
24            echo "KO: ($i, $j)\n";
25            exit;
26        }
27    }
28}
29echo "OK\n";
30?>
31--EXPECTF--
32OK
33