# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=cantarell-fonts
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.301
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="Humanist sans serif font (mingw-w64)"
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-appstream-glib")
license=(custom:SIL)
url="https://www.gnome.org"
source=("https://download.gnome.org/sources/${_realname}/${pkgver}/${_realname}-${pkgver}.tar.xz")
sha256sums=('3d35db0ac03f9e6b0d5a53577591b714238985f4cfc31a0aa17f26cd74675e83')

prepare() {
  cd "${srcdir}"/${_realname}-$pkgver
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}
  cp -r "../${_realname}-$pkgver/prebuilt" \
    ${srcdir}/build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="--prefix=;-Dfontsdir=" \
  ${MINGW_PREFIX}/bin/meson \
    --prefix=${MINGW_PREFIX} \
    --buildtype=plain \
    -Duseprebuilt=true \
    -Dbuildappstream=true \
    -Dfontsdir=${MINGW_PREFIX}/share/fonts/cantarell \
    "../${_realname}-${pkgver}"

  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  DESTDIR="${pkgdir}" ninja install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
