%define tlversion	2017

%define hirapropver	0.3
%define kokanaver	1.0b2
%define otfver		1.7
%define otfbetaver	b6

%define texmf		%{_tl_texmfvine}
%define texvf		%{texmf}/fonts/vf/public
%define texofm		%{texmf}/fonts/ofm/public
%define textfm		%{texmf}/fonts/tfm/public
%define mapdir		%{texmf}/fonts/map/dvipdfmx
%define build_texmf	%{buildroot}%{texmf}
%define build_texvf	%{buildroot}%{texvf}
%define build_texofm	%{buildroot}%{texofm}
%define build_textfm	%{buildroot}%{textfm}
%define build_mapdir	%{buildroot}%{mapdir}


Summary: TeX Live macro packages for "VF for OpenType Fonts" by S. Saito
Summary(ja): TeX Live で使うマクロパッケージ (齋藤修三郎氏による「OpenType Font用VF」)
Name: texmacro-otf
Version: %{otfver}
Release: 9%{?otfbetaver:.%otfbetaver}%{?_dist_release}

Source0: http://psitau.kitunebi.com/otf%{version}%{?otfbetaver:%otfbetaver}.zip
#Source1: http://psitau.at.infoseek.co.jp/hiraprop.zip
Source1: hiraprop-%{hirapropver}.tar.bz2
#Source2: http://psitau.at.infoseek.co.jp/kokana.zip
Source2: kokana-%{kokanaver}.tar.bz2

Source3: http://psitau.at.infoseek.co.jp/otfmanual.pdf
Source4: http://psitau.at.infoseek.co.jp/kitunetuki.pdf
Source5: http://psitau.at.infoseek.co.jp/meijinden.pdf

URL: http://psitau.kitunebi.com/otf.html
License: BSD
Group:  Applications/Publishing
BuildRequires: texlive-vtlpkg = %{tlversion}
BuildRequires: texlive-common = %{tlversion}
BuildRequires: perl, nkf
Requires:     texlive-common = %{tlversion}
Requires:     ghostscript
## NOTE: texlive-collection-langcjk-2012 has otf.sty: 
## /usr/share/texmf-dist/tex/platex/japanese-otf-uptex/otf.sty
Requires:     texlive-collection-langcjk = %{tlversion}

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

Obsoletes: texlive-texmacro-otf <= 1.5.6.1

Distribution: Vine Linux
Vendor:       Project Vine

%description
TeX Live macro packages of VF for OpenType Fonts by SAITO Shuzaburo
Users can use these macros on platex.
Including
	hiraprop.sty ajmacros.sty mlcid.sty mlutf.sty otf.sty
	otfaltkana.sty redeffont.sty

%description -l ja
齋藤修三郎氏作成の TeX Live で用いる追加マクロパッケージです。
LaTeX(pLaTeX2e)でOpen Type Fontを有効に利用するための 
VF およびスタイルファイルです。
platex 上で利用できます。
以下のマクロが含まれています。
	hiraprop.sty ajmacros.sty mlcid.sty mlutf.sty otf.sty
	otfaltkana.sty redeffont.sty

%prep
%setup -q -c -n %{name}-%{version} -a 1 -a 2

## 
(cd otfbeta
    chmod +x makeotf
    %__sed -i -e "s/ovp2ovf/wovp2ovf/" mkjvf && chmod +x mkjvf || exit 1
    for x in script/*.pl; do 
    	%__sed -i -e "s/ovp2ovf/wovp2ovf/" $x && chmod +x $x || exit 1
    done
)

## rename from pltotf to ppltotf
%__sed -i -e "s,^pltotf,ppltotf,g" kokana-%{kokanaver}/makealtkana || exit 1

%build

###### otf #####
(cd otfbeta
./makeotf
)

###### kokana #####
pushd kokana-%{kokanaver}
nkf -be basepl/base-h.pl > base-h.pl
nkf -be basepl/base-v.pl > base-v.pl
%__mv -f base-[hv].pl basepl
./makealtkana
popd

%install
%__rm -rf %{buildroot}

%__mkdir_p fontmap test pdf
%__mkdir_p %{buildroot}%{_bindir}
%__mkdir_p %{build_texmf}/tex/platex/japanese-otf
%__mkdir_p %{build_texvf}/japanese-otf
%__mkdir_p %{build_textfm}/japanese-otf
%__mkdir_p %{build_mapdir}/japanese-otf

%__install -m 644 %{SOURCE3} %{SOURCE4} %{SOURCE5} pdf

###### otfstable #####
(cd otfbeta
# %__install -m 644 sty/* %{build_texmf}/tex/platex/japanese-otf
# %__install -m 644 vf/* %{build_texvf}/japanese-otf
# %__install -m 644 tfm/* %{build_textfm}/japanese-otf

%__install -m 644 readme.txt ../readme-otf.txt
%__install -m 644 test/*.tex ../test
)

###### hiraprop #####
%__mkdir_p %{build_texmf}/tex/platex/hiraprop
%__mkdir_p %{build_texvf}/hiraprop
%__mkdir_p %{build_texofm}/hiraprop
%__mkdir_p %{build_textfm}/hiraprop

pushd hiraprop-%{hirapropver}
%__install -m 644 sty/* %{build_texmf}/tex/platex/hiraprop
%__install -m 644 vf/hiraprop/* %{build_texvf}/hiraprop
%__install -m 644 ofm/hiraprop/* %{build_texofm}/hiraprop
%__install -m 644 tfm/hiraprop/* %{build_textfm}/hiraprop

%__install -m 644 *.tex ../test
%__install -m 644 readme.txt ../readme-hiraprop.txt
popd

###### kokana #####
pushd kokana-%{kokanaver}
%__install -m 644 otfaltkana.sty %{build_texmf}/tex/platex/japanese-otf
%__install -m 644 vf/* %{build_texvf}/japanese-otf
%__install -m 644 tfm/* %{build_textfm}/japanese-otf

%__install -m 644 sample/kokanatest.tex ../test
%__install -m 644 readme.txt ../readme-kokana.txt
popd


## remove duplicated files 
%__rm -f \
      %{build_texmf}/fonts/ofm/public/japanese-otf/hirakaku-w3-h.ofm \
      %{build_texmf}/fonts/ofm/public/japanese-otf/hirakaku-w6-h.ofm \
      %{build_texmf}/fonts/ofm/public/japanese-otf/hiramaru-w4-h.ofm \
      %{build_texmf}/fonts/ofm/public/japanese-otf/hiramin-w3-h.ofm \
      %{build_texmf}/fonts/ofm/public/japanese-otf/hiramin-w6-h.ofm \
      %{build_texmf}/fonts/tfm/public/japanese-otf/hirakaku-w3-h.tfm \
      %{build_texmf}/fonts/tfm/public/japanese-otf/hirakaku-w6-h.tfm \
      %{build_texmf}/fonts/tfm/public/japanese-otf/hiramaru-w4-h.tfm \
      %{build_texmf}/fonts/tfm/public/japanese-otf/hiramin-w3-h.tfm \
      %{build_texmf}/fonts/tfm/public/japanese-otf/hiramin-w6-h.tfm \
      || exit 1


%post
%_tl_touch_run texhash
#% _tl_touch_run updmap
exit 0

%postun
if [ "$1" = 0 ]; then
   %_tl_touch_run texhash
   #% _tl_touch_run updmap
fi
exit 0

%posttrans
%{_tl_exec_texhash}
#% {_tl_exec_updmap}
exit 0


%clean
%__rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc readme* fontmap test pdf
%{texmf}/tex/platex/japanese-otf
%{texmf}/tex/platex/hiraprop
%{texvf}
%{textfm}
%{texofm}
# %{mapdir}/japanese-otf


%changelog
* Sun Jun 18 2017 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-9.b6
- TeX Live 2017

* Thu Apr 28 2016 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-8.b6
- TeX Live 2016

* Tue Apr 28 2015 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-7.b6
- TeX Live 2015

* Sun May 25 2014 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-6.b6
- updated to 1.7b6
- TeX Live 2014

* Sat Aug 24 2013 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-5.b5
- TeX Live 2013

* Sat Nov 24 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-4.b5
- TeX Live 2012
- add Requires: texlive-collection-langcjk
  - it contains otf packages v1.7b5

* Sun Apr 15 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-3.b5
- updated to 1.7b5

* Sun Dec  4 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-2.b3
- defined %%exec_texhash

* Sat Nov 26 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.7-1.b3
- new upstream release
  - changed Url, License tags
- TeX Linux 2011
 
* Mon May 23 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.5.6.1-4
- fixed updmap-otf
  - changed $$MAPDIR to $${TEXMF}/fonts/map/dvipdfm/otf

* Sat Apr 16 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.5.6.1-3
- changed %%mapdir to %%{texmf}/fonts/map/dvipdfm/otf

* Sat Jan 15 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.5.6.1-2
- added Obsoletes: texlive-texmacro-otf <= 1.5.6.1
  - for TeX Live 2009 of VinePlus/5, supported texlive-texmacro-otf

* Sat Jul 03 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.5.6.1-1
- new upstream release
- TeX Linux 2009

* Fri May 15 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.2.9-3
- added otf-ps-morisawax{-noEmbed}.map

* Sun Mar 29 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.2.9-2
- spec in utf8

* Tue Aug 05 2008 KOBAYASHI Taizo <tkoba@vinelinux.org> 1.2.9-1
- applied new versioning policy

* Sun Apr 07 2007 KOBAYASHI Taizo <tkoba@vinelinux.org> 1.2.9-0vl1
- new upstream release

* Sat May 27 2006 KOBAYASHI Taizo <tkoba@vinelinux.org> 1.2.7.1-0vl2
- updmap-otf v0.9: use noEmbed.map instead of noEmbeddedFont.map

* Fri May 12 2006 KOBAYASHI Taizo <tkoba@vinelinux.org> 1.2.7.1-0vl1
- resync with ptetex3-20060506

* Sun Nov 06 2005 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.7-0vl3
- resync with ptetex3-20051102

* Wed Aug 31 2005 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.7-0vl2
- resync with ptetex3-20050830

* Sat Jun 18 2005 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.7-0vl1
- source update
- modified for teTeX3

* Thu Feb 03 2005 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.6-0vl1
- source update

* Thu Jan 20 2005 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.5-0vl1
- source update

* Sun Nov 07 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.4-0vl5
- updmap-0.7

* Mon Oct 18 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.4-0vl4
- updmap-0.6

* Mon Oct 11 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.4-0vl3
- updmap-0.5

* Thu Sep 30 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.4-0vl2
- fixed updmap

* Thu Sep 30 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.4-0vl1
- source update
- updmap-0.4

* Thu Apr 08 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.2-0vl4
- update updmap-otf: take over before setting in "auto" target
- remove requires texmacro-sfujita

* Sat Apr 03 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.2-0vl3
- fix postun

* Fri Apr 02 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.2-0vl2
- drop extrafonts and added hiraprop
- update updmap-otf and *-udvips.map

* Sun Mar 28 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.2.2-0vl1
- source update
- added updmap-otf

* Wed Feb 04 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.0.9-0vl1
- first release
