array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.imageloadfont.php', 1 => 'imageloadfont', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD および Image 関数', ), 'prev' => array ( 0 => 'function.imageline.php', 1 => 'imageline', ), 'next' => array ( 0 => 'function.imageopenpolygon.php', 1 => 'imageopenpolygon', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/image/functions/imageloadfont.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
imageloadfont — 新しいフォントを読み込む
imageloadfont() はユーザーが定義したビットマップを読み込み、 その ID を返します。
filename
フォントファイル形式は現在はバイナリで、アーキクチャに依存します。 このため、PHP を実行するマシーンと同一の型の CPU 上でフォントファイルを 生成する必要があります。
バイト位置 | C 言語のデータ型 | 説明 |
---|---|---|
0-3 バイト目 | int | フォント中の文字の数 |
4-7 バイト目 | int | フォント中の最初の文字の値(しばしば 空白を表す 32 となります) |
8-11 バイト目 | int | 各文字のピクセル幅 |
12-15 バイト目 | int | 各文字のピクセル高さ |
16 バイト目から | char | 文字データの配列、各文字のピクセルにつき1バイトで、 総数は(文字数*幅*高さ)バイトです。 |
例1 imageloadfont() の使用例
<?php
// 新しい画像インスタンスを作成します
$im = imagecreatetruecolor(50, 20);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// 背景を白に設定します
imagefilledrectangle($im, 0, 0, 49, 19, $white);
// gd フォントを読み込み 'Hello' を書き込みます
$font = imageloadfont('./04b.gdf');
imagestring($im, $font, 0, 0, 'Hello', $black);
// ブラウザに出力します
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>