Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / gd / tests / imagefttext.phpt
blob16e0495ef034d12bda4eab9db73c630b9651a115
1 --TEST--
2 imagefttext() function test
3 --SKIPIF--
4 <?php 
5         if (!extension_loaded('gd')) {
6                 die("skip gd extension not available.");
7         }
8         if (!function_exists("imagefttext")) {
9                 die("skip imagefttext() not available.");
10         }
12 --FILE--
13 <?php
14         $cwd = dirname(__FILE__);
15         $fontfile_8859 = "$cwd/test8859.ttf";
17         function testrun($im, $fontfile) {
18                 $sx = imagesx($im);
19                 $sy = imagesy($im);
21                 $colour_w = imagecolorallocate($im, 255, 255, 255);
22                 $colour_b = imagecolorallocate($im, 0, 0, 0);
24                 imagefilledrectangle($im, 0, 0, $sx - 1, $sy - 1, $colour_b);
25                 imagefttext($im, $sy * 0.75, 0, 0, $sy - 1, $colour_w, $fontfile, "A", array());
27                 $cnt = 0;
28                 for ($y = 0; $y < $sy; ++$y) {
29                         for ($x = 0; $x < $sx; ++$x) {
30                                 if (imagecolorat($im, $x, $y) == $colour_b) {
31                                         ++$cnt;
32                                 }
33                         }
34                 }
36                 // imagecolordeallocate($im, $colour_w);
37                 // imagecolordeallocate($im, $colour_b);
39                 return ($cnt < ($sx * $sy));
40         }
42         $im = imagecreate(256, 256);
43         var_dump(testrun($im, $fontfile_8859));
44         imagedestroy($im);
46         $im = imagecreatetruecolor(256, 256);
47         var_dump(testrun($im, $fontfile_8859));
48         imagedestroy($im);
50 --EXPECT--
51 bool(true)
52 bool(true)