# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=freetype
pkgver=2.13.3
pkgrel=0
pkgdesc="TrueType font rendering library"
url="https://www.freetype.org/"
arch="all"
license="FTL OR GPL-2.0-or-later"
options="!check"
makedepends="
	brotli-dev
	bzip2-dev
	libpng-dev
	libx11-dev
	meson
	zlib-dev
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-demos
	$pkgname-doc
	"
source="
	https://download.savannah.gnu.org/releases/freetype/freetype-$pkgver.tar.xz
	https://download.savannah.gnu.org/releases/freetype/ft2demos-$pkgver.tar.xz
	pcf-family-names.patch
	subpixel.patch
	table-validation-modules.patch
	"

# secfixes:
#   2.12.1-r0:
#     - CVE-2022-27404
#     - CVE-2022-27405
#     - CVE-2022-27406
#   2.10.4-r0:
#     - CVE-2020-15999
#   2.9-r1:
#     - CVE-2018-6942
#   2.7.1-r1:
#     - CVE-2017-8105
#     - CVE-2017-8287

prepare() {
	default_prepare

	ln -sfv ../../freetype-$pkgver "$srcdir"/ft2demos-$pkgver/subprojects/freetype2
}

build() {
	abuild-meson \
		-Dfreetype2:default_library=both \
		-Dlibrsvg=disabled \
		"$srcdir"/ft2demos-$pkgver output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	install -Dm644 builds/unix/freetype2.m4 \
		-t "$pkgdir"/usr/share/aclocal
}

demos() {
	pkgdesc="A collection of FreeType demos"

	amove usr/bin
}

sha512sums="
600828d7756c8cfa974448ef34ee0db573fb8cfdb2dc1e0358b63c44a03bfd7e3d4384424b9cc5e4749034f60231a550c4b7fcb46694fcacea218787ce305504  freetype-2.13.3.tar.xz
e662a20ad2ff80534e8ea0df2f299e8f61350f13d279f80f8257b18352e863dd2c266791b85d3410b0c83966cb12e3ff49cf398b83a651dc73772df9fcf5936c  ft2demos-2.13.3.tar.xz
78ad6b1de388d3986fd5a51a7076b0a9d782733e85f400fc8c070b40e5e48130a562a67a7a9b251169b74ae052f571ea8e6b0f9435c271520d93dd72c1845d59  pcf-family-names.patch
55fb06dbc7cc950129a99d9fd5480397b3e0720f32ab65fb3893768ed40e2de27be2cfd52ec6da490f79c79b4ddfecd0b7efcd32da4a95f2666a6b67a3cd9a31  subpixel.patch
580fe59acddfd41966e387bdb6a88336b8bc119cc3d60d8689be20c96fb0dd07c5138ea31f6cb9c854f497ecb41c3adc49eb3ec16a34b2e010e8294851770763  table-validation-modules.patch
"
