2011-07-30 10 views
1

--enable-gd-jis-conv = sharedと--enable-mbstring = sharedをインストールしましたが、フォントファイルを使って日本語のテキストをイメージに保存できないようです。日本語のテキストで画像を保存する

「英雄時代」を英語のテキストに変更すると、イメージは日本語フォントの英語文字で正しく作成されますが、日本語のテキストでは奇妙な四角形などが表示されます。

public function makeJapaneseCharacter($font="static/JFONT.TTF", $W=200, $H=20, $X=0, $Y=0, $fsize=18, $color=array(0x0,0x0,0x0), $bgcolor=array(0xFF,0xFF,0xFF)) 
{   
$this->im = @imagecreate($W, $H) 
or die("Cannot Initialize new GD image stream"); 

$background_color = imagecolorallocate($this->im, $bgcolor[0], $bgcolor[1], $bgcolor[2]); //RGB color background. 
$text_color = imagecolorallocate($this->im, $color[0], $color[1], $color[2]);   //RGB color text. 

imagettftext($this->im, $fsize, $X, $Y, $fsize, $text_color, $font, mb_convert_encoding('英雄時代', 'SJIS', 'UTF-8')); 
$this->saveAsPng("jchar", "static/"); 
} 


public function saveAsPng($fileName, $location= null) 
{   

    $_fileName = $fileName.".png"; 
    $_fileName = is_null($location)?$_fileName:$location.$_fileName; 
    return imagepng($this->im, $_fileName);   
}  

すべてのヘルプは素晴らしい高く評価、 ニコラスだろう。

答えて

0

'英雄時代'の代わりにL'英雄時代'を書き込んでみてください。あなたが使っている言語は分かりませんが、それはC言語で行う必要があります。

0
imagettftext($this->im, 58, 0, 50, 100, 
    $text_color, $font, 
    mb_convert_encoding('佳人', 'UTF8', 'UTF-8')); 

キーが見つかりました。