From: lbayuk at users dot sourceforge dot net Operating system: All PHP version: 5.4.15 Package: GD related Bug Type: Bug Bug description:Thread-safe PHP GD fails to to find TrueType font without path
Description: ------------ The $font parameter in the GD extension function imagettftext() should accept a filename without path, and per the PHP manual GD should search for that font file using a library-defined font path or GDFONTPATH environment variable. This works, but only if PHP was built without thread-safety. If PHP is built with thread safety, it is unable to find TrueType font files using the search path (GDFONTPATH or the built-in default). (I think this is happening because when ZTS is defined, VIRTUAL_DIR is defined, and that causes the GD function php_imagettftext_common() to run the font argument through VCWD_REALPATH(). That fails when the font argument is not a complete file path.) Also, if you build PHP with Apache2 (--with-apx2), you will get a thread-safe PHP if your Apache installation is configured to use the Event MPM or Worker MPM, and a non-thread-safe PHP if your Apache installation is configured to use the Pre-fork MPM. This results in the really strange situation where whether GD can find a TTF font file on the search path depends on which Apache MPM was configured when you built PHP. Test script: --------------- <?php $font = 'Arial.ttf'; // This is for Windows. Change the name for others. $im = imagecreate(600, 400); $background_color = imagecolorallocate($im, 255, 255, 255); $text_color = imagecolorallocate($im, 0, 0, 255); imagettftext($im, 14, 0, 20, 200, $text_color, $font, 'Font Test'); imagepng ($im); Expected result: ---------------- Creates a PNG image file on standard output, with the text 'Font Test'. Actual result: -------------- When using non-thread-safe PHP, the expected result. When using thread-safe PHP, a warning message, and no text is drawn: "PHP Warning: imagettftext(): Invalid font filename in ..." -- Edit bug report at https://bugs.php.net/bug.php?id=64823&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64823&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64823&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64823&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64823&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64823&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64823&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64823&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64823&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64823&r=support Expected behavior: https://bugs.php.net/fix.php?id=64823&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64823&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64823&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64823&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64823&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64823&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64823&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64823&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64823&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64823&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64823&r=mysqlcfg