%define _fontdir %{_datadir}/fonts/%{name}

Summary:	Free Japanese Handwriting OpenType Font (mikachan_o)
Summary(ja):	フリーの手書き風日本語 OpenType フォント (みかちゃん_o)
Name:		OpenType-mikachan
Version:	9.1
Release:	4%{?_dist_release}
URL:		http://mikachan-font.com/
License:	distributable
Group:		User Interface/X
BuildArch:	noarch
Buildroot:	%{_tmppath}/%{name}-%{version}-root
BuildRequires:	lha
Requires(post):   xorg-x11-font-utils
Requires(postun): xorg-x11-font-utils

## Ver9.1 2005.02.12
## see chksrc() in %%prep
Source0:	http://mikachan.sourceforge.jp/mikachan_o.lzh
Source1:	http://mikachan.sourceforge.jp/mikachanP_o.lzh
Source2:	http://mikachan.sourceforge.jp/mikachanPB_o.lzh
Source3:	http://mikachan.sourceforge.jp/mikachanPS_o.lzh

## vine
Source10:	README.vine

Distribution:	Vine Linux
Vendor:		Project Vine

%description
Free Japanese Handwriting OpenType Font (mikachan_o)

    mikachan_o    : fixed-width fonts
    mikachan_o-P  : proportional fonts (regular)
    mikachan_o-PB : proportional fonts (bold style)
    mikachan_o-PS : proportional fonts with somewhat smaller hiragana,
                    katakana, alphabets, and numbers

It is possible to display following characters.
 - Hiragana
 - Katakana
 - Numbers
 - Alphabets
 - Symbols
 - Kanji (for education, usual, person's name, JIS Level 1/2, IBM extended)

# '
%description -l ja
フリーの手書き風日本語 OpenType フォント (みかちゃん_o) です。

    mikachan_o    : 等幅フォント
    mikachan_o-P  : プロポーショナルフォント
    mikachan_o-PB : 太字のプロポーショナルフォント
    mikachan_o-PS : ひらがな・カタカナ・数字・英字が少し小さめのプロポーショ
                    ナルフォント

次の文字を表示することができます。
 - ひらがな
 - カタカナ
 - 数字
 - 英字
 - 記号
 - 漢字 (教育/常用/人名/JIS第1水準/JIS第2水準/IBM拡張)

%prep
## check sha1sum of sources
## For any mikachan*.lzh archives, 
## its filename has no versioning informations. 
chksrc(){
    cd %_sourcedir
#ad1b8d96e20f398661a18e4ba7704881705e1e21  mikachanPB_o.lzh
    sha1sum -c --quiet - <<EOT
ad1b8d96e20f398661a18e4ba7704881705e1e21  mikachanPB_o.lzh
cca9a25cbff69fbdd1f03c7c07dae17f9bc183f0  mikachanPS_o.lzh
da5f64708e108fe97f989587abe7153a488651d0  mikachanP_o.lzh
3896763b947fd4f5510fb3348435efce15879db6  mikachan_o.lzh
EOT
    [ $? -eq 1 ] && return 1
    cd -
    return 0
}
chksrc || exit 1

%setup -n %{name}-%{version} -c -T

if `%{_bindir}/lha l --archive-kanji-code=sjis %{SOURCE0} > /dev/null 2>&1`
then
	srccode=euc-jp
else
	srccode=cp932
fi

%{_bindir}/lha xq %{SOURCE0}
%{_bindir}/lha xq %{SOURCE1}
%{_bindir}/lha xq %{SOURCE2}
%{_bindir}/lha xq %{SOURCE3}

# FIXME: convert file name (cp932 -> utf-8)
for i in *.otf ; do
	%__mv $i `echo $i \
		| %{_bindir}/iconv -f $srccode -t utf-8 \
		| %__sed -e 's/みかちゃん/mikachan/'`
done

## copy README.vine
%__cp %{SOURCE10} .

%build

%install
%__rm -rf %{buildroot}
%__mkdir -p %{buildroot}%{_fontdir}
%__install -m644 -p *.otf %{buildroot}%{_fontdir}

%post
%__font_install_post %{_fontdir}

%postun
%__font_install_postun %{_fontdir}

%clean
%__rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc README.vine
%{_fontdir}/*

%changelog
* Sun Jan 12 2014 TANAKA hiroaki <mosaicist@jcom.home.ne.jp> 9.1-4
- rebuilt with gcc-4.8

* Wed Jun 2 2011 Munehiro Yamamoto <munepi@vinelinux.org> 9.1-3
- added README.vine
- drooped Provides: mikachanfont
- checked sha1sum of sources
  - defined chksrc() in %%prep
- use %%__font_install_post, %%__font_install_postun

* Sat Jun 20 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 9.1-2vl5
- changed font path

* Sun Oct 05 2008 Shu KONNO <owa@bg.wakwak.com> 9.1-1vl5
- applied new versioning policy, spec in utf-8
- updated scripts to convert file name's encode
- changed font path

* Fri Oct 20 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 9.1-0vl2
- fix install script to support autoconfiscated lha

* Sat May 07 2005 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 9.1-0vl1
- upstream release
- fix scripts

* Sun Feb 15 2004 KAZUKI SHIMURA <rito@pos.to> 9.0-0vl1
- initial release
