[kansaipm] GD で TTF を使うと文字化けしてしまいます

takimoto takimoto at miki-net.or.jp
Sun Jun 2 15:30:11 CDT 2002


TAKIです

takimoto <takimoto at miki-net.or.jp> wrote:
>あ,それと Jcode.pm をWinな環境に入れるのはめんどうくさそうなので,とり
>あえずソースごとエディタで UTF-8 でセーブしてから実行してみました.
># Jcode.pm をWinな環境に入れるにはどうしたらいいんだろう???

以下のページを参考にしてWinな環境にJcode.pmを入れてみました.
http://homepage2.nifty.com/hobbit/html/jcode.html

で,以下のように 今度はJcodeで変換してみました.

OKですね  v(^^)v

use GD; 
use Jcode;

$im = new GD::Image(400,250); 

($white,$black,$red,$blue,$yellow) = 
( 
	$im->colorAllocate(255, 255, 255), 
	$im->colorAllocate(0, 0, 0), 
	$im->colorAllocate(255, 0, 0), 
	$im->colorAllocate(0,0,255), 
	$im->colorAllocate(255,250,205) 
); 
$im->interlaced(1); # cool venetian blinds effect 

$font1 = "c:\\windows\\fonts\\arial.ttf"; 
$font = "c:\\windows\\fonts\\MSGOTHIC.TTC"; 

# Some TTFs 
$im->stringTTF($black,$font,18.0,0.0,20,20,"Hello") || die $@; 
$im->stringTTF($red,$font,14.0,0.0,20,80,"How are you")|| die $@;; 
$im->stringTTF($blue,$font,30.0,-0.2,60,130,"hello world!!")|| die $@;; 

$japanese = 'Japanese日本語フォントOK!';
Jcode::convert(\$japanese,'utf8');
$im->stringTTF($red,$font,14.0,0.0,20,100,$japanese)|| die $@;; 


open(FILE,">ttf.png"); 
binmode FILE; 
print FILE $im->png; 
close(FILE); 



   瀧本  満  "TAKI"    takimoto at miki-net.or.jp




More information about the Kansai-pm mailing list