|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-06-28 05:53 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
The problem: you can't call ImagePSExtendFont a second time after calling it once then calling ImagePSText. To reproduce: // ... // $f holds a loaded font, $im holds a loaded image // and $black and white hold allocated colours header('Content-type: text/plain'); $b = ImagePSExtendFont($f,1); echo "<!-- ImagePSExtendFont returned $b -->\n"; ImagePsText($im, "Hello", &$f, 20, $black, $white, rand(0,100),rand(0,0100)); $b = ImagePSExtendFont($f,1); echo "<!-- ImagePSExtendFont returned $b -->\n"; // ... The second echo of $b will show false. I picked thru the t1lib code and found that the ImagePSText code is creating size-dependent data associated with the font, which will cause subsequent calls to ImagePSExtendFont to fail (actually the underlying t1lib call to T1_ExtendFont returns the OP_NOT_PERMITTED error (#12)). To fix: You need to call T1_DeleteAllSizes before calling T1_ExtendFont in the imagepsextendfont function in ext/gd/gd.c. This removes all size-dependent data which prevents the T1_ExtendFont from succeeding the next time: /* {{{ proto bool imagepsextendfont(int font_index, double extend) Extend or or condense (if extend < 1) a font */ PHP_FUNCTION(imagepsextendfont) { #if HAVE_LIBT1 zval **fnt, **ext; int *f_ind; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &fnt, &ext) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); } convert_to_double_ex(ext); ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font); /* !!! I added this line !!! */ T1_DeleteAllSizes(*f_ind); if (T1_ExtendFont(*f_ind, Z_DVAL_PP(ext)) != 0) RETURN_FALSE; RETURN_TRUE; #else php_error(E_WARNING, "ImagePsExtendFont: No T1lib support in this PHP build"); RETURN_FALSE; #endif } /* }}} */ After I added the T1_DeleteAllSizes, it worked fine. Also, memory consumption decreases since a bunch of bitmapped stuff gets freed up.