xref: /PHP-5.4/ext/gd/tests/bug43073.phpt (revision 131d7d7a)
1--TEST--
2Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype < 2.4.10
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	include dirname(__FILE__) . '/func.inc';
9	if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10');
10?>
11--FILE--
12<?php
13$cwd = dirname(__FILE__);
14$font = "$cwd/Tuffy.ttf";
15$delta_t = 360.0 / 16; # Make 16 steps around
16$g = imagecreate(800, 800);
17$bgnd  = imagecolorallocate($g, 255, 255, 255);
18$black = imagecolorallocate($g, 0, 0, 0);
19$x = 100;
20$y = 0;
21$cos_t = cos(deg2rad($delta_t));
22$sin_t = sin(deg2rad($delta_t));
23for ($angle = 0.0; $angle < 360.0; $angle += $delta_t) {
24  $bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF');
25  $s = vsprintf("(%d, %d), (%d, %d), (%d, %d), (%d, %d)\n", $bbox);
26  echo $s;
27  $temp = $cos_t * $x + $sin_t * $y;
28  $y    = $cos_t * $y - $sin_t * $x;
29  $x    = $temp;
30}
31imagepng($g, "$cwd/bug43073.png");
32?>
33--CLEAN--
34<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?>
35--EXPECTF--
36(500, 402), (610, 402), (610, 376), (500, 376)
37(492, 363), (591, 322), (580, 295), (480, 336)
38(470, 331), (548, 254), (527, 233), (449, 310)
39(439, 309), (483, 202), (461, 193), (416, 299)
40(401, 300), (401, 183), (381, 183), (381, 300)
41(362, 307), (316, 195), (291, 205), (337, 318)
42(330, 329), (246, 244), (224, 265), (308, 350)
43(308, 360), (202, 316), (190, 344), (296, 388)
44(300, 399), (186, 399), (186, 425), (300, 425)
45(306, 437), (195, 483), (206, 510), (318, 464)
46(328, 469), (240, 557), (260, 578), (349, 491)
47(359, 491), (312, 607), (334, 616), (382, 501)
48(398, 500), (398, 618), (418, 618), (418, 500)
49(436, 493), (483, 607), (507, 597), (461, 482)
50(468, 471), (555, 558), (577, 538), (490, 450)
51(490, 440), (600, 485), (611, 457), (502, 412)
52