tabe Wed Mar 25 16:15:18 2009 UTC Added files: /php-src/ext/gd/tests bug43073.phpt
Modified files: /php-src/ext/gd/libgd gdft.c Log: MFB: #43073, TrueType bounding box is wrong for angle<>0 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gdft.c?r1=1.46&r2=1.47&diff_format=u Index: php-src/ext/gd/libgd/gdft.c diff -u php-src/ext/gd/libgd/gdft.c:1.46 php-src/ext/gd/libgd/gdft.c:1.47 --- php-src/ext/gd/libgd/gdft.c:1.46 Wed Jan 9 01:52:03 2008 +++ php-src/ext/gd/libgd/gdft.c Wed Mar 25 16:15:18 2009 @@ -1108,15 +1108,23 @@ double d1 = sin (angle + 0.78539816339744830962); double d2 = sin (angle - 0.78539816339744830962); + /* make the center of rotation at (0, 0) */ + FT_BBox normbox; + + normbox.xMin = 0; + normbox.yMin = 0; + normbox.xMax = bbox.xMax - bbox.xMin; + normbox.yMax = bbox.yMax - bbox.yMin; + /* rotate bounding rectangle */ - brect[0] = (int) (bbox.xMin * cos_a - bbox.yMin * sin_a); - brect[1] = (int) (bbox.xMin * sin_a + bbox.yMin * cos_a); - brect[2] = (int) (bbox.xMax * cos_a - bbox.yMin * sin_a); - brect[3] = (int) (bbox.xMax * sin_a + bbox.yMin * cos_a); - brect[4] = (int) (bbox.xMax * cos_a - bbox.yMax * sin_a); - brect[5] = (int) (bbox.xMax * sin_a + bbox.yMax * cos_a); - brect[6] = (int) (bbox.xMin * cos_a - bbox.yMax * sin_a); - brect[7] = (int) (bbox.xMin * sin_a + bbox.yMax * cos_a); + brect[0] = (int) (normbox.xMin * cos_a - normbox.yMin * sin_a); + brect[1] = (int) (normbox.xMin * sin_a + normbox.yMin * cos_a); + brect[2] = (int) (normbox.xMax * cos_a - normbox.yMin * sin_a); + brect[3] = (int) (normbox.xMax * sin_a + normbox.yMin * cos_a); + brect[4] = (int) (normbox.xMax * cos_a - normbox.yMax * sin_a); + brect[5] = (int) (normbox.xMax * sin_a + normbox.yMax * cos_a); + brect[6] = (int) (normbox.xMin * cos_a - normbox.yMax * sin_a); + brect[7] = (int) (normbox.xMin * sin_a + normbox.yMax * cos_a); /* scale, round and offset brect */ brect[0] = x + gdroundupdown(brect[0], d2 > 0); http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug43073.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/bug43073.phpt +++ php-src/ext/gd/tests/bug43073.phpt --TEST-- Bug #43073 (TrueType bounding box is wrong for angle<>0) --SKIPIF-- <?php if(!extension_loaded('gd')){ die('skip gd extension not available'); } ?> --FILE-- <?php $cwd = dirname(__FILE__); $font = "$cwd/test8859.ttf"; $delta_t = 360.0 / 16; # Make 16 steps around $g = imagecreate(800, 800); $bgnd = imagecolorallocate($g, 255, 255, 255); $black = imagecolorallocate($g, 0, 0, 0); $x = 100; $y = 0; $cos_t = cos(deg2rad($delta_t)); $sin_t = sin(deg2rad($delta_t)); for ($angle = 0.0; $angle < 360.0; $angle += $delta_t) { $bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF'); $s = vsprintf("(%d, %d), (%d, %d), (%d, %d), (%d, %d)\n", $bbox); echo $s; $temp = $cos_t * $x + $sin_t * $y; $y = $cos_t * $y - $sin_t * $x; $x = $temp; } ?> --EXPECTF-- (500, 400), (579, 400), (579, 370), (500, 370) (492, 361), (575, 327), (564, 301), (480, 335) (470, 329), (540, 260), (521, 242), (451, 312) (438, 307), (478, 210), (461, 204), (420, 301) (400, 300), (400, 193), (383, 193), (383, 300) (361, 307), (319, 207), (297, 216), (338, 317) (329, 329), (254, 254), (233, 275), (307, 351) (307, 361), (215, 323), (203, 354), (294, 392) (300, 400), (203, 400), (203, 431), (300, 431) (307, 438), (219, 474), (229, 501), (318, 465) (329, 470), (263, 535), (281, 553), (347, 489) (361, 492), (326, 575), (343, 582), (378, 499) (400, 500), (400, 584), (416, 584), (416, 500) (438, 492), (468, 567), (490, 559), (460, 483) (470, 470), (523, 525), (545, 505), (491, 449) (492, 438), (560, 467), (572, 436), (504, 408) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php