mirror of
https://github.com/php/php-src.git
synced 2025-01-23 20:23:31 +08:00
Merge branch 'PHP-7.0' into PHP-7.1
This commit is contained in:
commit
8dfee1a777
@ -1,31 +1,53 @@
|
||||
--TEST--
|
||||
Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype < 2.4.10
|
||||
Bug #43073 (TrueType bounding box is wrong for angle<>0)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imagettftext')) die('skip imagettftext() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10');
|
||||
|
||||
die('skip freetype issues');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$exp = [
|
||||
[501,400, 611,400, 611,376, 501,376],
|
||||
[492,361, 595,319, 586,296, 483,338],
|
||||
[470,329, 549,251, 531,233, 453,312],
|
||||
[439,307, 481,204, 458,195, 416,297],
|
||||
[400,299, 400,189, 376,189, 376,299],
|
||||
[361,307, 319,204, 296,213, 338,316],
|
||||
[329,329, 251,250, 233,267, 311,346],
|
||||
[307,360, 204,318, 195,341, 297,383],
|
||||
[299,400, 189,400, 189,424, 299,424],
|
||||
[307,438, 204,480, 213,503, 316,461],
|
||||
[329,470, 250,548, 267,566, 346,488],
|
||||
[360,492, 318,595, 341,604, 383,502],
|
||||
[400,501, 400,611, 424,611, 424,501],
|
||||
[438,492, 480,595, 503,586, 461,483],
|
||||
[470,470, 548,549, 566,532, 488,453],
|
||||
[492,439, 595,481, 604,458, 502,416]
|
||||
];
|
||||
$cwd = dirname(__FILE__);
|
||||
$font = "$cwd/Tuffy.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);
|
||||
$red = imagecolorallocate($g, 255, 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) {
|
||||
for ($angle = 0.0, $i = 0; $angle < 360.0; $angle += $delta_t, $i++) {
|
||||
$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;
|
||||
imagepolygon($g, $bbox, 4, $red);
|
||||
printf("%2d: ", $i);
|
||||
for ($j = 0; $j < 8; $j++) {
|
||||
if ($bbox[$j] >= $exp[$i][$j] - 1 && $bbox[$j] <= $exp[$i][$j] + 1) {
|
||||
echo '.';
|
||||
} else {
|
||||
echo "(expected $exp[$i][$j], got $bbox[$j])";
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
$temp = $cos_t * $x + $sin_t * $y;
|
||||
$y = $cos_t * $y - $sin_t * $x;
|
||||
$x = $temp;
|
||||
@ -34,20 +56,20 @@ imagepng($g, "$cwd/bug43073.png");
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?>
|
||||
--EXPECTF--
|
||||
(500, 40%d), (610, 40%d), (610, 376), (500, 376)
|
||||
(492, 363), (591, 322), (580, 295), (480, 336)
|
||||
(470, 331), (548, 254), (527, 233), (449, 310)
|
||||
(439, 309), (483, 202), (461, 193), (416, 299)
|
||||
(40%d, 300), (40%d, 183), (38%d, 183), (38%d, 300)
|
||||
(362, 307), (316, 195), (291, 205), (337, 318)
|
||||
(330, 329), (246, 244), (224, 265), (308, 350)
|
||||
(308, 360), (202, 316), (190, 344), (296, 388)
|
||||
(300, %d), (18%d, %d), (18%d, 425), (%d, 425)
|
||||
(306, 437), (195, 483), (206, 510), (318, 464)
|
||||
(328, 469), (240, 557), (260, 578), (349, 491)
|
||||
(359, 491), (312, 607), (334, 616), (382, 501)
|
||||
(%d, 500), (%d, 618), (41%d, 618), (41%d, 500)
|
||||
(436, 493), (483, 607), (507, 597), (461, 482)
|
||||
(468, 471), (555, 558), (577, 538), (490, 450)
|
||||
(490, 440), (600, 485), (611, 457), (502, 412)
|
||||
--EXPECT--
|
||||
0: ........
|
||||
1: ........
|
||||
2: ........
|
||||
3: ........
|
||||
4: ........
|
||||
5: ........
|
||||
6: ........
|
||||
7: ........
|
||||
8: ........
|
||||
9: ........
|
||||
10: ........
|
||||
11: ........
|
||||
12: ........
|
||||
13: ........
|
||||
14: ........
|
||||
15: ........
|
||||
|
@ -1,53 +0,0 @@
|
||||
--TEST--
|
||||
Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype >= 2.4.10
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imagettftext')) die('skip imagettftext() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') == -1) die('skip for freetype >= 2.4.10');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$cwd = dirname(__FILE__);
|
||||
$font = "$cwd/Tuffy.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);
|
||||
$red = imagecolorallocate($g, 255, 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');
|
||||
imagepolygon($g, $bbox, 4, $red);
|
||||
$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;
|
||||
}
|
||||
imagepng($g, "$cwd/bug43073.png");
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?>
|
||||
--EXPECTF--
|
||||
(501, 400), (611, 400), (611, 376), (501, 376)
|
||||
(492, 361), (595, 319), (586, 296), (483, 338)
|
||||
(470, 329), (549, 251), (531, 233), (453, 312)
|
||||
(439, 307), (481, 204), (458, 195), (416, 297)
|
||||
(400, 299), (400, 189), (376, 189), (376, 299)
|
||||
(361, 307), (319, 204), (296, 213), (338, 316)
|
||||
(329, 329), (251, 250), (233, 267), (311, 346)
|
||||
(307, 360), (204, 318), (195, 341), (297, 383)
|
||||
(299, 400), (189, 400), (189, 424), (299, 424)
|
||||
(307, 438), (204, 480), (213, 503), (316, 461)
|
||||
(329, 470), (250, 548), (267, 566), (346, 488)
|
||||
(360, 492), (318, 595), (341, 604), (383, 502)
|
||||
(400, 501), (400, 611), (424, 611), (424, 501)
|
||||
(438, 492), (480, 595), (503, 586), (461, 483)
|
||||
(470, 470), (548, 549), (566, 532), (488, 453)
|
||||
(492, 439), (595, 481), (604, 458), (502, 416)
|
@ -1,14 +1,9 @@
|
||||
--TEST--
|
||||
Bug #48801 (Problem with imagettfbbox) freetype < 2.4.10
|
||||
Bug #48801 (Problem with imagettfbbox)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10');
|
||||
|
||||
die('skip freetype issues');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
@ -20,8 +15,8 @@ echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n";
|
||||
echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n";
|
||||
echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
(-1, 15)
|
||||
(15%d, 15)
|
||||
(15%d, -48)
|
||||
(-1, -48)
|
||||
--EXPECTREGEX--
|
||||
\(4, 15\)
|
||||
\(16[0-1], 15\)
|
||||
\(16[0-1], -4[7-8]\)
|
||||
\(4, -4[7-8]\)
|
||||
|
@ -1,14 +1,9 @@
|
||||
--TEST--
|
||||
Bug #48801 (Problem with imagettfbbox) freetype < 2.4.10
|
||||
Bug #48801 (Problem with imagettfbbox)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10');
|
||||
|
||||
die('skip freetype issues');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
@ -20,8 +15,8 @@ echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n";
|
||||
echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n";
|
||||
echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
(-1, 15)
|
||||
(15%d, 15)
|
||||
(15%d, -48)
|
||||
(-1, -48)
|
||||
--EXPECTREGEX--
|
||||
\(4, 15\)
|
||||
\(16[0-1], 15\)
|
||||
\(16[0-1], -4[7-8]\)
|
||||
\(4, -4[7-8]\)
|
||||
|
@ -1,25 +0,0 @@
|
||||
--TEST--
|
||||
Bug #48801 (Problem with imagettfbbox) freetype >= 2.4.10
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') == -1) die('skip for freetype >= 2.4.10');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$cwd = dirname(__FILE__);
|
||||
$font = "$cwd/Tuffy.ttf";
|
||||
$bbox = imageftbbox(50, 0, $font, "image");
|
||||
echo '(' . $bbox[0] . ', ' . $bbox[1] . ")\n";
|
||||
echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n";
|
||||
echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n";
|
||||
echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
(4, 15)
|
||||
(161, 15)
|
||||
(161, -47)
|
||||
(4, -47)
|
@ -4,9 +4,6 @@ Bug #53504 imagettfbbox/imageftbbox gives incorrect values for bounding box
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') == -1) die('skip for freetype < 2.4.10');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
@ -21,40 +18,49 @@ $blue = imagecolorallocate($g, 0, 0, 255);
|
||||
|
||||
$tests = [
|
||||
// Kerning examples (unfortunately not available in "Tuffy" test font):
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 20, 'y' => 70, 'text' => 'AV Teg'],
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 70, 'y' => 350, 'text' => 'AV Teg'],
|
||||
['fontSize' => 50, 'angle' => 40, 'x' => 130, 'y' => 280, 'text' => 'AV Teg'],
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 20, 'y' => 70, 'text' => 'AV Teg', 'exp' => [2,15, 208,15, 208,-48, 2,-48]],
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 70, 'y' => 350, 'text' => 'AV Teg', 'exp' => [15,-1, 15,-208, -48,-208, -48,-2]],
|
||||
['fontSize' => 50, 'angle' => 40, 'x' => 130, 'y' => 280, 'text' => 'AV Teg', 'exp' => [11,11, 169,-122, 129,-171, -30,-39]],
|
||||
|
||||
// Shift-Test:
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 350, 'y' => 110, 'text' => 'H-Shift'],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 350, 'y' => 110, 'text' => 'H-Shift', 'exp' => [8,2, 386,2, 386,-97, 8,-97]],
|
||||
|
||||
// Small/single chars:
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 350, 'y' => 220, 'text' => '-'],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 430, 'y' => 220, 'text' => ','],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 510, 'y' => 220, 'text' => '.'],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 590, 'y' => 220, 'text' => '|'],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 670, 'y' => 220, 'text' => 'g'],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 350, 'y' => 220, 'text' => '-', 'exp' => [7,-37, 51,-37, 51,-46, 7,-46]],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 430, 'y' => 220, 'text' => ',', 'exp' => [7,15, 21,15, 21,-13, 7,-13]],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 510, 'y' => 220, 'text' => '.', 'exp' => [7,1, 21,1, 21,-13, 7,-13]],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 590, 'y' => 220, 'text' => '|', 'exp' => [8,0, 17,0, 17,-95, 8,-95]],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 670, 'y' => 220, 'text' => 'g', 'exp' => [5,29, 60,29, 60,-72, 5,-72]],
|
||||
|
||||
// Multi-Line + rotation:
|
||||
['fontSize' => 30, 'angle' => 0, 'x' => 20, 'y' => 400, 'text' => "Multi\nLine\nTest"],
|
||||
['fontSize' => 30, 'angle' => 40, 'x' => 150, 'y' => 420, 'text' => "Multi\nLine\nTest"],
|
||||
['fontSize' => 30, 'angle' => 90, 'x' => 250, 'y' => 340, 'text' => "Multi\nLine\nTest"],
|
||||
['fontSize' => 30, 'angle' => 0, 'x' => 20, 'y' => 400, 'text' => "Multi\nLine\nTest", 'exp' => [2,107, 80,107, 80,-29, 2,-29]],
|
||||
['fontSize' => 30, 'angle' => 40, 'x' => 150, 'y' => 420, 'text' => "Multi\nLine\nTest", 'exp' => [70,81, 131,31, 43,-74, -18,-24]],
|
||||
['fontSize' => 30, 'angle' => 90, 'x' => 250, 'y' => 340, 'text' => "Multi\nLine\nTest", 'exp' => [107,-1, 107,-80, -29,-80, -29,-2]],
|
||||
|
||||
// Some edge case glyphs:
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 70, 'y' => 750, 'text' => "iiiiiiiiiiii"],
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 150, 'y' => 750, 'text' => "~~~~~~~"],
|
||||
['fontSize' => 50, 'angle' => 50, 'x' => 210, 'y' => 750, 'text' => "iiiiiiiiiiii"],
|
||||
['fontSize' => 50, 'angle' => 50, 'x' => 300, 'y' => 750, 'text' => "~~~~~~~"],
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 430, 'y' => 650, 'text' => "iiiiiiiiiiii"],
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 430, 'y' => 750, 'text' => "~~~~~~~"],
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 70, 'y' => 750, 'text' => "iiiiiiiiiiii", 'exp' => [0,-4, 0,-165, -47,-165, -47,-4]],
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 150, 'y' => 750, 'text' => "~~~~~~~", 'exp' => [-19,-2, -18,-167, -29,-167, -29,-2]],
|
||||
['fontSize' => 50, 'angle' => 50, 'x' => 210, 'y' => 750, 'text' => "iiiiiiiiiiii", 'exp' => [3,-3, 107,-127, 70,-157, -34,-33]],
|
||||
['fontSize' => 50, 'angle' => 50, 'x' => 300, 'y' => 750, 'text' => "~~~~~~~", 'exp' => [-13,-13, 93,-141, 85,-147, -21,-20]],
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 430, 'y' => 650, 'text' => "iiiiiiiiiiii", 'exp' => [4,0, 165,0, 165,-47, 4,-47]],
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 430, 'y' => 750, 'text' => "~~~~~~~", 'exp' => [2,-19, 167,-19, 167,-29, 2,-29]],
|
||||
|
||||
// "Big" test:
|
||||
['fontSize' => 200, 'angle' => 0, 'x' => 400, 'y' => 500, 'text' => "Big"],
|
||||
['fontSize' => 200, 'angle' => 0, 'x' => 400, 'y' => 500, 'text' => "Big", 'exp' => [16,59, 329,59, 329,-190, 16,-190]],
|
||||
];
|
||||
|
||||
foreach ($tests as $test) {
|
||||
foreach ($tests as $testnum => $test) {
|
||||
$bbox = imageftbbox($test['fontSize'], $test['angle'], $font, $test['text']);
|
||||
vprintf("(%d, %d), (%d, %d), (%d, %d), (%d, %d)\n", $bbox);
|
||||
printf('%2d: ', $testnum);
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$exp = $test['exp'][$i];
|
||||
if ($bbox[$i] >= $exp - 2 && $bbox[$i] <= $exp + 2) {
|
||||
echo '.';
|
||||
} else {
|
||||
echo "(expected $exp, got $bbox[$i])";
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
|
||||
$bboxDrawn = imagefttext($g, $test['fontSize'], $test['angle'],
|
||||
$test['x'], $test['y'], $black, $font, $test['text']);
|
||||
@ -79,23 +85,23 @@ imagepng($g, "$cwd/bug53504.png");
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php @unlink(dirname(__FILE__) . '/bug53504.png'); ?>
|
||||
--EXPECTF--
|
||||
(2, 15), (208, 15), (208, -48), (2, -48)
|
||||
(15, -1), (15, -208), (-48, -208), (-48, -2)
|
||||
(11, 11), (169, -122), (129, -171), (-30, -39)
|
||||
(8, 2), (385, 2), (385, -97), (8, -97)
|
||||
(7, -37), (51, -37), (51, -46), (7, -46)
|
||||
(7, 15), (21, 15), (21, -13), (7, -13)
|
||||
(7, 1), (21, 1), (21, -13), (7, -13)
|
||||
(8, 0), (17, 0), (17, -95), (8, -95)
|
||||
(5, 29), (60, 29), (60, -72), (5, -72)
|
||||
(2, 107), (80, 107), (80, -29), (2, -29)
|
||||
(70, 81), (131, 31), (43, -74), (-18, -24)
|
||||
(107, -1), (107, -80), (-29, -80), (-29, -2)
|
||||
(0, -4), (0, -165), (-47, -165), (-47, -4)
|
||||
(-19, -2), (-18, -167), (-29, -167), (-29, -2)
|
||||
(3, -3), (107, -127), (70, -157), (-34, -33)
|
||||
(-13, -13), (93, -141), (85, -147), (-21, -20)
|
||||
(4, 0), (165, 0), (165, -47), (4, -47)
|
||||
(2, -19), (167, -19), (167, -29), (2, -29)
|
||||
(16, 59), (330, 59), (330, -190), (16, -190)
|
||||
--EXPECT--
|
||||
0: ........
|
||||
1: ........
|
||||
2: ........
|
||||
3: ........
|
||||
4: ........
|
||||
5: ........
|
||||
6: ........
|
||||
7: ........
|
||||
8: ........
|
||||
9: ........
|
||||
10: ........
|
||||
11: ........
|
||||
12: ........
|
||||
13: ........
|
||||
14: ........
|
||||
15: ........
|
||||
16: ........
|
||||
17: ........
|
||||
18: ........
|
||||
|
Loading…
Reference in New Issue
Block a user