\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{chise}[2003/03/03 v.0.1 (Omega/CHISE Team)]
% based on mulambda and omega-japanese
\RequirePackage{omega}
\RequirePackage[UT1]{fontenc}

\newif\if@gbfont\@gbfontfalse
\newif\if@cnsfont\@cnsfontfalse
\newif\if@jisfont\@jisfontfalse
\newif\if@ksfont\@ksfontfalse

\DeclareOption{gbfont}{
  \@gbfonttrue
}
\DeclareOption{cnsfont}{
  \@cnsfonttrue
}
\DeclareOption{jisfont}{
  \@jisfonttrue
}
\DeclareOption{ksfont}{
  \@ksfonttrue
}

\DeclareOption{utf8mcs}{
  \if@gbfont
    \externalocp\OCPuniGB=Utf8mcsToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
  \else\if@cnsfont
    \externalocp\OCPuniCNS=Utf8mcsToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
  \else\if@jisfont
    \externalocp\OCPuniJIS=Utf8mcsToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
  \else\if@ksfont
    \externalocp\OCPuniKS=Utf8mcsToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \else
    \externalocp\OCPuniGB=Utf8mcsToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
    \externalocp\OCPuniCNS=Utf8mcsToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
    \externalocp\OCPuniJIS=Utf8mcsToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
    \externalocp\OCPuniKS=Utf8mcsToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \fi\fi\fi\fi
}
\DeclareOption{utf8gb}{
  \if@gbfont
    \externalocp\OCPuniGB=Utf8gbToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
  \else\if@cnsfont
    \externalocp\OCPuniCNS=Utf8gbToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
  \else\if@jisfont
    \externalocp\OCPuniJIS=Utf8gbToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
  \else\if@ksfont
    \externalocp\OCPuniKS=Utf8gbToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \else
    \externalocp\OCPuniGB=Utf8gbToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
    \externalocp\OCPuniCNS=Utf8gbToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
    \externalocp\OCPuniJIS=Utf8gbToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
    \externalocp\OCPuniKS=Utf8gbToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \fi\fi\fi\fi
}
\DeclareOption{utf8cns}{
  \if@gbfont
    \externalocp\OCPuniGB=Utf8cnsToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
  \else\if@cnsfont
    \externalocp\OCPuniCNS=Utf8cnsToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
  \else\if@jisfont
    \externalocp\OCPuniJIS=Utf8cnsToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
  \else\if@ksfont
    \externalocp\OCPuniKS=Utf8cnsToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \else
    \externalocp\OCPuniGB=Utf8cnsToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
    \externalocp\OCPuniCNS=Utf8cnsToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
    \externalocp\OCPuniJIS=Utf8cnsToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
    \externalocp\OCPuniKS=Utf8cnsToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \fi\fi\fi\fi
}
\DeclareOption{utf8jis}{
  \if@gbfont
    \externalocp\OCPuniGB=Utf8jisToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
  \else\if@cnsfont
    \externalocp\OCPuniCNS=Utf8jisToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
  \else\if@jisfont
    \externalocp\OCPuniJIS=Utf8jisToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
  \else\if@ksfont
    \externalocp\OCPuniKS=Utf8jisToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \else
    \externalocp\OCPuniGB=Utf8jisToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
    \externalocp\OCPuniCNS=Utf8jisToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
    \externalocp\OCPuniJIS=Utf8jisToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
    \externalocp\OCPuniKS=Utf8jisToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \fi\fi\fi\fi
}
\DeclareOption{utf8ks}{
  \if@gbfont
    \externalocp\OCPuniGB=Utf8ksToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
  \else\if@cnsfont
    \externalocp\OCPuniCNS=Utf8ksToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
  \else\if@jisfont
    \externalocp\OCPuniJIS=Utf8ksToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
  \else\if@ksfont
    \externalocp\OCPuniKS=Utf8ksToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \else
    \externalocp\OCPuniGB=Utf8ksToUniGB {}
    \ocplist\uniGB=
      \addbeforeocplist 1 \OCPuniGB
      \nullocplist
    \externalocp\OCPuniCNS=Utf8ksToUniCNS {}
    \ocplist\uniCNS=
      \addbeforeocplist 1 \OCPuniCNS
      \nullocplist
    \externalocp\OCPuniJIS=Utf8ksToUniJIS {}
    \ocplist\uniJIS=
      \addbeforeocplist 1 \OCPuniJIS
      \nullocplist
    \externalocp\OCPuniKS=Utf8ksToUniKS {}
    \ocplist\uniKS=
      \addbeforeocplist 1 \OCPuniKS
      \nullocplist
  \fi\fi\fi\fi
}

\ocp\CJKbreak=cjkbreak
%% \ocplist\CJKadjust=
%%    \addbeforeocplist 1 \CJKbreak
%%    \nullocplist
\def\cjkglue{\hskip 0pt plus 1pt minus .5pt}

\ocp\OCPutf=inutf8
\ocplist\inutf
  \addbeforeocplist 1 \OCPutf
  \nullocplist
\AtBeginDocument{
%  \DefaultInputMode onebyte
%  \InputMode currentfile onebyte
%  \DefaultInputTranslation onebyte \OCPutf
%  \InputTranslation currentfile \OCPutf
  \pushocplist\inutf
}

%%%%% dummy %%%%%
\externalocp\OCPmkfont=makefonts.pl {}
\ocplist\mkfontOCP=
\addbeforeocplist 1 \OCPmkfont
\nullocplist

\AtEndDocument{
  \pushocplist\mkfontOCP
}

% Settings for CJK
\def\selectjisfont{\fontencoding{OT1}\fontfamily{omjis}\selectfont}
\def\selectgbsfont{\fontencoding{OT1}\fontfamily{omgbs}\selectfont}
\def\selectcnsfont{\fontencoding{OT1}\fontfamily{omcns}\selectfont}
\def\selectksxfont{\fontencoding{OT1}\fontfamily{omksx}\selectfont}
%\def\JIS{\pushocplist\CJKadjust\selectjisfont}
%\def\GB{\pushocplist\CJKadjust\selectgbsfont}
%\def\KS{\pushocplist\CJKadjust\selectksxfont}
%\def\CNS{\pushocplist\CJKadjust\selectcnsfont}

\newenvironment{JISfont}{\pushocplist\uniJIS\selectjisfont}{\pushocplist\inutf}
\newenvironment{GBfont}{\pushocplist\uniGB\selectgbsfont}{\pushocplist\inutf}
\newenvironment{KSfont}{\pushocplist\uniKS\selectksxfont}{\pushocplist\inutf}
\newenvironment{CNSfont}{\pushocplist\uniCNS\selectcnsfont}{\pushocplist\inutf}

\newcommand{\jisfont}[1]{\begingroup%
  \pushocplist\uniJIS\selectjisfont #1\endgroup}
\newcommand{\gbfont}[1]{\begingroup%
  \pushocplist\uniGB\selectgbsfont #1\endgroup}
\newcommand{\ksfont}[1]{\begingroup%
  \pushocplist\uniKS\selectksxfont #1\endgroup}
\newcommand{\cnsfont}[1]{\begingroup%
  \pushocplist\uniCNS\selectcnsfont #1\endgroup}
\newcommand{\noncjk}[1]{\begingroup%
  \normalfont\pushocplist\inutf #1\endgroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Font Declaration
% ----------------
\DeclareFontFamily{OT1}{chise000}{}
\DeclareFontShape{OT1}{chise000}{m}{n}{
   <-> [.96] chise000min
}{}
\DeclareFontShape{OT1}{chise000}{m}{sc}{
   <-> [.96] ssub * chise000min/m/n
}{}
\DeclareFontShape{OT1}{chise000}{m}{it}{
   <-> [.96] chise000min
}{}
\DeclareFontShape{OT1}{chise000}{m}{sl}{
   <-> [.96] ssub * chise000min/m/it
}{}
\DeclareFontShape{OT1}{chise000}{m}{itsc}{
   <-> [.96] ssub * chise000min/m/it
}{}
\DeclareFontShape{OT1}{chise000}{m}{slsc}{
   <-> [.96] ssub * chise000min/m/it
}{}
\DeclareFontShape{OT1}{chise000}{bx}{n}{
   <-> [.96] chise000got
}{}
\DeclareFontShape{OT1}{chise000}{bx}{sc}{
   <-> [.96] ssub * chise000got/bx/n
}{}
\DeclareFontShape{OT1}{chise000}{bx}{it}{
   <-> [.96] chise000got
}{}
\DeclareFontShape{OT1}{chise000}{bx}{itsc}{
   <-> [.96] ssub * chise000got/bx/it
}{}
\DeclareFontShape{OT1}{chise000}{bx}{sl}{
   <-> [.96] ssub * chise000got/bx/it
}{}
\DeclareFontShape{OT1}{chise000}{bx}{slsc}{
   <-> [.96] ssub * chise000got/bx/it
}{}
%%% GT
\DeclareFontFamily{OT1}{gt01}{}
\DeclareFontShape{OT1}{gt01}{m}{n}{
   <-> gt01
}{}
\DeclareFontFamily{OT1}{gt02}{}
\DeclareFontShape{OT1}{gt02}{m}{n}{
   <-> gt02
}{}
\DeclareFontFamily{OT1}{gt03}{}
\DeclareFontShape{OT1}{gt03}{m}{n}{
   <-> gt03
}{}
\DeclareFontFamily{OT1}{gt04}{}
\DeclareFontShape{OT1}{gt04}{m}{n}{
   <-> gt04
}{}
\DeclareFontFamily{OT1}{gt05}{}
\DeclareFontShape{OT1}{gt05}{m}{n}{
   <-> gt05
}{}
\DeclareFontFamily{OT1}{gt06}{}
\DeclareFontShape{OT1}{gt06}{m}{n}{
   <-> gt06
}{}
\DeclareFontFamily{OT1}{gt07}{}
\DeclareFontShape{OT1}{gt07}{m}{n}{
   <-> gt07
}{}
\DeclareFontFamily{OT1}{gt08}{}
\DeclareFontShape{OT1}{gt08}{m}{n}{
   <-> gt08
}{}
\DeclareFontFamily{OT1}{gt09}{}
\DeclareFontShape{OT1}{gt09}{m}{n}{
   <-> gt09
}{}
\DeclareFontFamily{OT1}{gt10}{}
\DeclareFontShape{OT1}{gt10}{m}{n}{
   <-> gt10
}{}
\DeclareFontFamily{OT1}{gt11}{}
\DeclareFontShape{OT1}{gt11}{m}{n}{
   <-> gt11
}{}


\ProcessOptions
\endinput
