|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-03-04 22:02 UTC] public at milindur dot de
Description: ------------ Hello, I am trying to compile PHP (5.2.1 and/or 4.4.6) with bundled libgd (2.0.28) but *without* FreeType 2. Is it right that I am not allowed to use the configure-option "--enable-gd-native-ttf" in this case? If I add --enable-gd-native-ttf the function imagettftext does not work (text is not added to image). If I remove this option imagettftext works. The source of this behaviour seems to be that using --enable-gd-native-ttf enables the macro USE_GD_IMGSTRTTF. This prevents ext/gd/gd.c from executing any function to draw the string: gdImageStringFT/gdImageStringFTEx/gdImageStringTTF are not available because GD2 is used without FreeType 2. For this case gdttf should be called but --enable-gd-native-ttf / USE_GD_IMGSTRTTF prevents this. I think that this case should be avoided by the configure-script (using GD2, FreeType2 not available => refuse --enable-gd-native-ttf). Code below is from http://www.php.net/manual/de/function.imagettftext.php Reproduce code: --------------- <?php Header ("Content-type: image/gif"); $im = imagecreate (400, 30); $black = ImageColorAllocate ($im, 0, 0, 0); $white = ImageColorAllocate ($im, 255, 255, 255); ImageTTFText ($im, 20, 0, 10, 20, $white, "/path/arial.ttf", "Test"); ImageGif ($im); ImageDestroy ($im); ?> Expected result: ---------------- black box with white text Actual result: -------------- black box without text, when using --enable-gd-native-ttf with GD2 and without FreeType 2.x PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
> In short, you should really use only freetype2. Okay, but unfortunately my webhoster does not want this. He just uses freetype1 (--with-ttf). But he also uses the option --enable-gd-native-ttf. > "--enable-gd-native-ttf" > Enable gdImageStringTTF function instead of > gdImageStringFT/gdImageStringFTEx (both freetype2). Sure? I think that this option actually enforces the use of the libgd-ttf-functions (gdImageStringTTF, gdImageStringFT or gdImageStringFTEx). I looked into the configure-script. The option --enable-gd-native-ttf sets PHP_GD_NATIVE_TTF which enables "#define USE_GD_IMGSTRTTF 1". I find the macro USE_GD_IMGSTRTTF again in ext/gd/gd.c: #ifdef USE_GD_IMGSTRTTF # if HAVE_GD_STRINGFTEX if (extended) { error = gdImageStringFTEx(...); } else # endif # if HAVE_GD_STRINGFT error = gdImageStringFT(...); # elif HAVE_GD_STRINGTTF error = gdImageStringTTF(...); # endif #else /* !USE_GD_IMGSTRTTF */ error = gdttf(...); #endif If USE_GD_IMGSTRTTF is set only gdImageStringFTEx, gdImageStringFT or gdImageStringTTF would be executed. But if HAVE_GD_STRINGFTEX, HAVE_GD_STRINGFT and HAVE_GD_STRINGTTF are not set (freetype1) no code would be executed. The function gdttf provides ttf-functionality with GD2/freetype1 (as far as I understand this function) but it is not executed. > Freetype1 support is already abandoned in HEAD (php6). Right, but PHP4/5 are still widely spread. If you do not want to fix this than just tell me if I am right regarding --enable-gd-native-ttf with GD2/freetype1.