Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

PHP with GD + TTF fonts problem

Hi,

I have compiled the 'gd.so' module successfully using the osx.topicdesk.com tutorial, except 2 changes. I had to edit /usr/X11/lib/libpng.la and change '26' to '24' as described here:
http://sarth.thallos.org/search/label/libtool

And I also had to add '--with-gd=shared' to the 'configure' line.

Basic GD functionality is now working fine with the standard Apple installed PHP 5.2.6, but if I run the following PHP script, I see the following repeated many times in the error_log:

The script:
--------------------------
$width = 100;
$height = 100;
$filePNG = 'image.png';
$font_size = '29';
$font = 'monofont.ttf';
$code = 'test';


//first box
$im = ImageCreateTrueColor($width, $height);
$red = ImageColorAllocate($im, 255, 0, 0);
ImageFillToBorder($im, 0, 0, $red, $red);
imagepng($im,$filePNG);
ImageDestroy($im);

$textbox = imagettfbbox($font_size, 0, $font, $code) or die('Error in imagettfbbox function');
--------------------------

error_log
--------------------------------------------------------
[Thu Aug 14 16:22:53 2008] [notice] Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l PHP/5.2.6 configured -- resuming normal operations
THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YO U_MUST_EXEC_() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on _THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___Y OU_MUST_EXEC_() to debug.
..
.
.. same thing repeats many times
--------------------------------------------------------

Any ideas on why this would happen? If I remove the last line (the imagettfbbox call), it works fine. It seems I am missing something to do with truetype or freetype? But phpinfo() says that everything is enabled and FreeType support is enabled, Freetype Linkage is "with freetype", and Freetype Version is 2.3.5.

Intel Xeon XServe, Mac OS X (10.5.4)

Posted on Aug 14, 2008 9:15 AM

Reply
1 reply

Aug 14, 2008 3:55 PM in response to kerneljack

There is a known conflict between FreeType and Apache 2 PHP+FreeTypeGD when using TTF fonts. In essence, Core Foundation (core system calls for OS X) functions can't be used after a fork(), without using exec() immediately afterwards. Apache 2 doesn't exec() after a fork(). This sets the stage.

The problem doesn't come up until you want to use imagettfbbox(), which calls into GD's font handling routines, which uses FreeType functions...which, by default, is implemented...using Core Foundation system calls. Kaboom.

You might try the solution Bill Eccles posted a while back: http://discussions.apple.com/thread.jspa?messageID=5693097

Basically, compile FreeType without Mac extensions. Then recompile everything that depends on FreeType, using the new custom library without Core Foundation calls. You'll lose the ability to handle Mac-specific fonts, but at least it should no longer explode.

PHP with GD + TTF fonts problem

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.