Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PHP-DEV] GD 2.0.1 and FreeType 2

0 views
Skip to first unread message

Rasmus Lerdorf

unread,
Apr 13, 2001, 2:07:47 AM4/13/01
to
Wez Furlong posted a GD 2.0 patch earlier today to php-dev. Have a look
at it.

-Rasmus

On Thu, 12 Apr 2001, Brian Moon wrote:

> Hi guys,
>
> A) has anyone tried PHP and gd 2.0.1?
>
> B) If I compile gd with FreeType 2 support, do I have to compile FreeType
> into PHP?
>
> Brian Moon
> -------------------------------------------------------------------------
> Phorum Dev Team - http://phorum.org
> Making better forums with PHP
> -------------------------------------------------------------------------
>
> Look for my presentation at ApacheCon 2001.
> "Caching Dynamic Web Content to Increase Dependability and Performance"
> http://www.apachecon.com/
>
>
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-u...@lists.php.net
> For additional commands, e-mail: php-de...@lists.php.net
> To contact the list administrators, e-mail: php-lis...@lists.php.net
>


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-u...@lists.php.net
For additional commands, e-mail: php-de...@lists.php.net
To contact the list administrators, e-mail: php-lis...@lists.php.net

Brian Moon

unread,
Apr 12, 2001, 11:51:11 PM4/12/01
to

Brian Moon

unread,
Apr 13, 2001, 2:43:29 PM4/13/01
to
When compiling Apache I get:

modules/php4/libphp4.a(gd.o): In function `php_imagettftext_common':
/usr/src/apache/php4-200104131045/ext/gd/gd.c:2667: undefined reference to
`gdttf'

Brian Moon
Phorum Dev Team - Making better forums with PHP
http://phorum.org/
-------------------------------------------------------------------------

----- Original Message -----
From: "Wez Furlong" <w...@thebrainroom.com>
To: "Brian Moon" <br...@phorum.org>
Sent: Friday, April 13, 2001 5:42 AM
Subject: Re: [PHP-DEV] GD 2.0.1 and FreeType 2


> Hi Brian,


>
> > A) has anyone tried PHP and gd 2.0.1?

> Yes - me.


>
> > B) If I compile gd with FreeType 2 support, do I have to compile
FreeType
> > into PHP?

> PHP needs to be linked to any and all libraries that are used by those
libraries that you use, if you get my meaning!
> If gd has a dependency on freetype, then anything that uses that gd
library will need to be linked to freetype as well.
>
> I've attached a patch that takes care of this and enables the true color
and alpha channel code, plus a handful of line style and image brush/tile
options that have so far been missing from PHP.
>
>
./configure --with-ttf=no --with-freetype-dir --with-png-dir --with-jpeg-dir
--with-gd
>
> The --with-ttf=no is there to prevent linking against the libttf if it is
installed.
>
> Please let me know how you get on with this!
>
> --Wez.

Brian Moon

unread,
Apr 13, 2001, 3:57:44 PM4/13/01
to
Ok, first, I had to edit gdttf.c and change:

#if HAVE_LIBTTF && !defined(USE_GD_IMGSTRTTF)
to:
#if (HAVE_LIBTTF|HAVE_FREETYPE) && !defined(USE_GD_IMGSTRTTF)

Next I was getting complaints about not finding freetype.h. I edited the
configure script and fixed what I guess was a typo:

FREETYPE2_INC_DIR="$i/include/freetype/freetype2"
to
FREETYPE2_INC_DIR="$i/include/freetype2/freetype"

Then I started getting errors about freetype/config/ftheader.h not existing.

So, I hand edited config_vars.mk and added -I/usr/local/include/freetype2.

It found the file fine then.

Now I get massive parse errors.

gdttf.c:74: parse error before `TT_Engine'
gdttf.c:74: warning: no semicolon at end of struct or union
gdttf.c:75: warning: type defaults to `int' in declaration of `face'
gdttf.c:75: warning: data definition has no type or storage class
gdttf.c:76: parse error before `properties'
gdttf.c:76: warning: type defaults to `int' in declaration of `properties'
gdttf.c:76: warning: data definition has no type or storage class
gdttf.c:77: parse error before `instance'
gdttf.c:77: warning: type defaults to `int' in declaration of `instance'
gdttf.c:77: warning: data definition has no type or storage class
gdttf.c:78: parse error before `char_map_Unicode'
gdttf.c:78: warning: type defaults to `int' in declaration of
`char_map_Unicode'
gdttf.c:78: warning: data definition has no type or storage class
gdttf.c:79: parse error before `char_map_Big5'
gdttf.c:79: warning: type defaults to `int' in declaration of
`char_map_Big5'
gdttf.c:79: warning: data definition has no type or storage class
gdttf.c:80: parse error before `char_map_Roman'
gdttf.c:80: warning: type defaults to `int' in declaration of
`char_map_Roman'
gdttf.c:80: warning: data definition has no type or storage class
gdttf.c:84: parse error before `matrix'
gdttf.c:84: warning: type defaults to `int' in declaration of `matrix'
gdttf.c:84: warning: data definition has no type or storage class
gdttf.c:85: parse error before `imetrics'
gdttf.c:85: warning: type defaults to `int' in declaration of `imetrics'
gdttf.c:85: warning: data definition has no type or storage class
gdttf.c:87: parse error before `}'
gdttf.c:87: warning: type defaults to `int' in declaration of `font_t'
gdttf.c:87: warning: data definition has no type or storage class
gdttf.c:93: parse error before `TT_Engine'
gdttf.c:93: warning: no semicolon at end of struct or union
gdttf.c:94: warning: type defaults to `int' in declaration of `fontkey_t'
gdttf.c:94: warning: data definition has no type or storage class
gdttf.c:99: parse error before `TT_Glyph'
gdttf.c:99: warning: no semicolon at end of struct or union
gdttf.c:100: warning: type defaults to `int' in declaration of `metrics'
gdttf.c:100: warning: data definition has no type or storage class
gdttf.c:101: parse error before `outline'
gdttf.c:101: warning: type defaults to `int' in declaration of `outline'
gdttf.c:101: warning: data definition has no type or storage class
gdttf.c:102: parse error before `oldx'
gdttf.c:102: warning: type defaults to `int' in declaration of `oldx'
gdttf.c:102: warning: type defaults to `int' in declaration of `oldy'
gdttf.c:102: warning: data definition has no type or storage class
gdttf.c:103: parse error before `Bit'
gdttf.c:103: warning: type defaults to `int' in declaration of `Bit'
gdttf.c:103: warning: data definition has no type or storage class
gdttf.c:107: parse error before `}'
gdttf.c:107: warning: type defaults to `int' in declaration of `glyph_t'
gdttf.c:107: warning: data definition has no type or storage class
gdttf.c:113: parse error before `font_t'
gdttf.c:113: warning: no semicolon at end of struct or union
gdttf.c:114: warning: type defaults to `int' in declaration of `glyphkey_t'
gdttf.c:114: warning: data definition has no type or storage class
gdttf.c:125: parse error before `glyph_t'
gdttf.c:125: warning: no semicolon at end of struct or union
gdttf.c:126: warning: type defaults to `int' in declaration of `bitmapkey_t'
gdttf.c:126: warning: data definition has no type or storage class
gdttf.c:154: parse error before `font_t'
gdttf.c: In function `fontTest':
gdttf.c:319: `a' undeclared (first use in this function)
gdttf.c:319: (Each undeclared identifier is reported only once
gdttf.c:319: for each function it appears in.)
gdttf.c:319: parse error before `)'
gdttf.c:320: `b' undeclared (first use in this function)
gdttf.c:320: parse error before `)'
gdttf.c:325: warning: control reaches end of non-void function
gdttf.c: In function `fontFetch':
gdttf.c:330: `TT_Error' undeclared (first use in this function)
gdttf.c:330: parse error before `err'
gdttf.c:331: `a' undeclared (first use in this function)
gdttf.c:331: warning: statement with no effect
gdttf.c:332: `b' undeclared (first use in this function)
gdttf.c:332: parse error before `)'
gdttf.c:336: parse error before `)'
gdttf.c:352: `err' undeclared (first use in this function)
gdttf.c:352: warning: implicit declaration of function `TT_Open_Face'
gdttf.c:353: `TT_Err_Could_Not_Open_File' undeclared (first use in this
function)
gdttf.c:362: warning: implicit declaration of function
`TT_Get_Face_Properties'
gdttf.c:365: warning: implicit declaration of function `TT_New_Instance'
gdttf.c:370: warning: implicit declaration of function
`TT_Set_Instance_Resolutions'
gdttf.c:373: `map_found' undeclared (first use in this function)
gdttf.c:379: warning: implicit declaration of function
`TT_Set_Instance_CharSize'
gdttf.c:379: `TT_F26Dot6' undeclared (first use in this function)
gdttf.c:384: warning: implicit declaration of function
`TT_Get_Instance_Metrics'
gdttf.c:387: `n' undeclared (first use in this function)
gdttf.c:387: warning: implicit declaration of function
`TT_Get_CharMap_Count'
gdttf.c:389: `i' undeclared (first use in this function)
gdttf.c:390: warning: implicit declaration of function `TT_Get_CharMap_ID'
gdttf.c:390: `platform' undeclared (first use in this function)
gdttf.c:390: `encoding' undeclared (first use in this function)
gdttf.c:394: warning: implicit declaration of function `TT_Get_CharMap'
gdttf.c:413: `TT_Fixed' undeclared (first use in this function)
gdttf.c: In function `fontRelease':
gdttf.c:427: `a' undeclared (first use in this function)
gdttf.c:427: parse error before `)'
gdttf.c:430: warning: implicit declaration of function `TT_Done_Instance'
gdttf.c:431: warning: implicit declaration of function `TT_Close_Face'
gdttf.c: In function `glyphTest':
gdttf.c:442: `a' undeclared (first use in this function)
gdttf.c:442: parse error before `)'
gdttf.c:443: `b' undeclared (first use in this function)
gdttf.c:443: parse error before `)'
gdttf.c:448: warning: control reaches end of non-void function
gdttf.c: In function `glyphFetch':
gdttf.c:453: `a' undeclared (first use in this function)
gdttf.c:453: warning: statement with no effect
gdttf.c:454: `b' undeclared (first use in this function)
gdttf.c:454: parse error before `)'
gdttf.c:460: parse error before `)'
gdttf.c:467: warning: implicit declaration of function `TT_New_Glyph'
gdttf.c:472: `flags' undeclared (first use in this function)
gdttf.c:472: `TTLOAD_SCALE_GLYPH' undeclared (first use in this function)
gdttf.c:474: `TTLOAD_HINT_GLYPH' undeclared (first use in this function)
gdttf.c:477: `glyph_code' undeclared (first use in this function)
gdttf.c:477: warning: implicit declaration of function `TT_Char_Index'
gdttf.c:483: `err' undeclared (first use in this function)
gdttf.c:483: warning: implicit declaration of function `TT_Load_Glyph'
gdttf.c:488: warning: implicit declaration of function
`TT_Get_Glyph_Metrics'
gdttf.c:490: warning: implicit declaration of function
`TT_Get_Glyph_Outline'
gdttf.c:491: warning: implicit declaration of function
`TT_Transform_Outline'
gdttf.c:500: `cos_a' undeclared (first use in this function)
gdttf.c:501: `sin_a' undeclared (first use in this function)
gdttf.c:502: `crect' undeclared (first use in this function)
gdttf.c:518: `TT_Flow_Up' undeclared (first use in this function)
gdttf.c: In function `glyphRelease':
gdttf.c:538: `a' undeclared (first use in this function)
gdttf.c:538: parse error before `)'
gdttf.c:541: warning: implicit declaration of function `TT_Done_Glyph'
gdttf.c: In function `bitmapTest':
gdttf.c:552: `b' undeclared (first use in this function)
gdttf.c:552: parse error before `)'
gdttf.c: In function `bitmapFetch':
gdttf.c:565: `b' undeclared (first use in this function)
gdttf.c:565: parse error before `)'
gdttf.c:575: warning: implicit declaration of function `TT_Get_Glyph_Pixmap'
gdttf.c:579: warning: implicit declaration of function `TT_Get_Glyph_Bitmap'
gdttf.c: At top level:
gdttf.c:650: parse error before `font_t'
gdttf.c: In function `gdttfchar':
gdttf.c:663: `glyph' undeclared (first use in this function)
gdttf.c:663: warning: statement with no effect
gdttf.c:664: `glyphkey_t' undeclared (first use in this function)
gdttf.c:664: parse error before `glyphkey'
gdttf.c:665: `bitmapkey_t' undeclared (first use in this function)
gdttf.c:677: `font' undeclared (first use in this function)
gdttf.c:678: `next' undeclared (first use in this function)
gdttf.c:695: `glyphkey' undeclared (first use in this function)
gdttf.c:698: `fg' undeclared (first use in this function)
gdttf.c:700: parse error before `)'
gdttf.c:704: `bbox' undeclared (first use in this function)
gdttf.c:705: `advance' undeclared (first use in this function)
gdttf.c:708: `im' undeclared (first use in this function)
gdttf.c:712: `bitmapkey' undeclared (first use in this function)
gdttf.c:712: `x1' undeclared (first use in this function)
gdttf.c:713: invalid operands to binary &
gdttf.c:718: `x' undeclared (first use in this function)
gdttf.c:719: `y' undeclared (first use in this function)
gdttf.c:719: invalid operands to binary &
gdttf.c:720: `tweencolorkey' undeclared (first use in this function)
gdttf.c:748: `tweencolor' undeclared (first use in this function)
gdttf.c: In function `gdttf':
gdttf.c:764: `TT_F26Dot6' undeclared (first use in this function)
gdttf.c:764: parse error before `ur_x'
gdttf.c:766: `TT_BBox' undeclared (first use in this function)
gdttf.c:766: `bbox' undeclared (first use in this function)
gdttf.c:766: warning: statement with no effect
gdttf.c:767: parse error before `double'
gdttf.c:769: `font' undeclared (first use in this function)
gdttf.c:769: warning: statement with no effect
gdttf.c:770: `fontkey_t' undeclared (first use in this function)
gdttf.c:770: parse error before `fontkey'
gdttf.c:777: `fontCache' undeclared (first use in this function)
gdttf.c:778: warning: implicit declaration of function `TT_Init_FreeType'
gdttf.c:778: `engine' undeclared (first use in this function)
gdttf.c:787: `fontkey' undeclared (first use in this function)
gdttf.c:791: parse error before `)'
gdttf.c:795: `sin_a' undeclared (first use in this function)
gdttf.c:796: `cos_a' undeclared (first use in this function)
gdttf.c:797: `advance_x' undeclared (first use in this function)
gdttf.c:797: `advance_y' undeclared (first use in this function)
gdttf.c:799: `next' undeclared (first use in this function)
gdttf.c:801: `ch' undeclared (first use in this function)
gdttf.c:817: `x1' undeclared (first use in this function)
gdttf.c:820: `error' undeclared (first use in this function)
gdttf.c:820: `advance' undeclared (first use in this function)
gdttf.c:823: `i' undeclared (first use in this function)
gdttf.c:824: `ll_x' undeclared (first use in this function)
gdttf.c:825: `ll_y' undeclared (first use in this function)
gdttf.c:826: `ur_x' undeclared (first use in this function)
gdttf.c:827: `ur_y' undeclared (first use in this function)
make[3]: *** [gdttf.lo] Error 1
make[3]: Leaving directory `/usr/src/apache/php4-200104131045/ext/gd'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/src/apache/php4-200104131045/ext/gd'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/apache/php4-200104131045/ext'
make: *** [all-recursive] Error 1

Brian Moon
Phorum Dev Team - Making better forums with PHP
http://phorum.org/
-------------------------------------------------------------------------

----- Original Message -----
From: "Wez Furlong" <w...@thebrainroom.com>
To: "Brian Moon" <br...@phorum.org>
Sent: Friday, April 13, 2001 5:42 AM
Subject: Re: [PHP-DEV] GD 2.0.1 and FreeType 2


> Hi Brian,
>


> > A) has anyone tried PHP and gd 2.0.1?

> Yes - me.


>
> > B) If I compile gd with FreeType 2 support, do I have to compile
FreeType
> > into PHP?

> PHP needs to be linked to any and all libraries that are used by those
libraries that you use, if you get my meaning!
> If gd has a dependency on freetype, then anything that uses that gd
library will need to be linked to freetype as well.
>
> I've attached a patch that takes care of this and enables the true color
and alpha channel code, plus a handful of line style and image brush/tile
options that have so far been missing from PHP.
>
>
./configure --with-ttf=no --with-freetype-dir --with-png-dir --with-jpeg-dir
--with-gd
>
> The --with-ttf=no is there to prevent linking against the libttf if it is
installed.
>
> Please let me know how you get on with this!
>
> --Wez.
>
>

Wez Furlong

unread,
Apr 13, 2001, 8:17:02 PM4/13/01
to
On 2001-04-13 20:59:21, "Brian Moon" <br...@phorum.org> wrote:
> Ok, first, I had to edit gdttf.c and change:
>
> #if HAVE_LIBTTF && !defined(USE_GD_IMGSTRTTF)
> to:
> #if (HAVE_LIBTTF|HAVE_FREETYPE) && !defined(USE_GD_IMGSTRTTF)

OK. I was using "--enable-gd-native-ttf", so this didn't come up.

> Next I was getting complaints about not finding freetype.h. I edited the
> configure script and fixed what I guess was a typo:
>
> FREETYPE2_INC_DIR="$i/include/freetype/freetype2"
> to
> FREETYPE2_INC_DIR="$i/include/freetype2/freetype"

Yes a typo, although I could have sworn I had written it the correct way around.

> Then I started getting errors about freetype/config/ftheader.h not existing.
> So, I hand edited config_vars.mk and added -I/usr/local/include/freetype2.
> It found the file fine then.
> Now I get massive parse errors.
> gdttf.c:74: parse error before `TT_Engine'
> [snip]

Ouch. This is because gdttf.c assumes freetype 1.x.
A workaround is to use --enable-gd-native-ttf, but beware! the font size is then measured in points whereas it was previously measured in pixels - the fonts on your images will get bigger unless you adjust your PHP code.

I'm not sure what to do about this - the native GD routines look nicer (fonts are smoother). Is it worth the trouble of updating the PHP equivalent for GD 2.0 and later?

For now, I have settled on the following behaviour:

./configure
"--with-jpeg-dir" \
"--with-png-dir" \
"--with-freetype-dir" \
"--with-gd"

If freetype2 is found, --with-ttf=no and --enable-gd-native-ttf are assumed.

This is going into CVS as we speak.

Brian Moon

unread,
Apr 17, 2001, 2:02:45 PM4/17/01
to
I found libgd.a from an old version just after sending this email.

So, all compiles and runs without error now. I just don't get an image.

Have you actually produced an image with this?

Brian Moon
Phorum Dev Team - Making better forums with PHP
http://phorum.org/
-------------------------------------------------------------------------

----- Original Message -----
From: "Wez Furlong" <w...@thebrainroom.com>
To: "Brian Moon" <br...@phorum.org>
Cc: <php...@lists.php.net>; "Wez Furlong" <w...@thebrainroom.com>
Sent: Tuesday, April 17, 2001 11:48 AM
Subject: Re: [PHP-DEV] GD 2.0.1 and FreeType 2


> On 2001-04-17 15:47:09, "Brian Moon" <br...@phorum.org> wrote:
> > Everything compiles fine. However, now I get this when calling
> > ImageTTFBBox:
> >
> > <b>Warning</b>: libgd was not built with TrueType font support
> >
> > I simply installed gd and FreeType per their instructions with no
problems.
> > Any ideas?
>
> That message comes from gd, but not from GD 2.0, so I would guess that PHP
linked to your old gd library.
>
> Try using --with-gd=/path/to/gd2
>
> where libgd.so lives in /path/to/gd2/lib, or alternatively, remove the
older gd library from your system (if it's a shared lib, make sure that
nothing else is dynamically linked to it first!).
>
> The sheer variety of places where gd gets installed makes it difficult to
pick a particular version if you have more than one installed :-/

Chris Adams

unread,
Apr 17, 2001, 4:58:15 PM4/17/01
to

On 17 Apr 2001 11:02:45 -0700, Brian Moon <br...@phorum.org> wrote:
>I found libgd.a from an old version just after sending this email.
>
>So, all compiles and runs without error now. I just don't get an image.
>
>Have you actually produced an image with this?

It worked fine in a quick test script I ran but I haven't had time to work with
it further (I'm working on a wvware extension and was planning on some GD work
when I got tired of Word).

Wez Furlong

unread,
Apr 17, 2001, 1:01:15 PM4/17/01
to
On 2001-04-17 15:47:09, "Brian Moon" <br...@phorum.org> wrote:
> Everything compiles fine. However, now I get this when calling
> ImageTTFBBox:
>
> <b>Warning</b>: libgd was not built with TrueType font support
>
> I simply installed gd and FreeType per their instructions with no problems.
> Any ideas?

That message comes from gd, but not from GD 2.0, so I would guess that PHP linked to your old gd library.

Try using --with-gd=/path/to/gd2

where libgd.so lives in /path/to/gd2/lib, or alternatively, remove the older gd library from your system (if it's a shared lib, make sure that nothing else is dynamically linked to it first!).

The sheer variety of places where gd gets installed makes it difficult to pick a particular version if you have more than one installed :-/

--Wez.


Wez Furlong

unread,
Apr 17, 2001, 5:41:12 PM4/17/01
to
On 2001-04-17 19:04:31, "Brian Moon" <br...@phorum.org> wrote:
> I found libgd.a from an old version just after sending this email.
> So, all compiles and runs without error now. I just don't get an image.
> Have you actually produced an image with this?

Yes, although I did find a couple of problems related to transparency and the new alpha channel code (I've submitted the fixes back to the GD author).

Could I see your PHP code?

Brian Moon

unread,
Apr 17, 2001, 10:45:38 AM4/17/01
to
Ok, I got latest CVS and tried again with:

./configure --with-apache=/usr/src/apache/apache_1.3.19 \
--with-gd \
--enable-gd-native-ttf \
--with-ttf=no \
--with-freetype-dir \
--with-png-dir=/usr/local \
--with-jpeg-dir=/usr/local \
--with-mysql=/usr \
--enable-debug --enable-track-vars=yes \
--with-zlib --with-bz2=/usr --disable-display-source \
--enable-sockets --with-imap

Everything compiles fine. However, now I get this when calling
ImageTTFBBox:

<b>Warning</b>: libgd was not built with TrueType font support

I simply installed gd and FreeType per their instructions with no problems.
Any ideas?

Brian Moon


Phorum Dev Team - Making better forums with PHP
http://phorum.org/
-------------------------------------------------------------------------

----- Original Message -----
From: "Wez Furlong" <w...@thebrainroom.com>
To: "Brian Moon" <br...@phorum.org>
Cc: <php...@lists.php.net>
Sent: Friday, April 13, 2001 7:26 PM
Subject: Re: [PHP-DEV] GD 2.0.1 and FreeType 2

0 new messages