
254
|
第
10
章
图片
用来展示这些字体的代码如下所示 :
<?php
$image = imagecreate(200, 200);
$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($image, 0x00, 0x00, 0x00);
imagestring($image, 1, 10, 10, "Font 1: ABCDEfghij", $black);
imagestring($image, 2, 10, 30, "Font 2: ABCDEfghij", $black);
imagestring($image, 3, 10, 50, "Font 3: ABCDEfghij", $black);
imagestring($image, 4, 10, 70, "Font 4: ABCDEfghij", $black);
imagestring($image, 5, 10, 90, "Font 5: ABCDEfghij", $black);
header("Content-Type: image/png");
imagepng($image);
也可以用
imageloadfond()
加载自己创建的位图字体。然而,字体是二进制的并且依赖
于平台,不能直接从一种机器移植到另一种机器。用
GD
提供的
TrueType
函数进行扩展
比较灵活。
TrueType
字体
TrueType
是一种标准的轮廓字体, ...