# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# File derived from a PKGBUILD from Arch with patches from Arch, Debian
# and Slackware
# Modified fo Slint by Didier Spaier didieratslintdotfr

# History:
# build 2
# symling link 70-non-bitmaps-except-emoji.conf in /etc/fonts.conf.d

pkgname=fontconfig
pkgver=2.15.0
pkgrel=2slint
pkgdesc="Library for configuring and customizing font access"
slackdesc=("fontconfig (Font library and tools)"
"Fontconfig is a library and tools designed to provide system-wide"
"font configuration, customization, and application access."
)
url=https://www.freedesktop.org/wiki/Software/fontconfig/
arch=(x86_64)
license=(custom)
depends=(
  expat
  freetype2
)
makedepends=(
  docbook-sgml
  docbook-utils
  git
  gperf
  meson
  perl-sgmls
)
provides=(fontconfig-docs)
conflicts=(fontconfig-docs)
replaces=('fontconfig-docs<2:2.13.93-1')
backup=(etc/fonts/fonts.conf)
install=fontconfig.install
_commit=72b9a48f57de6204d99ce1c217b5609ee92ece9b  # tags/2.15.0^0
source=(
"https://gitlab.freedesktop.org/fontconfig/fontconfig/-/archive/2.15.0/fontconfig-2.15.0.tar.bz2"
)
b2sums=('SKIP'
        '7fb63e76ab126bc0a7decfd74c53429ad1ce6d13de2f14037259616d8d4150b8fa4601c7f02b75918ccd5995d424816dc9d01a5fe7e39dc3dd1fcc83dfdb0fe8'
        'b06b3f2b8c0c38139a9247c26a641e6dc01d50b530478dd14133175a603f60b0af901af16c9fcf1ce73d23786ea14bfdbacd39f1dcfd88f6382965ad22be1411'
        'dfbf47c069c88da7687511356cef5bb94b7190e558a6f08390d6976fa7065ba7137ccb0a5ca1defdef655091afe74eb8a3d33fb9f3e0633409aa79f753ad276d')
validpgpkeys=(
  F77A64C4B5B45FF8763A278F65755979B34E1294  # Akira TAGOH <akira@tagoh.org>
)
docs=("AUTHORS" "COPYING" "INSTALL")
options=("nosrcpack" "noautodotnew")
pkgver() {
  cd fontconfig
  git describe --tags | se
d 's/[^-]*-g/r&/;s/-/+/g'
}
doinst(){
  # Update the X font indexes:
  if [ -x /usr/bin/fc-cache ]; then
    /usr/bin/fc-cache -f
  fi
}
build() {
  
  cd $pkgname-$pkgver
  # Patches from Debian and Fedora (the ones whose name begins in contconfig)
  while read p; do
    echo
    echo "**************** applying $p"
    patch -p1 --verbose <$startdir/patches/"$p"
  done < $startdir/patches/series
# Hardcode the default font search path rather than having fontconfig figure
# it out (and possibly follow symlinks, or index ugly bitmapped fonts):
# patch from Slackware adapted to version 2.15.0
patch -p1 --verbose --backup --suffix=.orig < $startdir/fontconfig.font.dir.list.slint.diff|| exit 1
# Prefer the Hack font for the monospace family as does solus
# Provide Slint modifications, as indicated in the patch
patch -p1 --verbose < $startdir/slint_mods.diff || exit 1
  mkdir build
  cd build || exit 1
#    -D baseconfig-dir=/etc/fonts
#    -D template-dir=
#    -D config-dir=/etc/fonts/conf.d
  CFLAGS="$SLKCFLAGS" \
  CXXFLAGS="$SLKCFLAGS" \
  meson setup \
    --buildtype=release \
    --infodir=/usr/info \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --localstatedir=/var \
    --mandir=/usr/man \
    --prefix=/usr \
    --sysconfdir=/etc \
    -D template-dir=/etc/fonts/conf.available \
    -D cache-build=disabled \
    -D default-hinting=slight \
    -D default-sub-pixel-rendering=rgb \
    -D doc-html=enabled \
    -D doc-pdf=disabled \
    -D doc-txt=disabled   
  ninja
  DESTDIR=$PKG ninja install
mkdir -p $PKG/usr/doc/${pkgname}-$pkgver
mv $PKG/usr/share/doc/$pkgname/* $PKG/usr/doc/${pkgname}-$pkgver || exit 1
rm -r $PKG/usr/share/doc || exit 1
# quote from Slackware's fontconfig.SlackBuild:
# Upstream has changed the default templatedir to /usr/share/fontconfig/conf.avail.
# This change, if accepted, would break any existing font package containing a
# conf.avail directory.  The safest thing to do is to keep things in the
# traditional location, but put a link in the new place so that font packages
# following the new standard location will work.  Let's hear it for being
# "more correct" at the expense of having things "just work"!
mkdir -p $PKG/usr/share/fontconfig
( cd $PKG/usr/share/fontconfig ; ln -sf /etc/fonts/conf.avail . )
ln -s $PKG/etc/fonts/conf.available/70-non-bitmaps-except-emoji.conf $PKG/etc/fonts/conf.d
mkdir -p $PKG/var/log/setup
cat $startdir/setup.05.fontconfig > $PKG/var/log/setup/setup.05.fontconfig
chmod 755 $PKG/var/log/setup/setup.05.fontconfig
}

