(PHP 4, PHP 5)
imagepstext — 用 PostScript Type1 字体把文本字符串画在图像上
$image
, string $text
, resource $font
, int $size
, int $foreground
, int $background
, int $x
, int $y
[, int $space
], int $tightness
, float $angle
, int $antialias_steps
)
foreground
是文本的颜色,background
是文本以防锯齿(antialiasing)方式尝试淡入的颜色。以 background
为颜色的像素实际上不会被画上去,所以背景图像不需要是实心的颜色。
以 x
,y
给出的坐标定义了第一个字符的起点(或参考点,基本是字符的左下角)。这和
imagestring() 不同,其
x
,y
坐标定义的是第一个字符的右上角。如果不很理解请参考 PostScript
文档中关于字体及其度量系统的部分。
space
可以用来改变字体中默认间距的值。此值将被加到通常的值上,可以为负值。
tightness
可以控制字符之间的间距。此值将被加到通常字符宽度上,可以为负值。
angle
以角度表示。
size
以像素表示。
antialias_steps
可以控制防混色文本使用的颜色的数目。允许值为
4 和 16。大的数值推荐用于大小小于 20
的文本,对文本质量的效果相当明显。对更大的大小,用 4,计算强度小一些。
space
和 tightness
以字符间距单元表示,1 个单元为 1 em-square 的一千分之一。
space
,tightness
,angle
和 antialias_steps
参数为可选项。
Note: 此函数仅在 PHP 编译时指定了 --with-t1lib[=DIR] 时可用。
本函数返回一个包含下列单元的数组:
0 | 左下角的 X 坐标 |
1 | 左下角的 Y 坐标 |
2 | 右上角的 X 坐标 |
3 | 右上角的 Y 坐标 |
参见 imagepsbbox()。
image
由图象创建函数(例如 imagecreatetruecolor())返回的图象资源。
text
The text to be written.
font_index
A font resource, returned by imagepsloadfont().
size
size
is expressed in pixels.
foreground
The color in which the text will be painted.
background
The color to which the text will try to fade in with antialiasing.
No pixels with the color background
are
actually painted, so the background image does not need to be of solid
color.
x
x-coordinate for the lower-left corner of the first character.
y
y-coordinate for the lower-left corner of the first character.
space
Allows you to change the default value of a space in a font. This amount is added to the normal value and can also be negative. Expressed in character space units, where 1 unit is 1/1000th of an em-square.
tightness
tightness
allows you to control the amount
of white space between characters. This amount is added to the
normal character width and can also be negative.
Expressed in character space units, where 1 unit is 1/1000th of an
em-square.
angle
angle
is in degrees.
antialias_steps
Allows you to control the number of colours used for antialiasing text. Allowed values are 4 and 16. The higher value is recommended for text sizes lower than 20, where the effect in text quality is quite visible. With bigger sizes, use 4. It's less computationally intensive.
This function returns an array containing the following elements:
0 | lower left x-coordinate |
1 | lower left y-coordinate |
2 | upper right x-coordinate |
3 | upper right y-coordinate |
Example #1 imagepstext() usage
<?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');
// Write the font to the image
imagepstext($im, 'Sample text is simple', $font, 12, $black, $white, 50, 50);
// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
Note: 此函数仅在 PHP 编译时指定了 --with-t1lib[=DIR] 时可用。