Bug #14735 Updated: Missing function call in imagepsextendfont prevents multiple invocations

From: Date: Fri, 28 Jun 2002 09:53:28 +0000
Subject: Bug #14735 Updated: Missing function call in imagepsextendfont prevents multiple invocations
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12385@lists.php.net to get a copy of this message
ID: 14735 Updated by: sniper@php.net Reported By: mfkahn2@yahoo.com -Status: Open +Status: Closed Bug Type: GD related Operating System: RH6.2 PHP Version: 4.1.0 New Comment: This bug has been fixed in CVS. You can grab a snapshot of the CVS version at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2001-12-28 10:52:41] mfkahn2@yahoo.com 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=14735&edit=1

« previous php.bugs (#12385) next »