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