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{$B!!(B}%
\newbox\@epsfkanjispacebox
\newskip\@epsfkanjiwidth
\newskip\@epsfkanjiheight
\newcount\@epsfkanjicnt
\newwrite\@xbmtoepsf
\@ifundefined{delayedfont}{%
  \typeout{epsfkanji.sty for ASCII-pLaTeX by Koichi Yasuoka, April 2002.}%
  \def\@epsfkanjistart{%
    \ifvmode
      \leavevmode
    \fi
    \hbox to 0pt{\@epsfkanjispace\hss}%
  }%
  \def\@epsfkanjiend{%
    \hbox to 0pt{\hss\@epsfkanjispace}%
  }%
}{%
  \typeout{epsfkanji.sty for NTT-jLaTeX by Koichi Yasuoka, April 2002.}%
  \def\@epsfkanjistart{%
    \@epsfkanjispace
    \setbox\@epsfkanjispacebox=\hbox{\@epsfkanjispace}%
    \hskip -\wd\@epsfkanjispacebox
  }%
  \def\@epsfkanjiend{%
    \setbox\@epsfkanjispacebox=\hbox{\@epsfkanjispace}%
    \hskip -\wd\@epsfkanjispacebox
    \@epsfkanjispace
  }%
}%
\gdef\epsfkanji#1{%
  \ifmmode
  \else
    \@epsfkanjistart
  \fi
  \vrule height 0.85zh depth 0.15zh width 0zw\relax
  \raise 0.85zh\hbox to 1zw{%
    \@epsfkanjiwidth=1zw\relax
    \divide\@epsfkanjiwidth by 65291\relax
    \@epsfkanjiheight=1zh\relax
    \divide\@epsfkanjiheight by 65291\relax
    \special{%
      epsfile=#1\space
      hsize=\number\@epsfkanjiwidth\space
      vsize=\number\@epsfkanjiheight\space
    }%
    \hfill
  }%
  \@ifnextchar\unskip{}{%
    \@ifnextchar\\{}{%
      \ifmmode
      \else
	\@epsfkanjiend
      \fi
    }%
  }%
}%
\begingroup
  \catcode`#=13\relax
  \catcode`+=6\relax
  \gdef\xbmtoeps+1+2{%
    \begingroup
      \catcode`\#=13\relax
      \catcode`\{=12\relax
      \catcode`\}=12\relax
      \immediate\openout\@xbmtoepsf=+2\relax
      \def#{\@xbmtoeps}%
      \input{+1}%
    \endgroup
    \epsfkanji{+2}%
  }%
  \catcode`\%=12\relax
  \gdef\@xbmtoepswritepreamble{\immediate\write\@xbmtoepsf{%!}\relax
    \immediate\write\@xbmtoepsf{%%BoundingBox: 0 0 1 1}}\relax
\endgroup
\long\def\@xbmtoeps#1idth #2 #3eight #4 #5=#60{%
  \@xbmtoepswritepreamble
  \immediate\write\@xbmtoepsf{#2 #4 true [#2 0 0 -#4 0 #4]}%
  \@epsfkanjicnt=#2\relax
  \advance\@epsfkanjicnt by 7\relax
  \divide\@epsfkanjicnt by 8\relax
  \immediate\write\@xbmtoepsf{{currentfile \number\@epsfkanjicnt\space
    string readhexstring pop} imagemask}%
  \multiply\@epsfkanjicnt by #4\relax
  \def\@tempb{}%
  \@xbmtoepsonebyte
}%
\def\@xbmtoepsonebyte#1x#2#3{%
  \@xbmtoepshalfbyte#3%
  \@xbmtoepshalfbyte#2%
  \advance\@epsfkanjicnt by -1\relax
  \ifnum\@epsfkanjicnt>0\relax
    \@tempcnta=\@epsfkanjicnt
    \divide\@tempcnta by 39\relax
    \multiply\@tempcnta by 39\relax
    \ifnum\@tempcnta=\@epsfkanjicnt
      \expandafter\@xbmtoepswriteout\@tempb.%
      \def\@tempb{}%
    \fi
    \let\@tempa=\@xbmtoepsonebyte
  \else
    \expandafter\@xbmtoepswriteout\@tempb.%
    \let\@tempa=\@xbmtoepsend
  \fi
  \@tempa
}%
\def\@xbmtoepshalfbyte#1{%
  \if#1f\edef\@tempb{\@tempb f}%
  \else
    \if#1e\edef\@tempb{\@tempb 7}%
    \else
      \if#1d\edef\@tempb{\@tempb b}%
      \else
	\if#1c\edef\@tempb{\@tempb 3}%
	\else
	  \if#1b\edef\@tempb{\@tempb d}%
	  \else
	    \if#1a\edef\@tempb{\@tempb 5}%
	    \else
	      \ifcase#1\edef\@tempb{\@tempb 0}%
	      \or\edef\@tempb{\@tempb 8}%
	      \or\edef\@tempb{\@tempb 4}%
	      \or\edef\@tempb{\@tempb c}%
	      \or\edef\@tempb{\@tempb 2}%
	      \or\edef\@tempb{\@tempb a}%
	      \or\edef\@tempb{\@tempb 6}%
	      \or\edef\@tempb{\@tempb e}%
	      \or\edef\@tempb{\@tempb 1}%
	      \or\edef\@tempb{\@tempb 9}%
	      \fi
	    \fi
	  \fi
	\fi
      \fi
    \fi
  \fi
}%
\def\@xbmtoepswriteout#1.{%
  \immediate\write\@xbmtoepsf{#1}%
}%
\def\@xbmtoepsend#1;{%
  \immediate\closeout\@xbmtoepsf
}%
