#
# spec file for package iosevka-fonts
#
# Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%global gh_v 3.0.0
%global gh_r rc.5
%global gh_f %{gh_v}-%{gh_r}

Name:		iosevka-fonts
Version:	%{gh_v}_%{gh_r}
Release:	0
License:	OFL-1.1
Summary:	Spatial efficient monospace font family for programming
Url:		https://typeof.net/Iosevka/
Group:		System/X11/Fonts
Source1:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/01-iosevka-%{gh_f}.zip
Source2:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/02-iosevka-fixed-%{gh_f}.zip
Source3:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/03-iosevka-term-%{gh_f}.zip
Source4:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/04-iosevka-slab-%{gh_f}.zip
Source5:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/05-iosevka-fixed-slab-%{gh_f}.zip
Source6:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/06-iosevka-term-slab-%{gh_f}.zip
Source7:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/07-iosevka-curly-%{gh_f}.zip
Source8:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/08-iosevka-fixed-curly-%{gh_f}.zip
Source9:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/09-iosevka-term-curly-%{gh_f}.zip
Source10:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/10-iosevka-curly-slab-%{gh_f}.zip
Source11:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/11-iosevka-fixed-curly-slab-%{gh_f}.zip
Source12:	https://github.com/be5invis/Iosevka/releases/download/v%{gh_f}/12-iosevka-term-curly-slab-%{gh_f}.zip
Source20: 	https://raw.githubusercontent.com/be5invis/Iosevka/master/LICENSE.md
Source21: 	https://raw.githubusercontent.com/be5invis/Iosevka/master/README.md
BuildRequires:	unzip
BuildRequires:	fontpackages-devel
BuildArch:	noarch
BuildRoot:	%{_tmppath}/%{name}-%{version}-build
%reconfigure_fonts_prereq

%description
Iosevka is an open-source, sans-serif + slab-serif, monospace + quasi‑proportional
typeface family, designed for writing code, using in terminals, and preparing
technical documents.

%prep
for s in %{S:1} %{S:2} %{S:3} %{S:4} %{S:5} %{S:6} %{S:7} %{S:8} %{S:9} %{S:10} %{S:11} %{S:12};
do
	%{__unzip} $s 'ttf/*';
done
%{__cp} %{S:20} %{S:21} .

%build
declare -A family=( \
		[iosevka]=Iosevka \
		[iosevka-fixed]=IosevkaFixed \
		[iosevka-term]=IosevkaTerm \
		[iosevka-slab]=IosevkaSlab \
		[iosevka-fixed-slab]=IosevkaFixedSlab \
		[iosevka-term-slab]=IosevkaTermSlab \
		[iosevka-curly]=IosevkaCurly \
		[iosevka-fixed-curly]=IosevkaFixedCurly \
		[iosevka-term-curly]=IosevkaTermCurly \
		[iosevka-curly-slab]=IosevkaCurlySlab \
		[iosevka-fixed-curly-slab]=IosevkaFixedCurlySlab \
		[iosevka-term-curly-slab]=IosevkaTermCurlySlab \
		)

declare -A variant=( \
		[bold]=Bold \
		[bolditalic]=BoldItalic \
		[boldoblique]=BoldOblique \
		[extralight]=Extralight \
		[extralightitalic]=ExtralightItalic \
		[extralightoblique]=ExtralightOblique \
		[heavy]=Heavy \
		[heavyitalic]=HeavyItalic \
		[heavyoblique]=HeavyOblique \
		[italic]=Italic \
		[light]=Light \
		[lightitalic]=LightItalic \
		[lightoblique]=LightOblique \
		[medium]=Medium \
		[mediumitalic]=MediumItalic \
		[mediumoblique]=MediumOblique \
		[oblique]=Oblique \
		[regular]=Regular \
		[thin]=Thin \
		[thinitalic]=ThinItalic \
		[thinoblique]=ThinOblique \
		[extended]=Extended \
		[extendedbold]=ExtendedBold \
		[extendedbolditalic]=ExtendedBoldItalic \
		[extendedboldoblique]=ExtendedBoldOblique \
		[extendedextrabold]=ExtendedExtrabold \
		[extendedextrabolditalic]=ExtendedExtraboldItalic \
		[extendedextraboldoblique]=ExtendedExtraboldOblique \
		[extendedextralight]=ExtendedExtralight \
		[extendedextralightitalic]=ExtendedExtralightItalic \
		[extendedextralightoblique]=ExtendedExtralightOblique \
		[extendedheavy]=ExtendedHeavy \
		[extendedheavyitalic]=ExtendedHeavyItalic \
		[extendedheavyoblique]=ExtendedHeavyOblique \
		[extendeditalic]=ExtendedItalic \
		[extendedlight]=ExtendedLight \
		[extendedlightitalic]=ExtendedLightItalic \
		[extendedlightoblique]=ExtendedLightOblique \
		[extendedmedium]=ExtendedMedium \
		[extendedmediumitalic]=ExtendedMediumItalic \
		[extendedmediumoblique]=ExtendedMediumOblique \
		[extendedoblique]=ExtendedOblique \
		[extendedsemibold]=ExtendedSemibold \
		[extendedsemibolditalic]=ExtendedSemiboldItalic \
		[extendedsemiboldoblique]=ExtendedSemiboldOblique \
		[extendedthin]=ExtendedThin \
		[extendedthinitalic]=ExtendedThinItalic \
		[extendedthinoblique]=ExtendedThinOblique \
		[extrabold]=Extrabold \
		[extrabolditalic]=ExtraboldItalic \
		[extraboldoblique]=ExtraboldOblique \
		[semibold]=Semibold \
		[semibolditalic]=SemiboldItalic \
		[semiboldoblique]=SemiboldOblique \
		)

pushd ttf/
for f in ${!family[@]};
do
	for v in ${!variant[@]};
	do
		mv $f-$v.ttf ${family[$f]}-${variant[$v]}.ttf
	done
done
popd

%install
%{__install} -d %{buildroot}%{_ttfontsdir}
%{__install} -m0644 ttf/*.ttf %{buildroot}%{_ttfontsdir}
%reconfigure_fonts_scriptlets

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc README.md
%license LICENSE.md
%{_ttfontsdir}