note 55093 added to function.ps-findfont
| From: | zeldorblat at gmail dot com | Date: | Mon, 25 Jul 2005 14:47:54 +0000 |
| Subject: | note 55093 added to function.ps-findfont | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92419@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.ps-findfont.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55093
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55093&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55093&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55093&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55093&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55093&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55093&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55093&report=yes
Search -- http://master.php.net/manage/user-notes.php