首页 > Web开发 > 详细

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

时间:2015-10-19 15:27:49      阅读:267      评论:0      收藏:0      [点我收藏+]
<?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);

 

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

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

原文:http://www.cnblogs.com/tumio/p/4891834.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!