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

\DeclareOption{utf8mcs}{
  \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
  \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
  \ocplist\uniMulti=
    \addbeforeocplist 1 \OCPuniMulti
    \nullocplist
}
\DeclareOption{utf8gb}{
  \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
  \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
  \ocplist\uniMulti=
    \addbeforeocplist 1 \OCPuniMulti
    \nullocplist
}
\DeclareOption{utf8cns}{
  \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
  \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
  \ocplist\uniMulti=
    \addbeforeocplist 1 \OCPuniMulti
    \nullocplist
}
\DeclareOption{utf8jis}{
  \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
  \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
  \ocplist\uniMulti=
    \addbeforeocplist 1 \OCPuniMulti
    \nullocplist
}
\DeclareOption{utf8ks}{
  \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
  \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
  \ocplist\uniMulti=
    \addbeforeocplist 1 \OCPuniMulti
    \nullocplist
}

\DeclareOption{gbfont}{
  \AtBeginDocument{
    \GBfont
  }
}
\DeclareOption{cnsfont}{
  \AtBeginDocument{
    \CNSfont
  }
}
\DeclareOption{jisfont}{
  \AtBeginDocument{
    \JISfont
  }
}
\DeclareOption{ksfont}{
  \AtBeginDocument{
    \KSfont
  }
}
\DeclareOption{multifont}{
  \AtBeginDocument{
    \Multifont
  }
}

\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
}

%%%%% to use KAGE server %%%%%
\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}
\newenvironment{Multifont}{\pushocplist\uniMulti}{\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{\multifont}[1]{\begingroup%
  \pushocplist\uniMulti #1\endgroup}
\newcommand{\noncjk}[1]{\begingroup%
  \normalfont\pushocplist\inutf #1\endgroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Font Declaration
% ----------------
%% omgbs
\DeclareFontFamily{OT1}{omgbs}{}
\DeclareFontShape{OT1}{omgbs}{m}{n}{
   <->omgbs
}{}
\DeclareFontShape{OT1}{omgbs}{m}{sc}{
   <-> ssub * omgbs/m/n
}{}
\DeclareFontShape{OT1}{omgbs}{m}{it}{
   <->omgb
}{}
\DeclareFontShape{OT1}{omgbs}{m}{sl}{
   <-> ssub * omgbs/m/it
}{}
\DeclareFontShape{OT1}{omgbs}{m}{itsc}{
   <-> ssub * omgbs/m/it
}{}
\DeclareFontShape{OT1}{omgbs}{m}{slsc}{
   <-> ssub * omgbs/m/it
}{}
\DeclareFontShape{OT1}{omgbs}{bx}{n}{
   <->omgbsgt
}{}
\DeclareFontShape{OT1}{omgbs}{bx}{sc}{
   <-> ssub * omgbs/bx/n
}{}
\DeclareFontShape{OT1}{omgbs}{bx}{it}{
   <->omgbsgt
}{}
\DeclareFontShape{OT1}{omgbs}{bx}{itsc}{
   <-> ssub * omgbs/bx/it
}{}
\DeclareFontShape{OT1}{omgbs}{bx}{sl}{
   <-> ssub * omgbs/bx/it
}{}
\DeclareFontShape{OT1}{omgbs}{bx}{slsc}{
   <-> ssub * omgbs/bx/it
}{}

%% omcns
\DeclareFontFamily{OT1}{omcns}{}
\DeclareFontShape{OT1}{omcns}{m}{n}{
   <->omcns
}{}
\DeclareFontShape{OT1}{omcns}{m}{sc}{
   <-> ssub * omcns/m/n
}{}
\DeclareFontShape{OT1}{omcns}{m}{it}{
   <->omcns
}{}
\DeclareFontShape{OT1}{omcns}{m}{sl}{
   <-> ssub * omcns/m/it
}{}
\DeclareFontShape{OT1}{omcns}{m}{itsc}{
   <-> ssub * omcns/m/it
}{}
\DeclareFontShape{OT1}{omcns}{m}{slsc}{
   <-> ssub * omcns/m/it
}{}
\DeclareFontShape{OT1}{omcns}{bx}{n}{
   <->omcnsgt
}{}
\DeclareFontShape{OT1}{omcns}{bx}{sc}{
   <-> ssub * omcns/bx/n
}{}
\DeclareFontShape{OT1}{omcns}{bx}{it}{
   <->omcnsgt
}{}
\DeclareFontShape{OT1}{omcns}{bx}{itsc}{
   <-> ssub * omcns/bx/it
}{}
\DeclareFontShape{OT1}{omcns}{bx}{sl}{
   <-> ssub * omcns/bx/it
}{}
\DeclareFontShape{OT1}{omcns}{bx}{slsc}{
   <-> ssub * omcns/bx/it
}{}

%%
\DeclareFontFamily{OT1}{omjis}{}
\DeclareFontShape{OT1}{omjis}{m}{n}{
   <->omjis
}{}
\DeclareFontShape{OT1}{omjis}{m}{sc}{
   <-> ssub * omjis/m/n
}{}
\DeclareFontShape{OT1}{omjis}{m}{it}{
   <->omjis
}{}
\DeclareFontShape{OT1}{omjis}{m}{sl}{
   <-> ssub * omjis/m/it
}{}
\DeclareFontShape{OT1}{omjis}{m}{itsc}{
   <-> ssub * omjis/m/it
}{}
\DeclareFontShape{OT1}{omjis}{m}{slsc}{
   <-> ssub * omjis/m/it
}{}
\DeclareFontShape{OT1}{omjis}{bx}{n}{
   <->omjisgt
}{}
\DeclareFontShape{OT1}{omjis}{bx}{sc}{
   <-> ssub * omjis/bx/n
}{}
\DeclareFontShape{OT1}{omjis}{bx}{it}{
   <->omjisgt
}{}
\DeclareFontShape{OT1}{omjis}{bx}{itsc}{
   <-> ssub * omjis/bx/it
}{}
\DeclareFontShape{OT1}{omjis}{bx}{sl}{
   <-> ssub * omjis/bx/it
}{}
\DeclareFontShape{OT1}{omjis}{bx}{slsc}{
   <-> ssub * omjis/bx/it
}{}

%% omksx
\DeclareFontFamily{OT1}{omksx}{}
\DeclareFontShape{OT1}{omksx}{m}{n}{
   <->omksx
}{}
\DeclareFontShape{OT1}{omksx}{m}{sc}{
   <-> ssub * omksx/m/n
}{}
\DeclareFontShape{OT1}{omksx}{m}{it}{
   <->omksx
}{}
\DeclareFontShape{OT1}{omksx}{m}{sl}{
   <-> ssub * omksx/m/it
}{}
\DeclareFontShape{OT1}{omksx}{m}{itsc}{
   <-> ssub * omksx/m/it
}{}
\DeclareFontShape{OT1}{omksx}{m}{slsc}{
   <-> ssub * omksx/m/it
}{}
\DeclareFontShape{OT1}{omksx}{bx}{n}{
   <->omksxgt
}{}
\DeclareFontShape{OT1}{omksx}{bx}{sc}{
   <-> ssub * omksx/bx/n
}{}
\DeclareFontShape{OT1}{omksx}{bx}{it}{
   <->omksxgt
}{}
\DeclareFontShape{OT1}{omksx}{bx}{itsc}{
   <-> ssub * omksx/bx/it
}{}
\DeclareFontShape{OT1}{omksx}{bx}{sl}{
   <-> ssub * omksx/bx/it
}{}
\DeclareFontShape{OT1}{omksx}{bx}{slsc}{
   <-> ssub * omksx/bx/it
}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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
}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% line break, from omega-japanese.

\def\CJKunbreakablekernone{%
  \nobreak
  \hskip 0sp plus 2sp minus 2sp
  \nobreak
}
\def\CJKunbreakablekerntwo{%
  \penalty 500
  \hskip 0sp plus 2sp minus 2sp
  \penalty 500
}
\def\CJKunbreakablekernthree{%
  \penalty 200
  \hskip 0sp plus 2sp minus 2sp
  \penalty 200
}
\def\CJKbreakablekern{\hskip 0sp plus 2pt minus 2sp}
% BUG: \rlap should preserve the current font
\def\CJKprotrude#1{%
  \discretionary{\rlap{#1}}%
                {}%
                {#1}%
}
%% Hyphenation parameters
  % If the badness does not exceed this, no hyphenation is
  % attempted
  \pretolerance=-1

  % Maximal badness
  \tolerance=200

  % Penalty added for the first hyphenation
  % in the current paragraph
  \hyphenpenalty=0 % Was 50

  % Penalty added for subsequent hyphenations
  \exhyphenpenalty=0 % Was 50

  % TeX tries to minimize the demerit of the lines:
  % (\linepenalty^2 + badness^2) + penalty^2
  \linepenalty=10

  % If a tight line is followed by a loose one
  % (or conversely), we add \adjdemerits 
  % to the demerit
  \adjdemerits=0 % Was 10000 % ???

  % two hyphens on consecutive lines also add 
  % to the demerit
  \doublehyphendemerits=0 % Was 10000

  % A hyphen on the last line also adds to
  % the demerit.
  \finalhyphendemerits=0 % Was 5000

  % Minimum number of characters in the current word
  % before or after a hyphenation point
  \lefthyphenmin=2
  \righthyphenmin=3

% line break definition ends.

\ProcessOptions
\endinput
