%define fontname ipaexfont
%define _fontdir %{_datadir}/fonts/OpenType-%{fontname}

Name:             OpenType-%{fontname}
Summary:          IPAex Fonts - JIS X 0213:2004 compliant OpenType fonts
Summary(ja):      IPAex フォント - JIS X 0213:2004に準拠した OpenType フォント
Version:          4.01
Release:          1%{?_dist_release}
Group:            User Interface/X
Vendor:           Project Vine
Distribution:     Vine Linux

License:          IPA Font License v1.0
URL:              https://ipafont.ipa.go.jp/
Source0:          https://ipafont.ipa.go.jp/IPAexfont/IPAexfont00401.zip

BuildRoot:        %{_tmppath}/%{name}-%{version}-root
BuildArch:        noarch

BuildRequires: unzip

Requires: OpenType-%{fontname}-mincho = %{version}
Requires: OpenType-%{fontname}-gothic = %{version}
Requires: OpenType-%{fontname}-doc

%description
IPAex Fonts are JIS X 0213:2004 compliant OpenType fonts
based on TrueType outlines.

This package is meta package to install Mincho and Gothic.

%description -l ja
IPAex フォントは、JIS X 0213:2004に準拠した
TrueType アウトラインベースの OpenType フォントです。

このパッケージは明朝、ゴシック両書体をインストールするためのメタパッケージです。

#-- 明朝
%package mincho
Summary: IPAex Fonts (Mincho)
Summary(ja): IPAex フォント(明朝体)
Group: User Interface/X
Requires: OpenType-%{fontname}-doc

%description mincho
This package includes IPAex Fonts (Mincho).

%description -l ja mincho
このパッケージには IPAex フォントの明朝体フォントが含まれています。

#-- ゴシック
%package gothic
Summary: IPAex Fonts (Gothic)
Summary(ja): IPAex フォント(ゴシック体)
Group: User Interface/X
Requires: OpenType-%{fontname}-doc

%description gothic
This package includes IPAex Fonts (Gothic).

%description -l ja gothic
このパッケージには IPAex フォントのゴシック体フォントが含まれています。

%package doc
Summary: %{name} Fonts Documents
Summary(ja): %{name} フォントドキュメント
Group: User Interface/X

%description doc
This package includes important documents for IPAex Fonts
includes enduser license.

%description -l ja doc
このパッケージには IPAex フォントのライセンスを含む
ドキュメント類が含まれています。


%prep
%setup -q -n IPAexfont00401

%clean
if test -n "${RPM_BUILD_ROOT}" && test "/" != "${RPM_BUILD_ROOT}"; then
    rm -rf ${RPM_BUILD_ROOT}
fi

%build

%install
rm -rf %{buildroot}

mkdir -p $RPM_BUILD_ROOT%{_fontdir}
cp -a *.ttf $RPM_BUILD_ROOT%{_fontdir}

%post mincho
%__font_install_post %{_fontdir}

%post gothic
%__font_install_post %{_fontdir}

%posttrans mincho
update-alternatives --install \
	/usr/share/fonts/alias/TrueType/fonts-japanese-mincho.ttf \
	fonts-japanese-mincho.ttf \
	%{_fontdir}/ipaexm.ttf \
	120
if [ ! -f /usr/share/fonts/alias/TrueType/fonts-japanese-mincho.ttf ] ; then
    /sbin/update-alternatives --auto fonts-japanese-mincho.ttf
fi

%posttrans gothic
update-alternatives --install \
	/usr/share/fonts/alias/TrueType/fonts-japanese-gothic.ttf \
	fonts-japanese-gothic.ttf \
	%{_fontdir}/ipaexg.ttf \
	120
if [ ! -f /usr/share/fonts/alias/TrueType/fonts-japanese-gothic.ttf ] ; then
    /sbin/update-alternatives --auto fonts-japanese-gothic.ttf
fi

%preun mincho
if [ $1 -eq 0 ]; then
	update-alternatives --remove \
		fonts-japanese-mincho.ttf \
		%{_fontdir}/ipaexm.ttf
    /sbin/update-alternatives --auto fonts-japanese-mincho.ttf ||:
fi

%preun gothic
if [ $1 -eq 0 ]; then
	update-alternatives --remove \
		fonts-japanese-gothic.ttf \
		%{_fontdir}/ipaexg.ttf
    /sbin/update-alternatives --auto fonts-japanese-gothic.ttf ||:
fi

%postun mincho
%__font_install_postun %{_fontdir}

%postun gothic
%__font_install_postun %{_fontdir}

%files

%files mincho
%license IPA_Font_License_Agreement_v1.0.txt
%{_fontdir}/ipaexm.ttf

%files gothic
%license IPA_Font_License_Agreement_v1.0.txt
%{_fontdir}/ipaexg.ttf

%files doc
%doc IPA_Font_License_Agreement_v1.0.txt Readme_IPAexfont*.txt

%changelog
* Mon May 04 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 4.01-1
- new upstream release.
- made to use alternatives for new ghostscript structure.

* Tue Apr 26 2016 Toshiharu Kudoh <toshi.kd2@gmail.com> - 3.01-1
- new upstream release

* Sun Jan 12 2014 TANAKA hiroaki <mosaicist@jcom.home.ne.jp> 2.01-2
- rebuilt with gcc-4.8

* Thu Nov 08 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> - 2.01-1
- new upstream release

* Thu Dec 2 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.03-1
- new upstream release

* Sat Jul 3 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.02-2
- fixed document filename

* Thu May 27 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.02-1
- new upstream release

* Fri Mar 19 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.01-1
- initial build for VineSeed