首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

imageloadfont

(PHP 4, PHP 5, PHP 7)

imageloadfont - 加载一个新的字体

描述

代码语言:javascript
复制
int imageloadfont ( string $file )

imageloadfont()加载用户定义的位图并返回其标识符。

参数

file

字体文件格式目前是二进制和架构相关的。这意味着您应该在您运行PHP的计算机上在相同类型的CPU上生成字体文件。

字节位置

C数据类型

描述

字节0-3

INT

字体中的字符数

字节4-7

INT

字体中第一个字符的值(对于空间通常为32)

字节8-11

INT

每个字符的像素宽度

字节12-15

INT

每个字符的像素高度

字节16-

烧焦

包含字符数据的数组,每个字符每个像素一个字节,总共为(nchars * width * height)个字节。

返回值

字体标识符总是大于5以避免与内置字体或FALSE错误冲突。

例子

Example #1 imageloadfont() usage example

代码语言:javascript
复制
<?php
// Create a new image instance
$im = imagecreatetruecolor(50, 20);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);

// Make the background white
imagefilledrectangle($im, 0, 0, 49, 19, $white);

// Load the gd font and write 'Hello'
$font = imageloadfont('./04b.gdf');
imagestring($im, $font, 0, 0, 'Hello', $black);

// Output to browser
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

← imageline

imageopenpolygon →

扫码关注腾讯云开发者

领取腾讯云代金券