可以有人让我知道我如何使用谷歌网页字体创建文本验证码?
<?php
$img = imagecreatetruecolor(200, 200);
$bgColor = imagecolorallocate($img, 255, 255, 255);
$netColor = imagecolorallocate($img, 185, 185, 185);
$txtColor = imagecolorallocate($img, 0, 0, 0);
imagefill($img, 0, 0, $bgColor);
imagettftext($img, 22, 0, 50 ,45, $txtColor,"Bedizen.ttf","Expert" );
header("Content-type:image/png");
imagepng($img);
imagedestroy($img);
?>
正如你可以从上面的代码中看到的,我使用字体文件来渲染文本,但是有任何方法可以导航到谷歌免费网页字体之一吗?由于
对于任何偶然遇到这个问题的人(就像我一样)-这是可行的。正如马克所说,你需要从谷歌字体下载字体,上传到你的网络服务器,并包含它的方式。
我需要包含字体的完整路径例如:
imagettftext($img, 22, 0, 50 ,45, $txtColor,"/path/to/webroot/fonts/Downlo-Bold.ttf","Expert" );