php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40718 PHP with GD2 and FreeType 1.x
Submitted: 2007-03-04 22:02 UTC Modified: 2007-03-07 10:23 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: public at milindur dot de Assigned:
Status: Wont fix Package: *Configuration Issues
PHP Version: 5.2.1 OS: Linux (Ubuntu 6.10)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
12 + 14 = ?
Subscribe to this entry?

 
 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-04 22:39 UTC] pajoye@php.net
"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?"

Freetype1:
"--with-ttf=/path"
Define the prefix of freetype2

"--enable-gd-native-ttf" 
Enable gdImageStringTTF function instead of  gdImageStringFT/gdImageStringFTEx (both freetype2).


Freetype2:
--with-freetype-dir=/path
Define the prefix of freetype2

In short, you should really use only freetype2.

Freetype1 support is already abandoned in HEAD (php6).

We keep the option around as some users keep rely on the old functions. But that's all I can do, keeping them around > won't fix.
 [2007-03-07 08:51 UTC] public at milindur dot de
> 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.
 [2007-03-07 10:23 UTC] pajoye@php.net
Why don't you use freetype2?

This option was about fixing issues with old libgd versions and to always provide ttf support. It is really not something you should use unless you have a very good reason.

About freetype1, it is broken, old and unmaintained. You better have to upgrade to freetype2 instead. As soon as I can, I will drop freetype1 (or add warning in the configure) about freetype1 usage.

I'm sorry, but I do not have the time to investigate and fix this problem. I do not think it is worth the effort either :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC