GD + PHP による日本語出力



GD + PHP サンプルソース
<?
Header ("Content-type: image/jpeg");

$im = imagecreate (150, 150);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);

// フォントパスは環境に合わせてください。
$font1 = "/usr/share/fonts/ja/kochi/kochi-gothic.ttf";
$font2 = "/usr/share/fonts/ja/kochi/kochi-mincho.ttf";

$str = "インストール";

ImageTTFText ($im, 20, 45, 10, 20, $white, $font1, $str);

ImageJpeg ($im);
ImageDestroy ($im);
?>

上記コードでエラーが出なければ、インストール完了です。
フリーな東風フォントは こちら から取得してください。
出力は以下のようになります。

kochi-gothic.ttf kochi-mincho.ttf


Maniackers Design
ダサ字
へた字


GD インストール トップページ