|
imageloadfont (PHP 3, PHP 4, PHP 5) imageloadfont -- 載入一新字型 說明int imageloadfont ( string file )
imageloadfont()
加載一個會員定義的點陣圖字型並返回該字型的標識符(其值總是大於
5,因此不會和內建字型衝突)。
在產生錯誤的情況下,該函數返回 FALSE 。
字型檔案格式目前是二進位的且和平台有關。這意味著應該用和你運行
PHP 的機器相同類型 CPU 的機器建立字型。
表格 1. 字型檔案格式 位元組位置 | C 資料類型 | 說明 |
---|
byte 0-3 | int | 字型中的字元數目 | byte 4-7 | int | 字型中第一個字元的值(通常是 32 代表空格) | byte 8-11 | int | 每個字元寬度的像素值 | byte 12-15 | int | 每個字元高度的像素值 | byte 16- | char | 字元資料的陣列,每字元中每像素一位元組,一共 (nchars*width*height) 位元組。 |
例子 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); $font = imageloadfont("04b.gdf"); imagestring($im, $font, 0, 0, "Hello", $black); imagepng($im); ?>
|
|
參見 imagefontwidth() 和
imagefontheight()。
| |