%%
%% This is file `ctex-engine-xetex.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ctex.dtx  (with options: `xetex')
%% 
%%     Copyright (C) 2003--2015
%%     CTEX.ORG and any individual authors listed in the documentation.
%% ------------------------------------------------------------------------------
%% 
%%     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. This version of this license is in
%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
%%     and the latest version of this license is in
%%        http://www.latex-project.org/lppl.txt
%%     and version 1.3 or later is part of all distributions of
%%     LaTeX version 2005/12/01 or later.
%% 
%%     This work has the LPPL maintenance status `maintained'.
%% 
%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
%% 
%% ------------------------------------------------------------------------------
%% 
\GetIdInfo$Id: ctex.dtx 3216ced 2015-05-16 11:29:03 +0800 Qing Lee <sobenlee@gmail.com> $
  {XeLaTeX adapter (CTEX)}
\ProvidesExplFile{ctex-engine-xetex.def}
  {\ExplFileDate}{2.0.2}{\ExplFileDescription}
\RequirePackage { xeCJK }
\exp_args:Nx \xeCJKsetup
  {
    LoadFandol   = false ,
    AutoFakeBold = true ,
    PunctStyle   = \l__ctex_punct_tl
  }
\@ifpackagelater { fontspec } { 2014/05/25 } { }
  { \msg_error:nnn { ctex } { package-too-old } { fontspec } }
\cs_new_protected_nopar:Npn \ctex_detected_platform:
  {
    \file_if_exist:nTF { /dev/null }
      {
        \file_if_exist:nTF { nul: }
          {
            \file_if_exist:nTF { \c__ctex_engine_file_tl }
              { \ctex_if_macosx:TF { mac } { windows } }
              { \ctex_if_macosx:TF { mac } { fandol } }
          }
          { \ctex_if_macosx:TF { mac } { fandol } }
      }
      { \tl_gset:Nn \g__ctex_fontset_tl { windows } }
  }
\tex_uppercase:D \exp_after:wN
  {
    \exp_after:wN \tl_const:Nn \exp_after:wN \c__ctex_engine_file_tl
    \exp_after:wN { \g_file_current_name_tl }
  }
\cs_new_protected_nopar:Npn \ctex_if_macosx:TF #1#2
  {
    \file_if_exist:nTF { \c__ctex_macosx_file_tl }
      { \tl_gset:Nn \g__ctex_fontset_tl {#1} }
      { \tl_gset:Nn \g__ctex_fontset_tl {#2} }
  }
\tl_const:Nn \c__ctex_macosx_file_tl { /mach_kernel }
\ctex_hypersetup:n { pdfencoding = unicode }
\RequirePackage { xeCJKfntef }
\clist_map_inline:nn
  { underdot , underline , underdblline , underwave , sout , xout }
  {
    \keys_set:nn { xeCJK / options } { #1 / format = { } }
    \cs_new_protected_nopar:cpx { CTEX#1 }
      {
        \msg_warning:nnnn { ctex } { deprecated-command } { \exp_not:c { CTEX#1 } }
          { You~ can~ use~ the~ command~ with~ prefix~ \exp_not:N \CJK~ instead. }
        \exp_not:c { CJK#1 }
      }
  }
\cs_new_protected_nopar:Npn { \CTEXfilltwosides }
  {
    \msg_warning:nnnn { ctex } { deprecated-environment } { CTEXfilltwosides }
      { You~ can~ use~ `CJKfilltwosides'~ environment~ instead. }
    \CJKfilltwosides
  }
\cs_new_protected_nopar:Npn { \endCTEXfilltwosides } { \endCJKfilltwosides }
\cs_new_protected_nopar:Npn \ctex_update_ccwd:
  {
    \hbox_set:Nn \l__ctex_tmp_box { \CJKglue }
    \dim_set:Nn \ccwd { \box_wd:N \l__ctex_tmp_box + \f@size \p@ }
  }
\dim_new:N \ccwd
\cs_new_protected_nopar:Npn \ctex_update_ccglue:
  { \xeCJKsetup { CJKglue = { \skip_horizontal:N \l__ctex_ccglue_skip } } }
\skip_new:N \l__ctex_ccglue_skip
\prg_new_conditional:Npnn \ctex_if_ccglue_touched: { TF }
  {
    \if_meaning:w \CJKglue \__ctex_ccglue:
      \prg_return_false: \else: \prg_return_true: \fi:
  }
\ctex_at_end:n { \cs_new_eq:NN \__ctex_ccglue: \CJKglue }
\cs_new_protected_nopar:Npn \ctex_update_em_unit:
  { \dim_set:Nn \ccwd { \f@size \p@ } }
\cs_new_protected:Npn \ctex_add_to_selectfont:n #1
  {
    \cs_set_protected_nopar:Npx \CTEX@selectfont@hook
      { \exp_not:o { \CTEX@selectfont@hook #1 } }
  }
\cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing:
\cs_new_eq:Nc \__ctex_save_selectfont: { selectfont ~ }
\use:n
  {
    \ExplSyntaxOff
    \ctex_preto_cmd:NnTF \selectfont { \CTEX@selectfont@hook }
      {
        \tl_put_left:Nn \@EverySelectfont@Init
          { \cs_set_eq:cN { selectfont ~ } \__ctex_save_selectfont: }
      }
      { \ctex_patch_failure:N \selectfont }
  }
\ExplSyntaxOn
\EverySelectfont { \CTEX@selectfont@hook }
\keys_define:nn { ctex }
  {
    space .choice: ,
    space / true  .code:n =
      { \xeCJKsetup { CJKspace = true } } ,
    space / auto  .code:n =
      { \xeCJKsetup { CJKspace = false } } ,
    space / false .code:n =
      { \xeCJKsetup { CJKspace = false } } ,
    space .default:n = { true } ,
    space .initial:n = { auto }
  }
\keys_define:nn { ctex }
  {
    punct .code:n =
      {
        \tl_set:Nx \l__ctex_punct_tl { #1 }
        \xeCJKsetup { PunctStyle = \l__ctex_punct_tl }
      } ,
    punct .default:n = { quanjiao } ,
  }
%% 
%%
%% End of file `ctex-engine-xetex.def'.
