怎么选择字体来绘制图片???
怎么看电脑里有哪些字体,然后在PHP文件里使用?
<?php
//绘制验证码
$num = 4; //验证码的长度。
$str = getCode($num, 0); //使用自定义函数,获取验证码值。
$width = $num * 20;
$height = 20;
$im = imagecreatetruecolor($width, $height); //创建画布
$c = imagecolorallocate($im, 111, 0, 55);
$bg = imagecolorallocate($im, 200, 200, 200); //设置背景
imagefill($im, 0, 0, $bg);
for($i;$i<$num;$i++) {
imagettftext($im, 18, rand(-20,20), 8+(18*$i), 24, $c, "simkai.ttf", $str[$i]);
}
header("content-Type:image/png");
imagepng($im);
imagedestroy($im);
/*
function getCode($m=4, $type=0) {
$str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$t = array(9,35,strlen($str)-1);
//随机生成验证码所需内容
$c = "";
for($i=0;$i<$m;$i++) {
$c .= $str[rand(0,$t[$type])];
}
return $c;
}
echo getCode();
?>
用fontinfo
http://www.pdflib.com/pdflib-cookbook/fonts/font-info/php-font-info/