%%% file `kotexplain.tex`
%%
%% Typesetting UTF-8 hangul on plain e-TeX
%%
%% (C) Copyright 2007 Dohyun Kim <nomos@ktug.or.kr>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%  http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2006/05/20 or later.
%% ----------------------------------------------------------------
%%
%% changelog:
%% 2007/06/26   1.0.5   error if char does not exist
%% 2007/06/26   1.0.4   redefine U+2018, U+2019, U+201C, U+201D
%% 2007/06/25   1.0.3   fix bugs introduced by previous minor upgrade
%% 2007/06/24   1.0.2   lower multiple punctuations.
%% 2007/06/14   1.0.1   \hu was too normal a CS. use \dhucs@hu intead.
%%

\expandafter\ifx\csname eTeXversion\endcsname\relax
  \errhelp{This package requires e-TeX. Please run etex or pdftex.}
  \errmessage{Not running under e-TeX.}
  \expandafter\endinput
\fi

\expandafter\edef\csname AT(@):catcode\endcsname
  {\noexpand\catcode`@\the\catcode`@}

\catcode`\@=11
\newcount\@tempcnta
\newcount\@tempcntb
\let\@empty\empty
\begingroup
\def\:{\global\let\@sptoken= }\:  % this makes \@sptoken a space token
\endgroup

\unless\ifdefined\IeC
  \protected\def\IeC#1{#1}\fi
\unless\ifdefined\textperiodcentered
  \protected\def\textperiodcentered{$\cdot$}\fi
\unless\ifdefined\textquoteleft
  \protected\def\textquoteleft{`}\fi
\unless\ifdefined\textquoteright
  \protected\def\textquoteright{'}\fi
\unless\ifdefined\textquotedblleft
  \protected\def\textquotedblleft{``}\fi
\unless\ifdefined\textquotedblright
  \protected\def\textquotedblright{''}\fi

%%% slightly modified from utf8.def
\begingroup
\catcode`\~13
\catcode`\"12
\def\UTFviii@loop{%
  \global\catcode\count@\active %% On latex, this is done not just for
                                %% C2 .. F4, but for all chars > 127.
  \uccode`\~\count@
  \uppercase\expandafter{\UTFviii@tmp}%
  \advance\count@\@ne
  \ifnum\count@<\@tempcnta
  \expandafter\UTFviii@loop
  \fi}
    \count@"C2
    \@tempcnta"E0
    \def\UTFviii@tmp{\xdef~{\noexpand\UTFviii@two@octets\string~}}
\UTFviii@loop
    \count@"E0
    \@tempcnta"F0
    \def\UTFviii@tmp{\xdef~{\noexpand\UTFviii@three@octets\string~}}
\UTFviii@loop
    \count@"F0
    \@tempcnta"F5 %%% was "F4 in utf8.def
    \def\UTFviii@tmp{\xdef~{\noexpand\UTFviii@four@octets\string~}}
\UTFviii@loop
\endgroup

\begingroup
\catcode`\"=12
\catcode`\<=12
\catcode`\.=12
\catcode`\,=12
\catcode`\;=12
\catcode`\!=12
\catcode`\~=13
\gdef\DeclareUnicodeCharacter#1#2{%
   \count@"#1\relax
   \wlog{ \space\space defining Unicode char U+#1 (decimal \the\count@)}%
   \begingroup
    \parse@XML@charref
    \def\UTFviii@two@octets##1##2{\csname u8:##1\string##2\endcsname}%
    \def\UTFviii@three@octets##1##2##3{\csname u8:##1%
                                     \string##2\string##3\endcsname}%
    \def\UTFviii@four@octets##1##2##3##4{\csname u8:##1%
                           \string##2\string##3\string##4\endcsname}%
    \expandafter\expandafter\expandafter
    \expandafter\expandafter\expandafter
    \expandafter
     \gdef\UTFviii@tmp{\IeC{#2}}%
   \endgroup
}
\gdef\parse@XML@charref{%
  \ifnum\count@<"A0\relax
     \errmessage{Cannot\space define\space Unicode\space
                 char\space value\space <\space 00A0}%\@eha
  \else\ifnum\count@<"800\relax
     \parse@UTFviii@a,%
     \parse@UTFviii@b C\UTFviii@two@octets.,%
  \else\ifnum\count@<"10000\relax
     \parse@UTFviii@a;%
     \parse@UTFviii@a,%
     \parse@UTFviii@b E\UTFviii@three@octets.{,;}%
   \else
     \parse@UTFviii@a;%
     \parse@UTFviii@a,%
     \parse@UTFviii@a!%
     \parse@UTFviii@b F\UTFviii@four@octets.{!,;}%
    \fi
    \fi
  \fi
}
\gdef\parse@UTFviii@a#1{%
     \@tempcnta\count@
     \divide\count@ 64
     \@tempcntb\count@
     \multiply\count@ 64
     \advance\@tempcnta-\count@
     \advance\@tempcnta 128
     \uccode`#1\@tempcnta
     \count@\@tempcntb}
\gdef\parse@UTFviii@b#1#2#3#4{%
     \advance\count@ "#10\relax
     \uccode`#3\count@
     \uppercase{\gdef\UTFviii@tmp{#2#3#4}}}
\endgroup

%%% slightly modified from dhucs.sty
\def\UTFviii@two@octets#1#2{%
  \ifcsname u8:\string#1\string#2\endcsname
    \expandafter\csname u8:\string#1\string#2\expandafter\endcsname
  \else
    \expandafter\unihangul@two@octets\expandafter#1\expandafter#2%
  \fi}
\def\unihangul@two@octets#1#2{%
    \expandafter\unihangulchar\expandafter{%
      \number\numexpr
        (`#1 - 192) * 64 +
        (`#2 - 128) \relax}}
\def\UTFviii@three@octets#1#2#3{%
  \ifcsname u8:\string#1\string#2\string#3\endcsname
    \expandafter\csname
      u8:\string#1\string#2\string#3\expandafter\endcsname
  \else
    \expandafter\unihangul@three@octets
      \expandafter#1\expandafter#2\expandafter#3%
  \fi}
\def\unihangul@three@octets#1#2#3{%
    \expandafter\unihangulchar\expandafter{%
      \number\numexpr
        (`#1 - 224) * 4096 +
        (`#2 - 128) * 64 +
        (`#3 - 128) \relax}}
\def\UTFviii@four@octets#1#2#3#4{%
  \ifcsname u8:\string#1\string#2\string#3\string#4\endcsname
    \expandafter\csname
      u8:\string#1\string#2\string#3\string#4\expandafter\endcsname
  \else
    \expandafter\unihangul@four@octets
      \expandafter#1\expandafter#2\expandafter#3\expandafter#4%
  \fi}
\def\unihangul@four@octets#1#2#3#4{%
    \expandafter\unihangulchar\expandafter{%
      \number\numexpr
        (`#1 - 240) * 262144 +
        (`#2 - 128) * 4096 +
        (`#3 - 128) * 64 +
        (`#4 - 128) \relax}}


\def\geth@ngulpl@ne@ndch@r{%
  \count@\numexpr % 1 / 256 = .00390625
    \number\dimexpr.00390625\dimexpr\unih@ngulpoint sp\relax\relax
    \relax
  \chardef\h@ngulch@r % hangul char slot
    \number\numexpr\unih@ngulpoint-\@cclvi*\count@\relax
  \let\h@ngulpl@ne\@empty % hangul subfont plane
  \ifnum\count@>\@cclv
    \ifnum\count@>4095
      \def\h@ngulpl@ne{1}\count@\numexpr\count@-4096\relax
    \else
      \def\h@ngulpl@ne{0}%
    \fi
    \@tempcnta\numexpr % 1 / 256 = .00390625
      \number\dimexpr.00390625\dimexpr\count@ sp\relax\relax
      \relax
    \edef\h@ngulpl@ne{\h@ngulpl@ne\dhucsnumt@hex\@tempcnta}%
    \count@\numexpr\count@-\@cclvi*\@tempcnta\relax
  \fi
  \@tempcnta\numexpr % 1 / 16 = .0625
    \number\dimexpr.0625\dimexpr\count@ sp\relax\relax
    \relax
  \edef\h@ngulpl@ne{\h@ngulpl@ne\dhucsnumt@hex\@tempcnta}%
  \count@\numexpr\count@-\sixt@@n*\@tempcnta\relax
  \edef\h@ngulpl@ne{\h@ngulpl@ne\dhucsnumt@hex\count@}%
}
\def\dhucsnumt@hex#1{\ifcase\number#1
  0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or
  8\or 9\or a\or b\or c\or d\or e\or f\else \dhucserr@r\fi
}

\input lucenc.dfu

\doublehyphendemerits=0
\finalhyphendemerits=0

\def\usehangulfontspec#1{%
  \begingroup
    \immediate\openin\z@=hfontspec.#1 %
    \ifeof\z@ 
      \message{\space\space
        *** Cannot find hangul font-spec file hfontspec.#1 ***\space\space}
    \else
      \endlinechar\m@ne
      \get@hfnt@spec@ 
    \fi
    \immediate\closein\z@
  \endgroup}
\def\get@hfnt@spec@{%
    \read\z@ to \temp
    \ifx\temp\@empty
      \let\next\relax
    \else
      \expandafter\get@hfnt@spec@@\temp\@@nil
      \let\next\get@hfnt@spec@
    \fi\next}
\def\get@hfnt@spec@@#1 = #2\@@nil{%
  \expandafter\gdef\csname dhucs@#1\endcsname{#2}}

\newcount\unih@ngulpoint

\protected\def\unihangulchar#1{% 
  \unih@ngulpoint#1\relax
  \futurelet\dhucs@next\unihangulchar@@}
\def\unihangulchar@@{% check what comes next to hangul?
  % \nexttoh@ngul = 1 : ascii opening parentheses
  % \nexttoh@ngul = 2 : ascii closing parentheses
  % \nexttoh@ngul = 3 : ascii numbers
  % \nexttoh@ngul = 4 : ascii fullstop 
  % \nexttoh@ngul = 5 : ascii question mark
  % \nexttoh@ngul = 6 : ascii exclamation mark
  % \nexttoh@ngul = 0 : all others
  \chardef\nexttoh@ngul\z@
  % \puncnobre@k = 0 : this is not char ``orphan'' case
  % \puncnobre@k = 1 : do not break before char ``orphan''
  \chardef\puncnobre@k\z@
  \ifx\par\dhucs@next
    \chardef\puncnobre@k\@ne
    \let\unihangul@branch\unihangulchar@@@
  \else
    \ifx\@sptoken\dhucs@next
      \let\unihangul@branch\check@next@to@sptoken
    \else
      \if\noexpand\dhucs@next\relax
        \let\unihangul@branch\unihangulchar@@@
      \else
        \check@dhucs@next@ascii456123\@nil
        \ifnum\nexttoh@ngul>\thr@@
          \let\unihangul@branch\check@next@to@puncs
        \else
          \let\unihangul@branch\unihangulchar@@@
        \fi 
      \fi
    \fi
  \fi
  \unihangul@branch
}

\def\check@next@to@sptoken{%
  \afterassignment\check@next@to@sptoken@\let\dhucs@next= }
\def\check@next@to@sptoken@{%
  \futurelet\dhucs@nextnext\check@next@to@sptoken@@}
\def\check@next@to@sptoken@@{%
  \ifx\dhucs@nextnext\par
    \chardef\puncnobre@k\@ne
  \fi
  \unihangulchar@@@\dhucs@next
}

\def\check@next@to@puncs{%
  \afterassignment\check@next@to@puncs@\let\dhucs@next= }
\def\check@next@to@puncs@{%
  \futurelet\dhucs@nextnext\check@next@to@puncs@@}
\def\check@next@to@puncs@@{%
  \ifx\dhucs@nextnext\par
    \chardef\puncnobre@k\@ne
    \expandafter\unihangulchar@@@\expandafter\dhucs@next
  \else
    \ifx\dhucs@nextnext\@sptoken
      \expandafter\expandafter\expandafter\check@next@to@punc@sptoken
    \else
      \expandafter\expandafter\expandafter\unihangulchar@@@
      \expandafter\expandafter\expandafter\dhucs@next
    \fi
  \fi
}

\def\check@next@to@punc@sptoken{%
  \afterassignment\check@next@to@punc@sptoken@\let\dhucs@nextnext= }
\def\check@next@to@punc@sptoken@{%
  \futurelet\dhucs@nextnextnext\check@next@to@punc@sptoken@@}
\def\check@next@to@punc@sptoken@@{%
  \ifx\dhucs@nextnextnext\par
    \chardef\puncnobre@k\@ne
  \fi
  \unihangulchar@@@\dhucs@next\dhucs@nextnext
}

\def\check@dhucs@next@ascii#1{%
  \def\@tempa{#1}%
  \ifx#1\@nil
    \let\next\relax
  \else
    \let\next\check@dhucs@next@ascii
    \edef\@tempb{\csname nexttohangul-#1\endcsname}%
    \expandafter\check@dhucs@next@ascii@\@tempb\@nnil
  \fi\next
}
\def\check@dhucs@next@ascii@#1{%
  \ifx#1\@nnil\let\next@\relax
  \else
    \ifx#1\dhucs@next
      \chardef\nexttoh@ngul\@tempa
      \let\next@\remove@to@nnil \let\next\remove@to@nil
    \else
      \let\next@\check@dhucs@next@ascii@
    \fi
  \fi\next@
}
\def\remove@to@nil#1\@nil{}
\def\remove@to@nnil#1\@nnil{}

\def\unihangulchar@@@{%
  \getthish@ngulcl@ss
  \dobeforeh@ngulch@r
  \begingroup
    \geth@ngulpl@ne@ndch@r
    \leavevmode
    \font\myh@ngulf@nt\h@font@name\h@ngulpl@ne\space\h@font@size
    \myh@ngulf@nt
    \dhucs@check@if@char@exists
    \h@ngulch@r
  \endgroup
  \do@fterh@ngulch@r
}

\def\dhucs@check@if@char@exists{%
  \unless\iffontchar\myh@ngulf@nt\h@ngulch@r
    \errmessage{Character \number\h@ngulch@r\space
      doesn't exist in font \fontname\myh@ngulf@nt}%
  \fi}

\mathchardef\Hangul@spacefactor=1001
\mathchardef\Hanja@spacefactor=1002
\mathchardef\nobreak@spacefactor=998

\def\getthish@ngulcl@ss{% what is current hangul category?
  % \thish@ngul = 1 : hangul
  % \thish@ngul = 2 : hanja, hiragana, katakana
  % \thish@ngul = 3 : opening parentheses; NOT in use: see lucenc.dfu
  % \thish@ngul = 4 : closing parentheses; NOT in use: see lucenc.dfu
  % \thish@ngul = 0 : all others
  \ifnum\unih@ngulpoint<12352
    \chardef\thish@ngul\z@ % cjk symbols
  \else\ifnum\unih@ngulpoint<12539
    \chardef\thish@ngul\tw@ % hiragana, katakana
  \else\ifnum\unih@ngulpoint<13312
    \chardef\thish@ngul\z@ % cjk symbols
  \else\ifnum\unih@ngulpoint<44032
    \chardef\thish@ngul\tw@ % hanja ext A; hanja unified
  \else\ifnum\unih@ngulpoint<57344
    \chardef\thish@ngul\@ne % hangul 
  \else\ifnum\unih@ngulpoint<64256
    \chardef\thish@ngul\tw@ % hanja compatibillity
  \else\ifnum\unih@ngulpoint<65520
    \chardef\thish@ngul\z@ % full/half width marks
  \else
    \chardef\thish@ngul\tw@ % hanja ext. B mostly 
  \fi\fi\fi\fi\fi \fi\fi
}

\sfcode`\(=\nobreak@spacefactor
\sfcode`\`=\nobreak@spacefactor
\sfcode`\[=\nobreak@spacefactor
\sfcode`\-=\nobreak@spacefactor

\def\dobeforeh@ngulch@r{%
  \ifhmode
    \ifcase\lastnodetype
      % e-TeX's lastnodetype 0 is char node
      \dhucs@normal@break@before@cjk
    \or % hlist node 
        % As \hbox returns spacefactor to 1000, 
        % we cannot identify what was before this korean char.
        % So, allowing linebreak is somewhat dangerous; We Do, however.
      \ifcase\thish@ngul
        \or \ifcase\puncnobre@k\breakbetweenhanja
              \or\nobreakbetweenhanja\fi
        \or \ifcase\puncnobre@k\breakbetweenhanja
              \or\nobreakbetweenhanja\fi
      \fi
    \or % vlist node
    \or % rule node
    \or % ins node
    \or % mark node
    \or % adjust node
    \or % ligature node
      \ifnum\spacefactor>\nobreak@spacefactor
        \ifcase\thish@ngul 
          \or \ifcase\puncnobre@k\breakafterasciichar
                \or\nobreakafterasciichar\fi
          \or \ifcase\puncnobre@k\breakafterasciichar
                \or\nobreakafterasciichar\fi
        \fi
      \fi
    \or % disc node
    \or % whatsit node
        % how do we know what there was before whatsit?
      \dhucs@normal@break@before@cjk
    \or % math node
      \ifcase\thish@ngul
        \or \ifcase\puncnobre@k\breakafterinlinemath
              \or\nobreakafterinlinemath\fi
        \or \ifcase\puncnobre@k\breakafterinlinemath
              \or\nobreakafterinlinemath\fi
      \fi
    \or % glue node
    \or % kern node, which is another source of headache!
      \ifdim\lastkern=\z@
        % is it safe to break lines after \kern 0pt?
        \dhucs@normal@break@before@cjk
      \else
        \ifnum\spacefactor>\nobreak@spacefactor
          \ifcase\thish@ngul
            \or \ifcase\puncnobre@k\breakbetweenhanja
                  \or\nobreakbetweenhanja\fi
            \or \ifcase\puncnobre@k\breakbetweenhanja
                  \or\nobreakbetweenhanja\fi
          \fi
        \fi
      \fi
    \or % penalty node
        % Even after \nobreak, inter-hangulchar kern should be applied!
      \ifnum\lastpenalty<\@M 
        \dhucs@normal@break@before@cjk
      \else
        \chardef\puncnobre@k\@ne
        \dhucs@normal@break@before@cjk
      \fi
    \or % unset node
    \or % math mode node
    \fi
  \fi
}

\def\dhucs@normal@break@before@cjk{%
  \ifnum\spacefactor>\nobreak@spacefactor
    \ifcase\thish@ngul
        % other cjk char: do nothing
    \or % hangul
      \ifnum\spacefactor=\Hangul@spacefactor
        \ifcase\puncnobre@k\breakbetweenhangul
          \or\nobreakbetweenhangul\fi
      \else
        \ifnum\spacefactor=\Hanja@spacefactor
          \ifcase\puncnobre@k\breakbetweenhanja
            \or\nobreakbetweenhanja\fi
        \else
          \ifcase\puncnobre@k\breakafterasciichar
            \or\nobreakafterasciichar\fi
        \fi
      \fi
    \or % hanja, hiragana, katakana
      \ifnum\spacefactor=\Hangul@spacefactor
        \ifcase\puncnobre@k\breakbetweenhanja
          \or\nobreakbetweenhanja\fi
      \else
        \ifnum\spacefactor=\Hanja@spacefactor
          \ifcase\puncnobre@k\breakbetweenhanja
            \or\nobreakbetweenhanja\fi
        \else
          \ifcase\puncnobre@k\breakafterasciichar
            \or\nobreakafterasciichar\fi
        \fi
      \fi
    \fi
  \fi
}

\def\do@fterh@ngulch@r{%
  \ifhmode
    \ifcase\nexttoh@ngul
      \ifcase\thish@ngul
          \declarehanjaspacefactor
      \or \declarehangulspacefactor
      \or \declarehanjaspacefactor
      \or \declarenobreakspacefactor
      \or \declarehanjaspacefactor
      \fi
    \or \breakbeforeasciichar % (
    \or % )
    \or \kernbeforeasciichar % 123
    \or \expandafter\expandafter\expandafter\asciifullstopafterhangul % .
    \or \expandafter\expandafter\expandafter\asciiquestionafterhangul % ?
    \or \expandafter\expandafter\expandafter\asciiexclamationafterhangul % !
    \fi
  \fi
}

\def\declarenobreakspacefactor{\spacefactor\nobreak@spacefactor}
\def\declarehangulspacefactor{\spacefactor\Hangul@spacefactor}
\def\declarehanjaspacefactor{\spacefactor\Hanja@spacefactor}

\usehangulfontspec{ut}
\def\breakbetweenhanja{\discretionary{}{}{}}
\def\nobreakbetweenhanja{}
\def\breakbetweenhangul{\discretionary{}{}{\kern\dhucs@interhchar}}
\def\nobreakbetweenhangul{\kern\dhucs@interhchar}
\def\breakafterinlinemath{\hskip\dimexpr\dhucs@hu*3\relax\relax}
\def\nobreakafterinlinemath{\kern\dimexpr\dhucs@hu*3\relax}
\def\breakafterasciichar{\hskip\dimexpr\dhucs@hu*2\relax\relax}
\def\nobreakafterasciichar{\kern\dimexpr\dhucs@hu*2\relax}
\def\breakbeforeasciichar{\hskip\dimexpr\dhucs@hu*2\relax\relax}
\def\kernbeforeasciichar{\kern\dimexpr\dhucs@hu*2\relax}

\def\asciifullstopafterhangul#1{%
  \lower\dhucs@fullstoplower\hbox\bgroup#1\dhucs@check@another@punc}
\def\asciiquestionafterhangul#1{%
  \lower\dhucs@questionlower\hbox\bgroup
    \let\dhucs@kern@before@quot@char\dhucs@kern@before@quot@char@
    \kern\dimexpr\dhucs@hu*3\relax#1\dhucs@check@another@punc}
\def\asciiexclamationafterhangul#1{%
  \lower\dhucs@exclamationlower\hbox\bgroup
    \let\dhucs@kern@before@quot@char\dhucs@kern@before@quot@char@
    \kern\dimexpr\dhucs@hu*4\relax#1\dhucs@check@another@punc}
\def\dhucs@kern@before@quot@char@{%
  \ifx'\dhucs@next\kern\dimexpr\dhucs@hu*3\relax\fi
  \spacefactor1003 }
\let\dhucs@kern@before@quot@char\relax
\def\dhucs@check@another@punc{%
  \futurelet\dhucs@next\dhucs@check@another@punc@}
\def\dhucs@check@another@punc@{%
  \chardef\nexttoh@ngul\z@
  \if\noexpand\dhucs@next\relax\else
    \check@dhucs@next@ascii456\@nil
  \fi
  \dhucs@check@another@punc@@}
\def\dhucs@check@another@punc@@{%
  \ifcase\nexttoh@ngul
      \expandafter\dhucs@check@another@punc@end
  \or \expandafter\dhucs@check@another@punc@end
  \or \expandafter\dhucs@check@another@punc@end
  \or \expandafter\dhucs@check@another@punc@end
  \or \let\dhucs@kern@before@quot@char\relax
      \expandafter\dhucs@check@another@punc@@@
  \or \let\dhucs@kern@before@quot@char\dhucs@kern@before@quot@char@
      \expandafter\dhucs@check@another@punc@@@
  \or \let\dhucs@kern@before@quot@char\dhucs@kern@before@quot@char@
      \expandafter\dhucs@check@another@punc@@@
  \fi}
\def\dhucs@check@another@punc@@@#1{%
  \kern\dhucs@hu\relax #1\dhucs@check@another@punc}
\def\dhucs@check@another@punc@end{%
  \dhucs@kern@before@quot@char
  \global\count@\spacefactor\egroup\spacefactor\count@}

\def\cjksymbolextraspace{\discretionary{}{}{}}
\def\cjksymbolskip{%
  \ifhmode
    \ifnum\spacefactor>\nobreak@spacefactor
      \cjksymbolextraspace
    \fi
  \else
    \leavevmode
  \fi}
\def\postcjksymskip{\ifhmode\declarehanjaspacefactor\fi}
\def\postcjksymnobreak{\ifhmode\declarehanjaspacefactor\nobreak\fi}
\def\postcjksymbol{\ifhmode\declarehanjaspacefactor\fi}
\def\kernbeforelatinquoteclose{%
  \ifhmode\ifnum\spacefactor=1003 \kern\dimexpr\dhucs@hu*3\relax\fi\fi}
\def\cjksymbolunskip{}

\def\disablehangulfontspec{%
  \def\breakbetweenhangul{\discretionary{}{}{}}
  \let\nobreakbetweenhangul\@empty
  \def\breakafterasciichar{\hskip\z@skip}
  \let\nobreakafterasciichar\@empty
  \let\breakbeforeasciichar\breakafterasciichar
  \let\kernbeforeasciichar\@empty
  \let\asciifullstopafterhangul\relax
  \let\asciiquestionafterhangul\relax
  \let\asciiexclamationafterhangul\relax
}

\def\disablehangullinebreak{%
  \let\unihangulchar@\unihangulchar@@@
  \let\dobeforeh@ngulch@r\relax
  \let\do@fterh@ngulch@r\relax
  \let\cjksymbolskip\leavevmode
}

\def\nobreak@hangul@da{\nobreak 다}
\def\^^eb#1#2{%
  \ifx#1^^8b%
    \ifx#2^^a4% avoid orphan \다
      \expandafter\expandafter\expandafter\nobreak@hangul@da
    \else
      \errmessage{Undefined Control Sequence}%
    \fi
  \else
    \errmessage{Undefined Control Sequence}%
  \fi}

% hangul font definition
% ex: \hfont{oungtm}{at 12pt}
%     \hfontname{oungtm}
%     \hfontsize{at 12pt}
\protected\def\hfontname#1{\def\h@font@name{#1}}
\protected\def\hfontsize#1{\def\h@font@size{#1}}
\protected\def\hfont#1#2{\hfontname{#1}\hfontsize{#2}}

\csname AT(@):catcode\endcsname

\frenchspacing

\hfont{outbtm}{}

\endinput

% eof
