(PHP 4, PHP 5)

imagepsencodefontChange the character encoding vector of a font


bool imagepsencodefont ( resource $font_index , string $encodingfile )

Loads a character encoding vector from a file and changes the fonts encoding vector to it. As a PostScript fonts default vector lacks most of the character positions above 127, you'll definitely want to change this if you use a language other than English.

If you find yourself using this function all the time, a much better way to define the encoding is to set ps.default_encoding in the configuration file to point to the right encoding file and all fonts you load will automatically have the right encoding.



A font resource, returned by imagepsloadfont().


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

Return Values

Returns TRUE on success or FALSE on failure.


Example #1 imagepsencodefont() example

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

// Tell T1lib to use ISO Latin 1 encoding

// Do any operations with the font here

// Free the font from memory


Note: This function is only available if PHP is compiled using --with-t1lib[=DIR] .

add a note add a note

User Contributed Notes 2 notes

Scott Hanson
10 years ago
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.
alex_marquarth at yahoo dot de
11 years ago
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().
To Top