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

imagepsbbox

(PHP 4, PHP 5)

imagepsbbox - 使用PostScript Type1字体给出文本矩形的边界框

警告

该功能在PHP 7.0.0中已被删除

描述

代码语言:javascript
复制
array imagepsbbox ( string $text , resource $font , int $size )
代码语言:javascript
复制
array imagepsbbox ( string $text , resource $font , int $size , int $space , int $tightness , float $angle )

使用PostScript Type1字体提供文本矩形的边界框。

边界框是使用字符度量可用的信息计算的,不幸的是,与实际栅格化文本所获得的结果略有不同。如果角度为0度,则可以预期文本在每个方向上需要多1个像素。

参数

text

要写入的文本。

font_index

由imagepsloadfont()返回的字体资源。

size

size 用像素表示。

space

允许您更改字体中空格的默认值。这个数量会被添加到正常值,也可能是负值。以角色空间单位表示,其中1个单位是em平方的1/1000。

tightness

tightness允许您控制字符之间的空白量。这个数量被添加到正常字符宽度,也可以是负数。以角色空间单位表示,其中1个单位是em平方的1/1000。

angle

angle 是度数。

返回值

返回包含以下元素的数组:

0

left x-coordinate

1

upper y-coordinate

2

right x-coordinate

3

lower y-coordinate

例子

Example #1 imagepsbbox() usage

代码语言:javascript
复制
<?php
// Create image handle
$im = imagecreatetruecolor(200, 200);

// Allocate colors
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);

// Load the PostScript Font
$font = imagepsloadfont('font.pfm');

// Make a bounding box for the font
$bbox = imagepsbbox('Sample text is simple', $font, 12);

// Define our X and Y cordinates
$x = ($bbox[2] / 2) - 10;
$y = ($bbox[3] / 2) - 10;

// Write the font to the image
imagepstext($im, 'Sample text is simple', $font, 12, $black, $white, $x, $y);

// Output and free memory
header('Content-type: image/png');

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

更新日志

描述

7.0.0

T1Lib支持已从PHP中删除,因此此功能已被删除。

注释

注意:只有在使用--with-t1lib = DIR编译PHP时才能使用此函数。

← imagepolygon

imagepsencodefont →

扫码关注腾讯云开发者

领取腾讯云代金券