1--TEST-- 2Bug #43073 (TrueType bounding box is wrong for angle<>0) 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$exp = [ 11 [501,400, 611,400, 611,376, 501,376], 12 [492,361, 595,319, 586,296, 483,338], 13 [470,329, 549,251, 531,233, 453,312], 14 [439,307, 481,204, 458,195, 416,297], 15 [400,299, 400,189, 376,189, 376,299], 16 [361,307, 319,204, 296,213, 338,316], 17 [329,329, 251,250, 233,267, 311,346], 18 [307,360, 204,318, 195,341, 297,383], 19 [299,400, 189,400, 189,424, 299,424], 20 [307,438, 204,480, 213,503, 316,461], 21 [329,470, 250,548, 267,566, 346,488], 22 [360,492, 318,595, 341,604, 383,502], 23 [400,501, 400,611, 424,611, 424,501], 24 [438,492, 480,595, 503,586, 461,483], 25 [470,470, 548,549, 566,532, 488,453], 26 [492,439, 595,481, 604,458, 502,416] 27]; 28$cwd = dirname(__FILE__); 29$font = "$cwd/Tuffy.ttf"; 30$delta_t = 360.0 / 16; # Make 16 steps around 31$g = imagecreate(800, 800); 32$bgnd = imagecolorallocate($g, 255, 255, 255); 33$black = imagecolorallocate($g, 0, 0, 0); 34$red = imagecolorallocate($g, 255, 0, 0); 35$x = 100; 36$y = 0; 37$cos_t = cos(deg2rad($delta_t)); 38$sin_t = sin(deg2rad($delta_t)); 39for ($angle = 0.0, $i = 0; $angle < 360.0; $angle += $delta_t, $i++) { 40 $bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF'); 41 imagepolygon($g, $bbox, 4, $red); 42 printf("%2d: ", $i); 43 for ($j = 0; $j < 8; $j++) { 44 if ($bbox[$j] >= $exp[$i][$j] - 1 && $bbox[$j] <= $exp[$i][$j] + 1) { 45 echo '.'; 46 } else { 47 echo "(expected $exp[$i][$j], got $bbox[$j])"; 48 } 49 } 50 echo "\n"; 51 $temp = $cos_t * $x + $sin_t * $y; 52 $y = $cos_t * $y - $sin_t * $x; 53 $x = $temp; 54} 55imagepng($g, "$cwd/bug43073.png"); 56?> 57--CLEAN-- 58<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?> 59--EXPECT-- 60 0: ........ 61 1: ........ 62 2: ........ 63 3: ........ 64 4: ........ 65 5: ........ 66 6: ........ 67 7: ........ 68 8: ........ 69 9: ........ 7010: ........ 7111: ........ 7212: ........ 7313: ........ 7414: ........ 7515: ........ 76