Skip to content

Commit a36a531

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: fixed tests for gd having freetype >= 2.4.10
2 parents 0c0b5a3 + 131d7d7 commit a36a531

File tree

5 files changed

+145
-2
lines changed

5 files changed

+145
-2
lines changed

ext/gd/tests/bug43073.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
--TEST--
2-
Bug #43073 (TrueType bounding box is wrong for angle<>0)
2+
Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype < 2.4.10
33
--SKIPIF--
44
<?php
55
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
66
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');
710
?>
811
--FILE--
912
<?php

ext/gd/tests/bug43073_1.phpt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
Bug #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') == -1) 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));
23+
for ($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+
}
31+
imagepng($g, "$cwd/bug43073.png");
32+
?>
33+
--CLEAN--
34+
<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?>
35+
--EXPECTF--
36+
(500, 400), (610, 400), (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+
(400, 300), (400, 183), (380, 183), (380, 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, 400), (187, 400), (187, 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+
(400, 500), (400, 618), (419, 618), (419, 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)

ext/gd/tests/bug48801.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
--TEST--
2-
Bug #48801 (Problem with imagettfbbox)
2+
Bug #48801 (Problem with imagettfbbox) freetype < 2.4.10
33
--SKIPIF--
44
<?php
55
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
66
if(!function_exists('imageftbbox')) die('skip imageftbbox() 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');
710
?>
811
--FILE--
912
<?php

ext/gd/tests/bug48801_1.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #48801 (Problem with imagettfbbox) freetype >= 2.4.10
3+
--SKIPIF--
4+
<?php
5+
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
6+
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
7+
8+
include dirname(__FILE__) . '/func.inc';
9+
if(version_compare(get_freetype_version(), '2.4.10') == -1) die('skip for freetype >= 2.4.10');
10+
?>
11+
--FILE--
12+
<?php
13+
$cwd = dirname(__FILE__);
14+
$font = "$cwd/Tuffy.ttf";
15+
$bbox = imageftbbox(50, 0, $font, "image");
16+
echo '(' . $bbox[0] . ', ' . $bbox[1] . ")\n";
17+
echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n";
18+
echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n";
19+
echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n";
20+
?>
21+
--EXPECTF--
22+
(-1, 15)
23+
(156, 15)
24+
(156, -48)
25+
(-1, -48)

ext/gd/tests/func.inc

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
function get_gd_version()
4+
{
5+
return GD_VERSION;
6+
}
7+
8+
function get_php_info()
9+
{
10+
ob_start();
11+
phpinfo();
12+
$info = ob_get_contents();
13+
ob_end_clean();
14+
15+
return $info;
16+
}
17+
18+
function get_freetype_version()
19+
{
20+
$version = 0;
21+
22+
if (preg_match(',FreeType Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) {
23+
$version = $match[1];
24+
}
25+
26+
return $version;
27+
}
28+
29+
function get_libjpeg_version()
30+
{
31+
$version = 0;
32+
33+
if (preg_match(',libJPEG Version => ([a-z0-9]+),s', get_php_info(), $match)) {
34+
$version = $match[1];
35+
}
36+
37+
return $version;
38+
}
39+
40+
function get_libpng_version()
41+
{
42+
$version = 0;
43+
44+
if (preg_match(',libPNG Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) {
45+
$version = $match[1];
46+
}
47+
48+
return $version;
49+
}
50+
51+
function get_libxpm_version()
52+
{
53+
$version = 0;
54+
55+
if (preg_match(',libXpm Version => (\d+),s', get_php_info(), $match)) {
56+
$version = $match[1];
57+
}
58+
59+
return $version;
60+
}
61+

0 commit comments

Comments
 (0)