# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

_pkgname=freetype2
pkgname=static-compat-$_pkgname
pkgver=2.13.2
pkgrel=1
pkgdesc="Font rasterization library"
url="https://www.freetype.org/"
arch=(x86_64)
license=(GPL)
# adding harfbuzz for improved OpenType features auto-hinting
# introduces a cycle dep to harfbuzz depending on freetype wanted by upstream
depends=(
  static-compat-brotli
  static-compat-bzip2
  static-compat-harfbuzz
  static-compat-libpng
  static-compat-zlib
)
makedepends=(
  static-compat-libx11
  static-compat-meson
)
options=(staticlibs)
source=(
  https://download-mirror.savannah.gnu.org/releases/freetype/freetype-$pkgver.tar.xz{,.sig}
  0001-Enable-table-validation-modules.patch
  0002-Enable-subpixel-rendering.patch
  0003-Enable-long-PCF-family-names.patch
)
b2sums=('cebc82180d9afaeb112a65ba78903d7bf7a9295a803166a033585ad2325add6023f05066852240c4665e56285345ba503b01ecd461d48f0478a8f3f56136988e'
        'SKIP'
        '2c148694e150b3faae9dc46ead824ae6d94cfe34f2918bc9066f45bab7e6b6f77b4d4b2fee00c3d466d866e1985132cea4a774dcf1bab95409b7cf55efff01e1'
        '9598d13eae0411878c1af8e5d875c3b1fc09f4e6649edfbbf3b0a819c4c585648521f0b30ffd1318f5106cfde9c899d3db70c8ffe36dac59f3f98b5fd7dab115'
        '66deb179d1f1f4e2e35f6d50acfbacce80595d5128f5fed8c1871838c210dbf1a7173a87dd937d64997844c8f478c8f81120f71e33b9d59d980e179d103ff31c')
validpgpkeys=(
  E30674707856409FF1948010BE6C3AAC63AD8E3F  # Werner Lemberg <wl@gnu.org>
)

prepare() {
  cd freetype-$pkgver
  patch -Np1 -i ../0001-Enable-table-validation-modules.patch
  patch -Np1 -i ../0002-Enable-subpixel-rendering.patch
  patch -Np1 -i ../0003-Enable-long-PCF-family-names.patch

  # meson sucks
  sed -i 's|static: false|static: true|g' meson.build
}

build() {
  source static-compat-environment
  cd freetype-$pkgver
  static-compat-meson build -D zlib=system -D bzip2=enabled -D png=enabled -D brotli=enabled
  meson compile -C build
}

check() {
  source static-compat-environment
  cd freetype-$pkgver
  meson test -C build --print-errorlogs
}

package() {
  source static-compat-environment
  cd freetype-$pkgver
  meson install -C build --destdir="$pkgdir"
  rm -rf "${pkgdir}"/usr/static/share/
}

# vim:set sw=2 sts=-1 et:
