php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34340 imagepstext returns T1Lib Error: Font ID Invalid in this Context
Submitted: 2005-09-02 02:23 UTC Modified: 2005-12-19 09:06 UTC
From: brian at visionn dot com Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5.1.0RC1 OS: Windows NT
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: brian at visionn dot com
New email:
PHP Version: OS:

 

 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-02 07:23 UTC] sniper@php.net
Provide a SHORT reproducing script. You don't need to define any functions, etc. to test this. (6 lines?)

 [2005-09-02 17:45 UTC] brian at visionn dot com
The error was fixed by restarting IIS.
 [2005-09-02 18:49 UTC] brian at visionn dot com
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);
 [2005-09-02 18:55 UTC] brian at visionn dot com
To reproduce, first run the code that work fine. Then introduce an error, run it. Remove the error, run it. The clean code doesn't work until a restart of IIS. There is a comment from 2001 in the docs about this on the imagepstext page...so this might be a T1Lib error that it can't recover from, and so wouldn't belong as a pure PHP bug(?)
 [2005-10-05 21:56 UTC] brian at visionn dot com
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.
 [2005-10-05 21:57 UTC] sniper@php.net
This is propably some threading issue with T1lib..

 [2005-12-19 09:06 UTC] sniper@php.net
Not PHP bug. Please report this to the T1 library author(s).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 20:01:31 2024 UTC