我使用以下代码在 png 图像上使用 imagettftext() 函数。
但它似乎不起作用。
有什么解决办法吗?
ttf 字体位于索引.php文件的当前目录中
<?php
require ("sdk/src/facebook.php");
$facebook=new Facebook(array('appId'=>'144694832322411','secret'=>'56456456456e6f75a5c4657befa','fileUpload'=>true,));
$user = $facebook->getUser();
if($user){
echo "User";
$im = imagecreate(200,200);
$rt='font.ttf';
$col = imagecolorallocate($im,255,0,0);
$v= imagecolorallocate($im,255,0,0);
try{
imagettftext($im,30.0,0.0,0,0,$v,$rt,"Hello");} catch (Exception $e){print_r($e);}
imagepng($im,'img.png');
echo "<img src='img.png'></img>";
} else {
$auth= "https://www.facebook.com/dialog/oauth/?client_id=144694832322411&redirect_uri=".urlencode("https://apps.facebook.com/lucky_elements")."&scope=user_about_me";
echo "<script>top.location.href="$auth"</script>";
}
?>
heroku不支持imagettftext(),它不支持pfb字体,并且它有错误的gdf支持,看起来不能正常工作。因此,要么更改服务器,要么尝试构建自定义版本(https://github.com/heroku/heroku-buildpack-php)