imageloadfont

(PHP 3, PHP 4, PHP 5)

imageloadfont -- 載入一新字型

說明

int imageloadfont ( string file )

imageloadfont() 加載一個會員定義的點陣圖字型並返回該字型的標識符(其值總是大於 5,因此不會和內建字型衝突)。 在產生錯誤的情況下,該函數返回 FALSE

字型檔案格式目前是二進位的且和平台有關。這意味著應該用和你運行 PHP 的機器相同類型 CPU 的機器建立字型。

表格 1. 字型檔案格式

位元組位置C 資料類型說明
byte 0-3int字型中的字元數目
byte 4-7int字型中第一個字元的值(通常是 32 代表空格)
byte 8-11int每個字元寬度的像素值
byte 12-15int每個字元高度的像素值
byte 16-char字元資料的陣列,每字元中每像素一位元組,一共 (nchars*width*height) 位元組。

例子 1. 使用 imageloadfont

<?php
$im 
imagecreatetruecolor(5020);
$black imagecolorallocate($im000);
$white imagecolorallocate($im255255255);
imagefilledrectangle($im004919$white);
$font imageloadfont("04b.gdf");
imagestring($im$font00"Hello"$black);
imagepng($im);
?>

參見 imagefontwidth()imagefontheight()