note 30058 added to ref.image
| From: | cysoft@php.net | Date: | Wed, 05 Mar 2003 14:32:52 +0000 |
| Subject: | note 30058 added to ref.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44877@lists.php.net to get a copy of this message | ||
How to using GD out put chinese Characters (BIG 5 or GB2312).
the following code shows you how to using gd display chinese Characters.
there is a funcation called by ImageTTFText.
since gd dose not support GB2312/big5 but unicode.if you can convert
Characters to unicode which you want display then every thing will be done!
your 's yan
<?php
function gb23122uni($text) {
$rtext="";
$max=strlen($text);
for($i=0;$i<$max;$i++){
$h=ord($text[$i]);
if($h>=160 && $i<$max-1){
$rtext.="&#".base_convert(bin2hex(iconv("gb2312","ucs-2",
substr($text,$i,2))),16,10).";";
$i++;
}else{
$rtext.=$text[$i];
}
}
return $rtext;
}
Header("Content-type: image/gif");
$im = imagecreate(400,50);
$black = ImageColorAllocate($im, 0,255,0);
$white = ImageColorAllocate($im, 255,0,255);
ImageTTFText($im, 20, 0, 30, 30, $white, "c:\php\STCAIYUN.ttf",gb23122uni("
ÄãºÃ")."test");
Imagejpeg($im);
ImageDestroy($im);
?>
--
http://www.php.net/manual/en/ref.image.php
http://master.php.net/manage/user-notes.php?action=edit+30058
http://master.php.net/manage/user-notes.php?action=delete+30058
http://master.php.net/manage/user-notes.php?action=reject+30058