如何更改验证码的字体?

时间:2017-09-24 07:20:04

标签: php captcha

嗨,我的表格有验证码,我想要一些验证码显示阿拉伯语或波斯语,但当我更改代码字体时,这是行不通的。我该怎么做?

<?php
session_start();

$string = '';

for ($i = 1; $i < 8; $i++) {
// this numbers refer to numbers of the ascii table (lower case)
$string .= rand(0,6);
}

$_SESSION['random_code'] = $string;

$dir = 'style/font/';

$image = imagecreatetruecolor(170, 60);
$black = imagecolorallocate($image, 0, 0, 0);
$color = imagecolorallocate($image, 200, 100, 90); // red
$white = imagecolorallocate($image, 255, 255, 255);

imagefilledrectangle($image,0,0,399,99,$white);
imagettftext ($image, 30, 0, 10, 40, $color, $dir."Yekan.ttf", 
$_SESSION['random_code']);

header("Content-type: image/png");
imagepng($image);

?>

0 个答案:

没有答案