# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Eric Belanger <eric@archlinux.org>
# Contributor: William Rea <sillywilly@gmail.com>

pkgname=fontforge
pkgver=20230101
pkgrel=3
pkgdesc='Outline and bitmap font editor'
url='https://fontforge.github.io/'
arch=('x86_64' 'aarch64')
license=('BSD')
makedepends=('cmake' 'git' 'python-sphinx')
depends=('libtool' 'pango' 'giflib' 'libtiff' 'libxml2' 'libspiro' 'python'
         'potrace' 'woff2' 'gtk3' 'libuninameslist')
source=("https://github.com/${pkgname}/${pkgname}/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.xz"
        fontforge-doc-no-warn-error.patch
        "fix-pofiles.patch::https://github.com/fontforge/fontforge/pull/5257/commits/55d58f87ab1440f628f2071a6f6cc7ef9626c641.patch")
sha256sums=('ca82ec4c060c4dda70ace5478a41b5e7b95eb035fe1c4cf85c48f996d35c60f8'
            'b87fa5a39d6948262d2dfb9b84c2462dc21de0bfb115cdd13e893c1b533d8f78'
            '91a2836b4ae8a572ad0cc9b867cf9313b64adbb094d416e8ba17535fc8b839b3')

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	mkdir build
	patch -Np1 -i ../fontforge-doc-no-warn-error.patch
	patch -Np1 -i ../fix-pofiles.patch
}

build() {
	cd "${srcdir}/${pkgname}-${pkgver}/build"
	cmake \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DENABLE_MAINTAINER_TOOLS=TRUE \
		-DENABLE_FONTFORGE_EXTRAS=TRUE \
		-DUNIX=TRUE \
		..

	make
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	cd build
	make DESTDIR="${pkgdir}" install
	install -Dm644 ../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
