% xetexko.sty
%
% Copyright (c) 2013-2018 Dohyun Kim  <nomos at ktug org>
%
% 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.

\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax\else
  \ProvidesPackage{xetexko}[2018/04/06 v2.18 Typesetting Korean with XeTeX]
\fi

\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname selectfont\endcsname\relax
  \chardef\catcodeofATcharacter\catcode`@
  \catcode`\@ = 11

  \input xetexko-space.sty
  \input xetexko-josa.sty
  \input xetexko-vertical.sty

  %%% 한글 폰트
  \def\hangulfont{\font\hangfnt}
  \def\hanjafont {\font\hanifnt}
  %\hangulfont="[UnBatang]:mapping=tex-text" at 10pt
  %%% 수식 한글
  \newfam\symmathhangul
  \def\setmathhangulfont#1#{\setmathhangulfont@}
  \def\setmathhangulfont@#1{%
    \font\tenhangul   = "#1" at 10pt
    \font\sevenhangul = "#1" at 7pt
    \font\fivehangul  = "#1" at 5pt
    \textfont\symmathhangul         = \tenhangul
    \scriptfont\symmathhangul       = \sevenhangul
    \scriptscriptfont\symmathhangul = \fivehangul
  }
  \setmathhangulblock{AC00}{D7A3}
  %\setmathhangulfont{[UnBatang]}

  \catcode`\@\catcodeofATcharacter
  \expandafter\endinput
\fi

\newif\if@hangul
\newif\if@hanja
\DeclareOption{hangul}{\@hangultrue}
\DeclareOption{hanja}{\@hangultrue\@hanjatrue}
\DeclareOption{unfonts}{}
\ProcessOptions\relax

\RequirePackage{xetexko-space}
\RequirePackage{xetexko-josa}
\RequirePackage{xetexko-font}
\RequirePackage{xetexko-vertical}

\RequirePackage{kolabels-utf}
\if@hangul\AtBeginDocument{\RequirePackage{konames-utf}}\fi

\AtBeginDocument{
  % for ulem package
  \ifcsname UL@hook\endcsname \xetexkoulemsupport \fi
  % for hyperref package
  \@ifpackageloaded{hyperref}{\pdfstringdefDisableCommands{%
      \let\dotemph\@firstofone
      \let\makejosa\@secondoftwo
      \let\jong\relax
      \let\jung\relax
      \let\rieul\relax
      \let\latinalphs\relax
      \let\hangulalphs\relax
      \let\hanjaalphs\relax
      \let\prevfontalphs\relax
      \let\latinnums\relax
      \let\hangulnums\relax
      \let\hanjanums\relax
      \let\prevfontnums\relax
      \let\latinparens\relax
      \let\hangulparens\relax
      \let\hanjaparens\relax
      \let\prevfontparens\relax
      \let\latinquotes\relax
      \let\hangulquotes\relax
      \let\hanjaquotes\relax
      \let\prevfontquotes\relax
      \let\latinpuncts\relax
      \let\hangulpuncts\relax
      \let\hanjapuncts\relax
      \let\prevfontpuncts\relax
      \let\latinmarks\relax
      \let\hangulmarks\relax
      \let\hanjamarks\relax
      \let\prevfontmarks\relax
      \let\latincolons\relax
      \let\hangulcolons\relax
      \let\hanjacolons\relax
      \let\prevfontcolons\relax
      \let\latinhyphens\relax
      \let\hangulhyphens\relax
      \let\hanjahyphens\relax
      \let\prevfonthyphens\relax
      \let\latincjksymbols\relax
      \let\hangulcjksymbols\relax
      \let\hanjacjksymbols\relax
      \let\prevfontcjksymbols\relax
      \let\disablekoreanfonts\relax
      \let\disablehangulspacing\relax
      \let\disablehangulspacingandlinebreak\relax
      \let\disableautojosa\relax
      \let\disablecjksymbolspacing\relax
      \let\japanese\relax
      \let\chinese\relax
      \let\Tchinese\relax
      \let\Schinese\relax
  }}{}
}

\endinput
