Skip to content

Conversation

@petk
Copy link
Member

@petk petk commented Feb 25, 2024

This is a fix for PHP-8.2 and PHP-8.3 branches for the GH-12019 as requested in GH-12029

Probably will work fine.

- Use gdFontCacheShutdown() to detect freetype
  Currently we look for gdImageStringFT() to determine whether or not gd
  has freetype support... but that function always exists. This leads
  PHP to believe that gd has freetype support when it does not, and can
  lead to build failures.

  The gdFontCacheShutdown() function, on the other hand, is only present
  when gd was built with freetype support. Let's use that instead.

- Fix GD image format detection
  We currently check for, say, AVIF support by attempting to link a
  program that calls libgd's gdImageCreateFromAvif() function. But
  perversely, that function always exists in libgd; moreover when AVIF
  support is missing it emits a warning and returns normally. Thus
  our straightforward link test becomes not so straightforward.

  This commit adds a new macro PHP_GD_CHECK_FORMAT that compiles, links,
  and runs a test program instead. The test program overrides that "emit
  a warning" handler so that the program actually fails if the format
  we're looking for is not supported. This fixes detection of AVIF and
  the other formats we check for in an external libgd.

- ext/gd/tests/bug77391.phpt: skip if gd lacks BMP support
  I don't actually know how to remove BMP support from libgd, but PHP
  has a ./configure test for it, so we should probably treat it as
  optional.

Closes phpGH-12019
Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible and seems to work fine.

@petk
Copy link
Member Author

petk commented Feb 26, 2024

Applied to PHP-8.2 and up via f732ab8.

@petk petk closed this Feb 26, 2024
@petk petk deleted the patch-12029 branch February 26, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants