文字

imagepsencodefont

(PHP 4, PHP 5)

imagepsencodefont改变字体中的字符编码矢量

说明

bool imagepsencodefont ( resource $font_index , string $encodingfile )

从文件中加载字符编码矢量并用其替换给定字体的编码矢量。由于 PostScript 字体的默认矢量缺少大多数超过 127 的字符位置,因此如果使用其它非英语的语言的话肯定需要改变它。编码文件的确切格式定义在 T1lib 文档中。T1lib 包含有两个可马上使用的文件,IsoLatin1.enc 和 IsoLatin2.enc。

如果发现自己总是要用本函数,更好的定义编码的做法是在配置文件中将 ps.default_encoding 设定为指向正确的编码文件,这样加载的所有字体就会自动具有正确编码了。

Note: 此函数仅在 PHP 编译时指定了 --with-t1lib[=DIR] 时可用。

参数

font_index

A font resource, returned by imagepsloadfont() .

encodingfile

The exact format of this file is described in T1libs documentation. T1lib comes with two ready-to-use files, IsoLatin1.enc and IsoLatin2.enc.

返回值

成功时返回 TRUE , 或者在失败时返回 FALSE

范例

Example #1 imagepsencodefont() example

<?php
// Load a .pfb font file
$font  imagepsloadfont ( './px3l.pfb' );

// Tell T1lib to use ISO Latin 1 encoding
imagepsencode ( $font './IsoLatin1.enc' );

// Do any operations with the font here

// Free the font from memory
imagepsfreefont ( $font );
?>

注释

Note: 此函数仅在 PHP 编译时指定了 --with-t1lib[=DIR] 时可用。

用户评论:

[#1] Scott Hanson [2003-07-15 05:15:08]

The t1lib-5.0.0 source includes 5 different encoding files under Fonts/enc/. For my text with German umlauts, using IsoLatin1.enc did not work, but PSLatin1.enc did the trick.

[#2] alex_marquarth at yahoo dot de [2002-10-24 01:41:55]

Because I have had problems with this function to find out that there is no result to store in a variable, a short example how to use:

$font = imagepsloadfont( "/home/www/font/Arial.pfb" );
imagepsencodefont( $font, "/home/www/font/IsoLatin1.enc" );

afterwards you can use the resource $font in each other ps function like imagepstext() or imagepsbbox().

上一篇: 下一篇: