2 imagefttext() function test
5 if (!extension_loaded('gd')) {
6 die("skip gd extension not available.");
8 if (!function_exists("imagefttext")) {
9 die("skip imagefttext() not available.");
14 $cwd = dirname(__FILE__);
15 $fontfile_8859 = "$cwd/test8859.ttf";
17 function testrun($im, $fontfile) {
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());
28 for ($y = 0; $y < $sy; ++$y) {
29 for ($x = 0; $x < $sx; ++$x) {
30 if (imagecolorat($im, $x, $y) == $colour_b) {
36 // imagecolordeallocate($im, $colour_w);
37 // imagecolordeallocate($im, $colour_b);
39 return ($cnt < ($sx * $sy));
42 $im = imagecreate(256, 256);
43 var_dump(testrun($im, $fontfile_8859));
46 $im = imagecreatetruecolor(256, 256);
47 var_dump(testrun($im, $fontfile_8859));