PHP: ps_findfont - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ps_get_buffer ps_fill

Last updated: Fri, 26 Jan 2007

view this page in

# ps_findfont

(PECL)

ps_findfont -- Loads a font

## Описание

int ps_findfont ( resource psdoc, string fontname, string encoding [, bool embed] )

Loads a font for later use. Before text is output with a loaded font it must be set with ps_setfont(). This function needs the adobe font metric file in order to calculate the space used up by the characters. A font which is loaded within a page will only be available on that page. Fonts which are to be used in the complete document have to be loaded before the first call of ps_begin_page(). Calling ps_findfont() between pages will make that font available for all following pages.

The name of the afm file must be `fontname``.afm`. If the font shall be embedded the file `fontname``.pfb` containing the font outline must be present as well.

Calling ps_findfont() before the first page requires to output the postscript header which includes the BoundingBox for the whole document. Usually the BoundingBox is set with the first call of ps_begin_page() which now comes after ps_findfont(). Consequently the BoundingBox has not been set and a warning will be issued when ps_findfont() is called. In order to prevent this situation, one should call ps_set_parameter() to set the BoundingBox before ps_findfont() is called.

## Список параметров

`psdoc`

  Resource identifier of the postscript file as returned by ps_new().

`fontname`

  The name of the font.

`encoding`

  ps_findfont() will try to load the file passed in the parameter `encoding`. Encoding files are of the same syntax as those used by dvips(1). They contain a font encoding vector (which is currently not used but must be present) and a list of extra ligatures to extend the list of ligatures derived from the afm file.

  `encoding` can be `NULL` or the empty string if the default encoding (TeXBase1) shall be used.

  If the encoding is set to `builtin` then there will be no reencoding and the font specific encoding will be used. This is very useful with symbol fonts.

`embed`

  If set to a value >0 the font will be embedded into the document. This requires the font outline (.pfb file) to be present.

## Возвращаемые значения

Returns the identifier of the font or zero in case of an error. The identifier is a positive number.

## Смотрите также

ps_begin_page()
ps_setfont()

add a note User Contributed Notes
ps_findfont
pepe at dexef dot hu
13-Apr-2006 03:19
`I found out that you must copy the <fontname>.afm files next to your php because it's searched there in default.`
zeldorblat at gmail dot com
25-Jul-2005 07:47
`I found that my Postscript files were taking an incredibly long time to generate and the file sizes were abnormally large. The problem was that, everytime I chose to set a font I would call ps_findfont() followed by ps_setfont().
It seems that every time ps_findfont() is called, the font gets embedded in the file. To prevent this, I keep an array of fonts I've already loaded, keyed by the font name. When I go to set the font, I first check this array to see if I've already loaded the font, and, if so, return the resource handle from that array. Otherwise, I call ps_findfont() and store the handle in the array.
Note that, if your call to ps_findfont() occurs while inside a page, the font will not be available on other pages. To get around this I just clear out the array at the end of each page.
My PS file went from 10 M to 75 K, and the time to create the file went from around 15 seconds to less than 1 second.`
add a note
ps_get_buffer ps_fill

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST