php 使用imagettftext()函数出问题的原因


<?php
header('Content-type: image/png');
$im = imagecreatetruecolor(400, 300); //创建画布
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);

imagefilledrectangle($im, 0, 0, 399, 29, $white);    //输出一个白色填充的矩形背景
//
////string iconv  ( string $in_charset  , string $out_charset  , string $str  )
////将字符串 str 从 in_charset 转换编码到 out_charset。
//
$text = iconv('gb2312','utf-8','show');
//
////设置字体
$font = 'C:\Windows\Fonts\msyh.ttc';
//
imagettftext($im, 20, 0, 12, 21, $grey, $font, $text); //输出一个灰色字符串作为阴影
//imagettftext($im, 20, 0, 10, 20, $black, $font, $text); //输出一个黑色字符串
//ob_clean();
imagepng($im);
imagedestroy($im);

 

设置字体的时候要写路径,不然就画不出来了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM