diff options
author | Anatoliy Belsky <ab@php.net> | 2012-10-12 19:34:31 +0200 |
---|---|---|
committer | Anatoliy Belsky <ab@php.net> | 2012-10-12 19:34:31 +0200 |
commit | 131d7d7a89dda1d5677cccb37b69628ee784b1b4 (patch) | |
tree | 293367a361fd1ab88c0b4cfe42e779d2a5338759 | |
parent | 1b9e0de2ccab0d6ae6f77b53b5c3a306ec154496 (diff) | |
download | php-git-131d7d7a89dda1d5677cccb37b69628ee784b1b4.tar.gz |
fixed tests for gd having freetype >= 2.4.10
-rw-r--r-- | ext/gd/tests/bug43073.phpt | 5 | ||||
-rw-r--r-- | ext/gd/tests/bug43073_1.phpt | 51 | ||||
-rw-r--r-- | ext/gd/tests/bug48801.phpt | 5 | ||||
-rw-r--r-- | ext/gd/tests/bug48801_1.phpt | 25 | ||||
-rw-r--r-- | ext/gd/tests/func.inc | 61 |
5 files changed, 145 insertions, 2 deletions
diff --git a/ext/gd/tests/bug43073.phpt b/ext/gd/tests/bug43073.phpt index df4ffe37e8..4f448f2b4a 100644 --- a/ext/gd/tests/bug43073.phpt +++ b/ext/gd/tests/bug43073.phpt @@ -1,9 +1,12 @@ --TEST-- -Bug #43073 (TrueType bounding box is wrong for angle<>0) +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') >= 0) die('skip for freetype < 2.4.10'); ?> --FILE-- <?php diff --git a/ext/gd/tests/bug43073_1.phpt b/ext/gd/tests/bug43073_1.phpt new file mode 100644 index 0000000000..b69067d31b --- /dev/null +++ b/ext/gd/tests/bug43073_1.phpt @@ -0,0 +1,51 @@ +--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); +$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; +} +imagepng($g, "$cwd/bug43073.png"); +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?> +--EXPECTF-- +(500, 400), (610, 400), (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) +(400, 300), (400, 183), (380, 183), (380, 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, 400), (187, 400), (187, 425), (300, 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) +(400, 500), (400, 618), (419, 618), (419, 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) diff --git a/ext/gd/tests/bug48801.phpt b/ext/gd/tests/bug48801.phpt index a6a9874ab8..fd25541a52 100644 --- a/ext/gd/tests/bug48801.phpt +++ b/ext/gd/tests/bug48801.phpt @@ -1,9 +1,12 @@ --TEST-- -Bug #48801 (Problem with imagettfbbox) +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') >= 0) die('skip for freetype < 2.4.10'); ?> --FILE-- <?php diff --git a/ext/gd/tests/bug48801_1.phpt b/ext/gd/tests/bug48801_1.phpt new file mode 100644 index 0000000000..11af80cd4b --- /dev/null +++ b/ext/gd/tests/bug48801_1.phpt @@ -0,0 +1,25 @@ +--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-- +(-1, 15) +(156, 15) +(156, -48) +(-1, -48) diff --git a/ext/gd/tests/func.inc b/ext/gd/tests/func.inc new file mode 100644 index 0000000000..f17227eccd --- /dev/null +++ b/ext/gd/tests/func.inc @@ -0,0 +1,61 @@ +<?php
+
+function get_gd_version()
+{
+ return GD_VERSION;
+}
+
+function get_php_info()
+{
+ ob_start();
+ phpinfo();
+ $info = ob_get_contents();
+ ob_end_clean();
+
+ return $info;
+}
+
+function get_freetype_version()
+{
+ $version = 0;
+
+ if (preg_match(',FreeType Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) {
+ $version = $match[1];
+ }
+
+ return $version;
+}
+
+function get_libjpeg_version()
+{
+ $version = 0;
+
+ if (preg_match(',libJPEG Version => ([a-z0-9]+),s', get_php_info(), $match)) {
+ $version = $match[1];
+ }
+
+ return $version;
+}
+
+function get_libpng_version()
+{
+ $version = 0;
+
+ if (preg_match(',libPNG Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) {
+ $version = $match[1];
+ }
+
+ return $version;
+}
+
+function get_libxpm_version()
+{
+ $version = 0;
+
+ if (preg_match(',libXpm Version => (\d+),s', get_php_info(), $match)) {
+ $version = $match[1];
+ }
+
+ return $version;
+}
+
|