Skip to content

ext/gd/tests/gh17373.phpt fails without freetype support in gd #17891

Closed
@orlitzky

Description

@orlitzky

Description

The new test in ext/gd/tests/gh17373.phpt can fail if gd (bundled or otherwise) does not have freetype support:

---- EXPECTED OUTPUT
int(0)
---- ACTUAL OUTPUT
Fatal error: Uncaught Error: Call to undefined function imagefttext() in /home/mjo/src/php-src.git/ext/gd/tests/gh17373.php:7
Stack trace:
#0 {main}
  thrown in /home/mjo/src/php-src.git/ext/gd/tests/gh17373.php on line 7
---- FAILED

For the bundled gd, there is the constant HAVE_GD_FREETYPE, but from config.m4 I infer that it probably only works with the bundled gd. Fixing it for the system gd is going to be a headache, because (much like png, webp, etc) libgd defines the associated freetype functions whether they work or not. For example,

#ifndef HAVE_LIBFREETYPE
...
BGD_DECLARE(char *) gdImageStringFT (gdImagePtr im, int *brect, int fg, const char *fontlist,
                                     double ptsize, double angle, int x, int y, const char *string)
{
	(void)im;
	(void)brect;
	(void)fg;
        (void)fontlist;
        (void)ptsize;
	(void)angle;
	(void)x;
	(void)y;
        (void)string;

        return "libgd was not built with FreeType font support\n";
}

We already have one clever autoconf macro for a similar purpose (image format detection), but the naming scheme and return value are different in this case.

PHP Version

git head

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions