From 3daafa0b0ecdd46d2d8a0bc0acca9becc5536f85 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 18 Mar 2023 21:40:07 +0800 Subject: [PATCH] add freetype support for gd --- config/ext.json | 4 +-- config/lib.json | 10 ++++++ config/source.json | 9 +++++ src/SPC/builder/Extension.php | 5 +++ src/SPC/builder/macos/library/freetype.php | 38 ++++++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/macos/library/freetype.php diff --git a/config/ext.json b/config/ext.json index a67abd14..4c85461d 100644 --- a/config/ext.json +++ b/config/ext.json @@ -75,11 +75,11 @@ "libwebp", "libjpeg", "xpm", - "libfreetype" + "freetype" ], "lib-depends-windows": [ "libiconv", - "libfreetype", + "freetype", "libjpeg", "zlib", "libpng", diff --git a/config/lib.json b/config/lib.json index 0cbfaa51..d7373c48 100644 --- a/config/lib.json +++ b/config/lib.json @@ -215,6 +215,16 @@ "libmcrypt.a" ] }, + "freetype": { + "source": "freetype", + "static-libs-unix": [ + "libfreetype.a" + ], + "headers-unix": [ + "freetype2/freetype/freetype.h", + "freetype2/ft2build.h" + ] + }, "nghttp2": { "source": "nghttp2", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index fd9f8871..f9d5ddd3 100644 --- a/config/source.json +++ b/config/source.json @@ -35,6 +35,15 @@ "path": "LICENSE" } }, + "freetype": { + "type": "filelist", + "url": "https://download.savannah.gnu.org/releases/freetype/", + "regex": "/href=\"(?freetype-(?[^\"]+)\\.tar\\.xz)\"/", + "license": { + "type": "file", + "path": "LICENSE.TXT" + } + }, "gmp": { "type": "filelist", "url": "https://gmplib.org/download/gmp/", diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index ec4c0777..624eb03e 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -216,6 +216,11 @@ class Extension 'CURL_LIBS="' . $this->getLibFilesString() . '" '; break; case 'gd': + if ($this->builder->getLib('freetype')) { + $arg .= ' --with-freetype ' . + 'FREETYPE2_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '/freetype2" ' . + 'FREETYPE2_LIBS="' . $this->getLibFilesString() . '" '; + } $arg .= ' ' . 'PNG_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '" ' . 'PNG_LIBS="' . $this->getLibFilesString() . '" '; diff --git a/src/SPC/builder/macos/library/freetype.php b/src/SPC/builder/macos/library/freetype.php new file mode 100644 index 00000000..49cfb7b9 --- /dev/null +++ b/src/SPC/builder/macos/library/freetype.php @@ -0,0 +1,38 @@ +builder->getLib('libpng') instanceof MacOSLibraryBase) ? ('--with-png=' . BUILD_ROOT_PATH) : '--without-png'; + $suggested .= ' '; + $suggested .= ($this->builder->getLib('bzip2') instanceof MacOSLibraryBase) ? ('--with-bzip2=' . BUILD_ROOT_PATH) : '--without-bzip2'; + $suggested .= ' '; + $suggested .= ($this->builder->getLib('brotli') instanceof MacOSLibraryBase) ? ('--with-brotli=' . BUILD_ROOT_PATH) : '--without-brotli'; + $suggested .= ' '; + + f_passthru( + $this->builder->set_x . ' && ' . + "cd {$this->source_dir} && " . + "{$this->builder->configure_env} ./configure " . + '--enable-static --disable-shared --without-harfbuzz ' . + $suggested . + '--prefix= && ' . // use prefix=/ + 'make clean && ' . + "make -j{$this->builder->concurrency} && " . + 'make install DESTDIR=' . $destdir + ); + } +}