(PHP 4, PHP 5)
imageloadfont — 載入一新字體
說明
int imageloadfont ( string$file
)
imageloadfont()
加載一個用戶定義的位圖字體并返回該字體的標識符(其值總是大于
5,因此不會和內置字體沖突)。
在產生錯誤的情況下,該函數返回 FALSE
。
字體文件格式目前是二進制的且和平臺有關。這意味著應該用和你運行 PHP 的機器相同類型 CPU 的機器生成字體。
字體文件格式 字節位置 C 數據類型 說明 byte 0-3 int 字體中的字符數目 byte 4-7 int 字體中第一個字符的值(通常是 32 代表空格) byte 8-11 int 每個字符寬度的像素值 byte 12-15 int 每個字符高度的像素值 byte 16- char 字符數據的數組,每字符中每像素一字節,一共 (nchars*width*height) 字節。
Example #1 使用 imageloadfont
<?php
header("Content-type: image/png");
$im = imagecreatetruecolor(50, 20);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, 49, 19, $white);
$font = imageloadfont("04b.gdf");
imagestring($im, $font, 0, 0, "Hello", $black);
imagepng($im);
?>
參見 imagefontwidth() 和 imagefontheight()。