|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-09-02 02:23 UTC] brian at visionn dot com
Description: ------------ When calling imagepstext() on a .pfb file on Windows NT, I get returned "T1Lib Error: Font ID Invalid in this Context". The font file seems to load fine with imagepsloadfont() (returns resource identifier), but when used within imagepstext it doesn't seem to be working properly. Am I using an invalid font file? Line endings? Something to do with Windows directory permissions? Like I said, the load works fine to return a resource... Reproduce code: --------------- http://test.taxloopholes.com/font_test.php Expected result: ---------------- An image tag returned that will show an image dynamically generated showing the text passed to the function. Actual result: -------------- 2 : imagepstext() [function.imagepstext]: T1Lib Error: Font ID Invalid in this Context PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 08:00:01 2025 UTC |
apologies, here's a better version of the code with hardcoded values: $font = imagepsloadfont("C:\\PATH_TO_FONT\\font_file.pfb"); $header_img = imagecreate(320, 20); $font_color = imagecolorallocate($header_img, 42, 86, 143); $bg_color = imagecolorallocate($header_img, 255, 255, 255); imagefill($header_img, 0, 0, $bg_color); imagepstext($header_img, "TEXT", $font, 18, $font_color, $bg_color, 0, 16, 0, 0, 0, 16);New version of test script with <?php ?>: <?php $font = imagepsloadfont("C:\PATH_TO_FONT\font_file.pfb"); $header_img = imagecreate(320, 20); $font_color = imagecolorallocate($header_img, 42, 86, 143); $bg_color = imagecolorallocate($header_img, 255, 255, 255); imagefill($header_img, 0, 0, $bg_color); imagepstext($header_img, "TEXT", $font, 18, $font_color, $bg_color, 0, 16, 0, 0, 0, 16); ?> PATH_TO_FONT\font_file.pfb should be edited to work on the system used. I can't really post on online version, since each time you run the script with an error, it would cause me to have to restart my web server. The easiest way to see the error would be to point the $font variable to a non-existent pfb file, run it, then fix it to point to an existing pfb file. Once the error has occurred, the function no longer works even when the code is correct and the pfb file exists. Once you restart IIS, it works again.