# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=font-liberation
_fontname=${pkgname#font-}
pkgver=2.1.5
pkgrel=2
pkgdesc="Fonts to replace commonly used Microsoft Windows fonts"
url="https://github.com/liberationfonts/liberation-fonts"
license="OFL-1.1"
arch="noarch"
depends="fontconfig"
replaces="ttf-liberation<2.1.5"  # for backward compatibility (Alpine <3.16)
provides="font-times"
provider_priority=10
options="!check"
subpackages="ttf-liberation:_ttf_liberation:noarch"
# added fontconfig configuration from:
# https://github.com/bohoomil/fontconfig-ultimate/tree/master/fontconfig_patches/fonts-settings
source="https://github.com/liberationfonts/liberation-fonts/files/7261482/liberation-fonts-ttf-$pkgver.tar.gz
	30-$_fontname-mono.conf
	30-$_fontname-sans.conf
	30-$_fontname-serif.conf
	45-$_fontname.conf
	90-$_fontname.conf
	"
builddir="$srcdir/liberation-fonts-ttf-$pkgver"

package() {
	install -D -m644 ./*.ttf -t "$pkgdir"/usr/share/fonts/$_fontname/

	mkdir -p "$pkgdir"/etc/fonts/conf.d

	local i; for i in "$srcdir"/*.conf; do
		install -D -m644 "$i" -t "$pkgdir"/etc/fonts/conf.avail/
		ln -s ../conf.avail/${i##*/} "$pkgdir"/etc/fonts/conf.d/${i##*/}
	done
}

# For backward compatibility with Alpine <3.16.
_ttf_liberation() {
	pkgdesc="Deprecated name for font-liberation and font-liberation-sans-narrow"
	depends="$pkgname=$pkgver-r$pkgrel font-liberation-sans-narrow"

	mkdir -p "$subpkgdir"
}

sha512sums="
b9f178fae43c9214ba6de36c6da613fcf59bd98084058afaaa9151d00f2406942bc360430be0a8f35ea6b5529146eef371c7cf75bdd7910403d449254f943fed  liberation-fonts-ttf-2.1.5.tar.gz
585b74555132098d1d89b118b92fb843471ae2882622dec16178f8e7690fe6b5d8bf46e27e59fc3324aebfbd52a4b511d2ad77a8ddf8ef319cbe89b1a2dac91a  30-liberation-mono.conf
4983c7be59b451d9f5aec7ca0502155ca0307cc8e8e96da02de36d4b665fd45834da359131f2bc83d579e586e0f1b2158fba0036f3c7c10f6d1ff34f0407c03b  30-liberation-sans.conf
3d54b6e92159860f16fef48e342bb46badb17d43f0f818a100e5e2fb344da77d7dc999ae35a6986dbb202d4e4423a102f4e100d6f3d67a72e604538c63e44178  30-liberation-serif.conf
ced72651ec5d9067c659ad83455dd95f2cdad7e46841b23ac09a1514aea258cd0b3e2baced439742f7b1bd34a83f022b4e85507deec0724f28d62e12bf57b6d5  45-liberation.conf
124d554173d13f2e3b9d4ad7cd428354cc4bb117526074608908bb3036cf06793a04ca735570126dd5a3ee9d973100f7cc02338bd9271d6dd1b65c934de88b50  90-liberation.conf
"
