# This is taken from the msttcorefonts spec file as distributed from
# http://corefonts.sourceforge.net/. Use it and enjoy!
# corefonts@resare.com
#
# Original packager: Daniel Resare <corefonts@resare.com>
#
# Modified for QiLinux by Silvan Calarco <silvan.calarco@qilinux.it>
# Modified by Davide Madrisan <davide.madrisan@qilinux.it>

# No ttmkfdir required with XFree 4.3

%define fontdir %{_datadir}/fonts/%{name}
%define name msttcorefonts

Name:          %{name}
Version:       @SRPMVERSION@
Release:       @SRPMRELEASE@
Summary:       TrueType core fonts for the web
Group:         Graphical Desktop/Fonts
Vendor:        @vendor@
Distribution:  @distribution@
Packager:      Silvan Calarco <silvan.calarco@mambasoft.it>
URL:           http://corefonts.sourceforge.net/
Source:        LICENSE
License:       Spec file is GPL, binary rpm is gratis but non-distributable
BuildPrereq:   wget, cabextract
PreReq:        /usr/bin/fc-cache
# BuildPrereq: %{ttmkfdir}
BuildArch:     noarch
BuildRoot:     %{_tmppath}/%{name}-%{version}-root

%description
The TrueType core fonts for the web that was once available from http://www.microsoft.com/typography/fontpack/. The src rpm is cleverly constructed so that the actual fonts are downloaded from Sourceforge's site at build time. Therefore this package technically does not 'redistribute' the fonts, it just makes it easy to install them on a linux system.

%prep
rm -rf %{name}
mkdir %{name}
cd %{name}
fonts='
   andale32.exe
   webdin32.exe
   trebuc32.exe
   georgi32.exe
   verdan32.exe
   comic32.exe
   arialb32.exe
   impact32.exe
   arial32.exe
   times32.exe
   courie32.exe'

[ -r /etc/sysconfig/@sysconfigfile@ ] && . /etc/sysconfig/@sysconfigfile@

# best effort
[ "$MSTTCF_URL" ] || \
   MSTTCF_URL="http://easynews.dl.sourceforge.net/sourceforge/corefonts"

for i in $fonts; do
   wget -nv --timeout=10 --tries=2 ${MSTTCF_URL}/$i 2>&1
done

[ "${HAS_MS_LICENSE}" = "yes" ] &&
   wget -nv --timeout=10 --tries=2 \
http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/EN-US/IELPKTH.CAB

%build
cd %{name}
install -d %{name}/cab-contents
for i in *.exe *.CAB; do
   [ -f $i ] && cabextract --lowercase --directory=cab-contents $i
done

install -d fonts
cd fonts
cp ../cab-contents/*.ttf .
# %{ttmkfdir} > fonts.dir

%install
[ "%{buildroot}" != / ] && rm -rf %{buildroot}
cd %{name}/fonts
install -d %{buildroot}%{fontdir}
cp *.ttf %{buildroot}%{fontdir}

%clean
[ "%{buildroot}" != / ] && rm -rf %{buildroot}

%post
/usr/bin/fc-cache
exit 0

%postun
/usr/bin/fc-cache
exit 0

%files
%attr(-,root,root) %{fontdir}
%dir %{fontdir}

%changelog
* Wed Jun 01 2011 Silvan Calarco <silvan.calarco@mambasoft.it> 1.3-7mamba
- retry times raised to 5
- replace use of wget with curl

* Fri Feb 02 2007 Davide Madrisan <davide.madrisan@qilinux.it> 1.3-6qilnx
- get download parameters from a sysconfig file

* Tue May 03 2005 Silvan Calarco <silvan.calarco@qilinux.it> 1.3-5qilnx
- added LICENSE file

* Mon Feb 23 2004 Davide Madrisan <davide.madrisan@qilinux.it> 1.3-4qilnx
- added missing preun script

* Mon Oct 03 2003 Silvan Calarco <silvan.calarco@qilinux.it> 1.3-3qilnx
- removed XFree configuration (these fonts are handled now by fontconfig)

* Wed Oct 01 2003 Davide Madrisan <davide.madrisan@qilinux.it> 1.3-2qilnx
- wget commands modified to avoid verbose output

* Mon Jul 14 2003 Silvan Calarco <silvan.calarco@qinet.it> 1.3-1qilnx
- first build for QiLinux

* Mon Mar 31 2003 Daniel Resare <noa@resare.com> 1.3-4
- updated microsoft link
- updated sourceforge mirrors

* Mon Nov 25 2002 Daniel Resare <noa@resare.com> 1.3-3
- the install dir is now deleted when the package is uninstalled
- executable permission removed from the fonts
- executes fc-cache after install if it is available

* Thu Nov 07 2002 Daniel Resare <noa@resare.com> 1.3-2
- Microsoft released a new service-pack. New url for Tahoma font.

* Thu Oct 24 2002 Daniel Resare <noa@resare.com> 1.3-1
- removed python hack
- removed python hack info from description
- made tahoma inclusion depend on define
- added some info on the ttmkfdir define

* Tue Aug 27 2002 Daniel Resare <noa@resare.com> 1.2-3
- fixed spec error when tahoma is not included 

* Tue Aug 27 2002 Daniel Resare <noa@resare.com> 1.2-2
- removed tahoma due to unclear licensing
- parametrized ttmkfdir path (for mandrake users)
- changed description text to reflect the new microsoft policy

* Thu Aug 15 2002 Daniel Resare <noa@resare.com> 1.2-1
- changed distserver because microsoft no longer provides them

* Tue Apr 09 2002 Daniel Resare <noa@resare.com> 1.1-3
- fixed post/preun script to actually do what they were supposed to do

* Tue Mar 12 2002 Daniel Resare <noa@resare.com> 1.1-2
- removed cabextact from this package
- added tahoma font from ie5.5 update

* Fri Aug 25 2001 Daniel Resare <noa@metamatrix.se>
- initial version
