%global fontconf 90-thai-scalable-synthetic

Name:           thai-scalable-fonts
Version:        0.6.5
Release:        5
Summary:        Thai TrueType fonts
License:        GPLv2+ and Bitstream Vera
URL:            http://linux.thai.net/projects/thaifonts-scalable
Source0:        http://linux.thai.net/pub/ThaiLinux/software/fonts-tlwg/fonts-tlwg-%{version}.tar.xz
Source1:        %{fontconf}-garuda.conf
Source2:        %{fontconf}-kinnari.conf
Source3:        %{fontconf}-umpush.conf
Source4:        %{fontconf}-laksaman.conf
BuildArch:      noarch
BuildRequires:  fontforge >= 20071110 fontpackages-devel

%description

Thai scalable fonts included here are:
- Kinnari, Garuda and Norasi from the National Font project
- DB Thai Text from DearBook
- TlwgMono, PseudoMono, Purisa by TLWG

%package        common
Summary:        Common files of %{name}
Requires:       fontpackages-filesystem
Provides:       thai-scalable-garuda-fonts thai-scalable-kinnari-fonts thai-scalable-loma-fonts thai-scalable-norasi-fonts thai-scalable-purisa-fonts 
Obsoletes:      thai-scalable-garuda-fonts thai-scalable-kinnari-fonts thai-scalable-loma-fonts thai-scalable-norasi-fonts thai-scalable-purisa-fonts
Provides:       thai-scalable-sawasdee-fonts thai-scalable-tlwgmono-fonts thai-scalable-tlwgtypewriter-fonts thai-scalable-tlwgtypist-fonts
Obsoletes:      thai-scalable-sawasdee-fonts thai-scalable-tlwgmono-fonts thai-scalable-tlwgtypewriter-fonts thai-scalable-tlwgtypist-fonts
Provides:       thai-scalable-tlwgtypo-fonts thai-scalable-umpush-fonts thai-scalable-laksaman-fonts thai-scalable-waree-fonts
Obsoletes:      thai-scalable-tlwgtypo-fonts thai-scalable-umpush-fonts thai-scalable-laksaman-fonts thai-scalable-waree-fonts

%description    common

This package consists of files used by other %{name} packages.

%prep
%autosetup -n fonts-tlwg-%{version} -p1

%build
%configure --with-ttfdir=%{_fontdir} --enable-ttf
%make_build

%install
install -m 0755 -d %{buildroot}%{_fontconfig_templatedir} %{buildroot}%{_fontconfig_confdir}
%make_install
rm %{buildroot}%{_datadir}/fontconfig/conf.avail/64-15-laksaman.conf
rm %{buildroot}%{_datadir}/fontconfig/conf.avail/64-*-tlwg*.conf
rm %{buildroot}%{_datadir}/fontconfig/conf.avail/89-tlwg*-synthetic.conf
install -m 0644 -p %{SOURCE1} %{buildroot}%{_datadir}/fontconfig/conf.avail/%{fontconf}-garuda.conf
install -m 0644 -p %{SOURCE2} %{buildroot}%{_datadir}/fontconfig/conf.avail/%{fontconf}-kinnari.conf
install -m 0644 -p %{SOURCE3} %{buildroot}%{_datadir}/fontconfig/conf.avail/%{fontconf}-umpush.conf
install -m 0644 -p %{SOURCE4} %{buildroot}%{_datadir}/fontconfig/conf.avail/%{fontconf}-laksaman.conf

for fconf in %{fontconf}-garuda.conf \
             %{fontconf}-kinnari.conf \
             %{fontconf}-umpush.conf \
	     %{fontconf}-laksaman.conf ; do
  ln -s %{_datadir}/fontconfig/conf.avail/$fconf \
        %{buildroot}%{_sysconfdir}/fonts/conf.d/$fconf
done

install -d 0755 -p %{buildroot}%{_datadir}/fonts/thai-scalable/
install -m 0644 -p tlwg/*.ttf %{buildroot}%{_datadir}/fonts/thai-scalable/
install -m 0644 -p nectec/*.ttf %{buildroot}%{_datadir}/fonts/thai-scalable/
install -m 0644 -p nf/*.ttf %{buildroot}%{_datadir}/fonts/thai-scalable/
rm -rf %{buildroot}%{_datadir}/fonts/thai-scalable-fonts/

%files
%defattr(-,root,root)
%doc AUTHORS README NEWS
%license COPYING

%files common
%defattr(-,root,root)
%{_sysconfdir}/fonts/conf.d/*.conf
%{_datadir}/fonts/thai-scalable/*
%{_datadir}/fontconfig/conf.avail/*.conf

%changelog
* Fri Feb 14 2020 Ling Yang <lingyang2@huawei.com> - 0.6.5-5
- Package init
