%%
%% This is file `ctex-engine-pdftex.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ctex-engine.dtx  (with options: `pdftex')
%% -----------------------------------------------------------------------
%%   Copyright (C) 2003--2026                                            *
%%   CTEX.ORG and any individual authors listed elsewhere in this file.  *
%% -----------------------------------------------------------------------
%%   This work may be distributed and/or modified under the conditions   *
%%   of the LaTeX Project Public License (LPPL), 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 2008 or later.                                              *
%%                                                                       *
%%   This work has the LPPL maintenance status `maintained'.             *
%% -----------------------------------------------------------------------
\GetIdInfo $Id: ctex-engine.dtx 2.6.2 2026-07-06 20:43:36 +0800 dbfd7c43 Mingyu Hsia <myhsia@outlook.com>$
  {(pdf)LaTeX adapter (CTEX)}
\ProvidesExplFile{ctex-engine-pdftex.def}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\cs_new_protected:Npn \ctex_set_zhmap:n
  { \tl_gput_right:Ne \g__ctex_zhmap_tl }
\cs_new_protected:Npn \ctex_use_zhmap:
  { \tl_use:N \g__ctex_zhmap_tl }
\cs_if_exist:NTF \ctex_gadd_ltxhook:nn
  {
    \cs_new_protected:Npn \ctex_at_shipout_first:n
      { \ctex_gadd_ltxhook:nn { shipout/firstpage } }
    \ctex_at_shipout_first:n { \ctex_use_zhmap: }
  }
  {
    \cs_new_protected:Npn \ctex_add_dvi_zhmap:
      { \AtBeginDvi { \ctex_use_zhmap: } }
    \ctex_after_end_preamble:n { \ctex_add_dvi_zhmap: }
    \ctex_at_end_package:nn { atbegshi }
      {
        \cs_new_protected:Npn \ctex_at_shipout_first:n
          { \AtBeginShipoutFirst }
        \ctex_at_shipout_first:n { \ctex_use_zhmap: }
        \cs_gset_eq:NN \ctex_add_dvi_zhmap: \prg_do_nothing:
      }
  }
\tl_new:N \g__ctex_zhmap_tl
\@onlypreamble \ctex_set_zhmap:n
\seq_const_from_clist:Nn \c__ctex_cmap_encoding_seq
  { C19 , C10 , C00 , C09 , C40 , C60 }
\cs_new_protected:Npn \ctex_family_cmap:nn #1#2
  {
    \cs_if_free:cF { #1 + #2 }
      {
        \seq_if_in:NnT \c__ctex_cmap_encoding_seq {#1}
          { \tl_gput_right:cn { #1 + #2 } { \ctex_add_cmap:n {#1} } }
      }
  }
\cs_generate_variant:Nn \ctex_family_cmap:nn { ee }
\cs_new_eq:NN \CTEX@Family@CMap \ctex_family_cmap:ee
\cs_new_protected:Npn \ctex_add_cmap:n #1
  {
    \cs_if_free:NF \CJK@plane
      { \exp_args:Ne \__ctex_add_cmap_auxi:n { #1 \CJK@plane } }
  }
\cs_new_protected:Npn \__ctex_add_cmap_auxi:n #1
  { \exp_args:Nc \__ctex_add_cmap_auxii:Nn { __ctex_add_cmap_ #1 : } {#1} }
\cs_new_protected:Npn \__ctex_add_cmap_auxii:Nn #1#2
  {
    \cs_if_exist:NF #1 { \__ctex_save_cmap:Nn #1 {#2} }
    #1
  }
\cs_new_protected:Npn \__ctex_save_cmap:Nn #1#2
  {
    \exp_args:Ne \file_get_full_name:nNTF
      { \str_lowercase:n {#2} .cmap } \l__ctex_cmap_file_tl
      {
        \pdf_object_unnamed_write:ne
          { fstream }
          { { } { \l__ctex_cmap_file_tl } }
        \cs_new_protected:Npx #1
          {
            \pdfnobuiltintounicode \tex_font:D
            \tex_pdffontattr:D \tex_font:D
              { /ToUnicode ~ \pdf_object_ref_last: }
          }
      }
      { \cs_new_eq:NN #1 \prg_do_nothing: }
  }
\tl_new:N \l__ctex_cmap_file_tl
\sys_if_output_pdf:T
  {
    \exp_args:Nno \use:n
      { \cs_gset_protected:Npn \DeclareFontFamily #1#2#3 }
      {
        \DeclareFontFamily {#1} {#2} {#3}
        \CTEX@Family@CMap  {#1} {#2}
      }
    \ctex_at_end_package:nn { cmap }
      {
        \cs_gset_eq:NN \ctex_add_cmap:n \use_none:n
        \cs_gset_eq:NN \CTEX@Family@CMap \use_none:nn
      }
  }
\bool_if:NTF \g__ctex_zhmCJK_bool
  {
    \exp_args:Ne \PassOptionsToPackage
      { encoding = \g__ctex_encoding_tl }
      { zhmCJK }
    \RequirePackage { zhmCJK }
  }
  {
    \str_if_eq:onTF { \g__ctex_encoding_tl } { GBK }
      { \RequirePackage { CJK } }
      { \RequirePackage { CJKutf8 } }
    \RequirePackage { CJKpunct , CJKspace }
    \cs_new_protected:Npn \ctex_load_zhmap:nnnn #1#2#3#4
      {
        \tl_set:Nn \CJKrmdefault {#1}
        \tl_set:Nn \CJKsfdefault {#2}
        \tl_set:Nn \CJKttdefault {#3}
        \ctex_set_zhmap:n { \ctex_file_input:n { ctex-zhmap- #4 .tex } }
      }
    \@onlypreamble \ctex_load_zhmap:nnnn
  }
\cs_new_protected:Npn \ctex_undeclare_unicode_character:n #1
  { \cs_set_eq:cN { u8 : \codepoint_str_generate:n {#1} } \tex_undefined:D }
\CJKaddEncHook { UTF8 }
  {
    \ctex_undeclare_unicode_character:n { "3008 }
    \ctex_undeclare_unicode_character:n { "3009 }
  }
\cs_new_protected:Npn \ctex_CJK_input:n #1
  {
    \ctex_push_file:
      \int_set:Nn \tex_endlinechar:D { -1 }
      \file_input:n {#1}
    \ctex_pop_file:
  }
\cs_set_eq:NN \CJK@input \ctex_CJK_input:n
\cs_if_free:NF \CJK@surr
  {
    \cs_new_protected:Npn \ctex_plane_to_utfxvibe:Nn #1#2
      {
        \int_set:Nn \l__ctex_tmp_int
          { \exp_args:Ne \int_from_hex:n {#2} }
        \int_compare:nNnTF \l__ctex_tmp_int < { 256 }
          { \tl_gset:Ne #1 { \int_to_Hex:n { \l__ctex_tmp_int } } }
          {
            \int_sub:Nn \l__ctex_tmp_int { 256 }
            \tl_gset:Ne #1
              {
                \int_to_Hex:n
                  { \int_div_truncate:nn { \l__ctex_tmp_int } { 4 } + "D800 }
                \int_to_Hex:n
                  { \int_mod:nn { \l__ctex_tmp_int } { 4 } + "DC }
              }
          }
      }
    \cs_set_eq:NN \CJK@surr \ctex_plane_to_utfxvibe:Nn
  }
\cs_if_free:NF \CJK@addcmap
  {
    \ctex_patch_cmd:Nnn \CJK@addcmap
      { \pdffontattr \font@name }
      {
        \pdfnobuiltintounicode \font@name
        \pdffontattr \font@name
      }
  }
\AtBeginDocument
  {
    \use:e
      {
        \str_if_eq:nnF { \l__ctex_punct_tl } { quanjiao }
          { \exp_not:N \punctstyle { \l__ctex_punct_tl } }
      }
  }
\ctex_at_end_preamble:n { \ctex_update_default_family: }
\bool_if:NF \g__ctex_zhmCJK_bool
  {
    \str_if_eq:onTF { \g__ctex_encoding_tl } { UTF8 }
      { \CJK@loadBinding { UTF8 } }
      { \CJK@loadBinding { standard } }
    \exp_args:Ne \ctex_at_end_preamble:n
      {
        \exp_not:N \CJK@envStart
          { } { \g__ctex_encoding_tl } { \exp_not:N \CJKfamilydefault }
        \exp_not:N \CJKtilde
      }
  }
\cs_new_eq:NN \ctex_auto_ignorespaces: \CJK@@ignorespaces
\cs_new:Npn \__ctex_char:N #1
  { \exp_args:Ne \CTEX@char@n { \int_value:w `#1 } }
\cs_new:Npn \__ctex_char:NN #1#2
  {
    \token_if_eq_meaning:NNTF #2 \protect
      { \__ctex_char_aux:NN #1 }
      { \__ctex_char_aux:NN #1#2 }
  }
\cs_new:Npn \__ctex_char_aux:NN #1#2
  {
    \exp_last_unbraced:Ne \CTEX@char@nn
      {
        { \int_value:w `#1 }
        { \int_value:w `#2 }
      }
  }
\cs_new:Npn \__ctex_char:NNN #1#2#3
  {
    \token_if_eq_meaning:NNTF #2 \protect
      { \__ctex_char_auxi:NNNN #1#3 }
      { \__ctex_char_auxii:NNN #1#2#3 }
  }
\cs_new:Npn \__ctex_char_auxi:NNNN #1#2#3#4
  { \__ctex_char_auxii:NNN #1#2#4 }
\cs_new:Npn \__ctex_char_auxii:NNN #1#2#3
  {
    \exp_last_unbraced:Ne \CTEX@char@nnn
      {
        { \int_value:w `#1 }
        { \int_value:w `#2 }
        { \int_value:w `#3 }
      }
  }
\cs_new:Npn \__ctex_char:NNNN #1#2#3#4
  {
    \token_if_eq_meaning:NNTF #2 \protect
      { \__ctex_char_auxi:NNNNN #1#3 }
      { \__ctex_char_auxii:NNNN #1#2#3#4 }
  }
\cs_new:Npn \__ctex_char_auxi:NNNNN #1#2#3#4#5
  { \__ctex_char_auxii:NNNN #1#2#3#5 }
\cs_new:Npn \__ctex_char_auxii:NNNN #1#2#3#4
  {
    \exp_last_unbraced:Ne \CTEX@char@nnnn
      {
        { \int_value:w `#1 }
        { \int_value:w `#2 }
        { \int_value:w `#3 }
        { \int_value:w `#4 }
      }
  }
\cs_gset_eq:NN \CJK@X    \__ctex_char:N
\cs_gset_eq:NN \CJK@XX   \__ctex_char:NN
\cs_gset_eq:NN \CJK@XXX  \__ctex_char:NNN
\cs_gset_eq:NN \CJK@XXXX \__ctex_char:NNNN
\str_if_eq:onF { \g__ctex_encoding_tl } { GBK }
  {
    \exp_args:Nne \use:n
      { \cs_gset:Npn \__ctex_char_aux:NN #1#2 }
      {
        \exp_not:N \cs_if_exist_use:cF
          { u8: \exp_not:N \tl_to_str:n { #1#2 } }
          { \exp_not:o { \__ctex_char_aux:NN {#1} {#2} } }
      }
    \exp_args:Nne \use:n
      { \cs_gset:Npn \__ctex_char_auxii:NNN #1#2#3 }
      {
        \exp_not:N \cs_if_exist_use:cF
          { u8: \exp_not:N \tl_to_str:n { #1#2#3 } }
          { \exp_not:o { \__ctex_char_auxii:NNN {#1} {#2} {#3} } }
      }
    \exp_args:Nne \use:n
      { \cs_gset:Npn \__ctex_char_auxii:NNNN #1#2#3#4 }
      {
        \exp_not:N \cs_if_exist_use:cF
          { u8: \exp_not:N \tl_to_str:n { #1#2#3#4 } }
          { \exp_not:o { \__ctex_char_auxii:NNNN {#1} {#2} {#3} {#4} } }
      }
  }
\group_begin:
\char_set_catcode_active:n { "7F }
\cs_new:Npn \__ctex_char_preproc:w #1 ^^7f #2 ^^7f
  { \exp_args:No \CTEX@char@nn { \int_value:w `#1 } {#2} }
\cs_gset_eq:NN \mule@arg \__ctex_char_preproc:w
\group_end:
\exp_args:Ne \ctex_at_end:n
  {
    \char_set_catcode:nn
      { \int_value:w "7F }
      { \char_value_catcode:n { "7F } }
  }
\cs_new_protected:Npn \CTEX@char@n #1
  {
    \mode_leave_vertical:
    \use:c { CJK@ #1 }
    \CJK@ignorespaces
  }
\cs_new_protected:Npn \CTEX@char@nn #1#2
  {
    \mode_leave_vertical:
    \use:c { CJK@ #1 } {#2}
    \CJK@ignorespaces
  }
\cs_new_protected:Npn \CTEX@char@nnn  #1#2#3
  {
    \mode_leave_vertical:
    \use:c { CJK@ #1 } {#2} {#3}
    \CJK@ignorespaces
  }
\cs_new_protected:Npn \CTEX@char@nnnn #1#2#3#4
  {
    \mode_leave_vertical:
    \use:c { CJK@ #1 } {#2} {#3} {#4}
    \CJK@ignorespaces
  }
\cs_new_protected:Npn \CTEX@char@nn@n   #1 { \CTEX@char@nn   #1 }
\cs_new_protected:Npn \CTEX@char@nnn@n  #1 { \CTEX@char@nnn  #1 }
\cs_new_protected:Npn \CTEX@char@nnnn@n #1 { \CTEX@char@nnnn #1 }
\cs_new:Npn \__ctex_char_wrap:nn #1#2
  { \CTEX@char@nn@n   { {#1} {#2} } }
\cs_new:Npn \__ctex_char_wrap:nnn #1#2#3
  { \CTEX@char@nnn@n  { {#1} {#2} {#3} } }
\cs_new:Npn \__ctex_char_wrap:nnnn #1#2#3#4
  { \CTEX@char@nnnn@n { {#1} {#2} {#3} {#4} } }
\tl_put_right:Nn \l_text_case_exclude_arg_tl
  {
    \CTEX@char@n
    \CTEX@char@nn@n
    \CTEX@char@nnn@n
    \CTEX@char@nnnn@n
  }
\text_declare_expand_equivalent:Nn \CTEX@char@nn   { \__ctex_char_wrap:nn }
\text_declare_expand_equivalent:Nn \CTEX@char@nnn  { \__ctex_char_wrap:nnn }
\text_declare_expand_equivalent:Nn \CTEX@char@nnnn { \__ctex_char_wrap:nnnn }
\cs_new:Npn \__ctex_char_raw:n #1
  { \char_generate:nn {#1} { 12 } }
\cs_new:Npn \__ctex_char_raw:nn #1#2
  {
    \char_generate:nn {#1} { 12 }
    \char_generate:nn {#2} { 12 }
  }
\cs_new:Npn \__ctex_char_raw:nnn #1#2#3
  {
    \char_generate:nn {#1} { 12 }
    \char_generate:nn {#2} { 12 }
    \char_generate:nn {#3} { 12 }
  }
\cs_new:Npn \__ctex_char_raw:nnnn #1#2#3#4
  {
    \char_generate:nn {#1} { 12 }
    \char_generate:nn {#2} { 12 }
    \char_generate:nn {#3} { 12 }
    \char_generate:nn {#4} { 12 }
  }
\cs_new:Npn \__ctex_char_raw_nn:n   #1 { \use:e { \__ctex_char_raw:nn   #1 } }
\cs_new:Npn \__ctex_char_raw_nnn:n  #1 { \use:e { \__ctex_char_raw:nnn  #1 } }
\cs_new:Npn \__ctex_char_raw_nnnn:n #1 { \use:e { \__ctex_char_raw:nnnn #1 } }
\text_declare_purify_equivalent:Nn \CTEX@char@n      { \__ctex_char_raw:n }
\text_declare_purify_equivalent:Nn \CTEX@char@nn@n   { \__ctex_char_raw_nn:n }
\text_declare_purify_equivalent:Nn \CTEX@char@nnn@n  { \__ctex_char_raw_nnn:n }
\text_declare_purify_equivalent:Nn \CTEX@char@nnnn@n { \__ctex_char_raw_nnnn:n }
\cs_new_protected:Npn \ctex_ignorespaces_case:N #1
  {
    \cs_set_protected:Npn \ctex_set_ignorespaces:
      { \cs_set_eq:NN \CJK@ignorespaces #1 }
    \ctex_set_ignorespaces:
  }
\cs_new_protected:Npn \ctex_set_ignorespaces:
  { \cs_set_eq:NN \CJK@ignorespaces \ctex_auto_ignorespaces: }
\tl_if_exist:NF \CJKhook { \tl_new:N \CJKhook }
\tl_gput_right:Nn \CJKhook { \ctex_set_ignorespaces: }
\cs_new_protected:Npn \ctex_punct_set:n #1
  {
    \clist_map_inline:Nn \c__ctex_punct_family_clist
      {
        \cs_if_free:cF { c__ctex_ #1 ##1 _punct_spaces_tl }
          {
            \cs_set_eq:cc
              { CJKpunct@ ##1 @spaces }
              { c__ctex_ #1 ##1 _punct_spaces_tl }
          }
      }
  }
\clist_const:Nn \c__ctex_punct_family_clist
  {
    zhsong , zhhei , zhfs , zhkai , zhli , zhyou ,
    zhsongb , zhheil , zhheib , zhyoub ,
    zhyahei , zhyaheib , zhpf , zhpfb
  }
\cs_new_protected:Npn \ctex_punct_map_family:nn #1#2
  {
    \cs_if_free:cF { CJKpunct@ #2 @spaces }
      { \cs_set_eq:cc { CJKpunct@ #1 @spaces } { CJKpunct@ #2 @spaces } }
  }
\cs_new_protected:Npn \ctex_punct_map_bfseries:nn #1#2
  {
    \clist_map_inline:nn {#1}
      {
        \ctex_punct_map_series:nnn { ##1 } { b } {#2}
        \ctex_punct_map_series:nnn { ##1 } { bx } {#2}
      }
  }
\cs_new_protected:Npn \ctex_punct_map_series:nnn #1#2#3
  {
    \CJKpunctmapfamily { C19 } {#1} {#2} { m }  {#3}
    \CJKpunctmapfamily { C19 } {#1} {#2} { it } {#3}
    \CJKpunctmapfamily { C19 } {#1} {#2} { sl } {#3}
    \CJKpunctmapfamily { C70 } {#1} {#2} { m }  {#3}
    \CJKpunctmapfamily { C70 } {#1} {#2} { it } {#3}
    \CJKpunctmapfamily { C70 } {#1} {#2} { sl } {#3}
  }
\cs_new_protected:Npn \ctex_punct_map_itshape:nn #1#2
  {
    \CJKpunctmapfamily { C19 } {#1} { m }  { it } {#2}
    \CJKpunctmapfamily { C19 } {#1} { b }  { it } {#2}
    \CJKpunctmapfamily { C19 } {#1} { bx } { it } {#2}
    \CJKpunctmapfamily { C70 } {#1} { m }  { it } {#2}
    \CJKpunctmapfamily { C70 } {#1} { b }  { it } {#2}
    \CJKpunctmapfamily { C70 } {#1} { bx } { it } {#2}
  }
\cs_new_protected:Npn \ctex_punct_space:nn #1#2
  { \tl_const:cn { c__ctex_ #1 _punct_spaces_tl } {#2} }
\cs_new_eq:NN \ctexspadef \ctex_punct_space:nn
\ctex_file_input:n { ctexspa.def }
\reverse_if:N \if_bool:N \g__ctex_zhmCJK_bool
\cs_new_protected:Npn \ctex_provide_font_hook:NNN #1#2
  {
    \exp_args:Nc \__ctex_provide_font_hook_aux:NNNN
      { CTEX \cs_to_str:N #2 } #1#2
  }
\cs_new_protected:Npn \__ctex_provide_font_hook_aux:NNNN #1#2#3#4
  {
    \tl_new:N #1
    \exp_args:Ne \ctex_gadd_ltxhook:nn { \cs_to_str:N #2 } {#1}
  }
\ctex_provide_font_hook:NNN \rmfamily \@rmfamilyhook \selectfont
\ctex_provide_font_hook:NNN \sffamily \@sffamilyhook \selectfont
\ctex_provide_font_hook:NNN \ttfamily \@ttfamilyhook \selectfont
\ctex_provide_font_hook:NNN \normalfont \@defaultfamilyhook \usefont
\tl_if_exist:NF \CJKfamilydefault
  { \tl_const:Nn \CJKfamilydefault { \CJKrmdefault } }
\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { rm } }
\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { sf } }
\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { tt } }
\tl_gput_right:Nn \CTEX@rmfamilyhook { \CJKfamily { \CJKrmdefault } }
\tl_gput_right:Nn \CTEX@sffamilyhook { \CJKfamily { \CJKsfdefault } }
\tl_gput_right:Nn \CTEX@ttfamilyhook { \CJKfamily { \CJKttdefault } }
\tl_gput_right:Nn \CTEX@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } }
\fi:
\normalfont
\cs_new_protected:Npn \ctex_update_default_family:
  {
    \tl_if_eq:NNT \CJKfamilydefault \l__ctex_family_default_init_tl
      {
        \group_begin:
          \cs_set_eq:NN \__ctex_family_default_wrap:n \exp_not:n
          \tl_gset:Ne \CJKfamilydefault
            {
              \str_case:onF { \familydefault }
                {
                  { \rmdefault } { \exp_not:N \CJKrmdefault }
                  { \sfdefault } { \exp_not:N \CJKsfdefault }
                  { \ttdefault } { \exp_not:N \CJKttdefault }
                }
                { \CJKfamilydefault }
            }
        \group_end:
      }
  }
\tl_new:N \l__ctex_family_default_init_tl
\cs_new_eq:NN \__ctex_family_default_wrap:n \use:n
\tl_set:Ne \l__ctex_family_default_init_tl
  {
    \exp_not:N \__ctex_family_default_wrap:n
      { \exp_not:o { \CJKfamilydefault } }
  }
\tl_gset_eq:NN \CJKfamilydefault \l__ctex_family_default_init_tl
\@ifpackageloaded { hyperref }
  { }
  { \PassOptionsToPackage { driverfallback = dvipdfmx } { hyperref } }
\str_if_eq:onTF { \g__ctex_encoding_tl } { GBK }
  {
    \ctex_hypersetup:n { CJKbookmarks = true }
    \sys_if_output_pdf:TF
      { \ctex_at_end_package:nn { hyperref } { \RequirePackage { xCJK2uni } } }
      {
        \ctex_hypersetup:n { pdfencoding = pdfdoc }
        \ctex_at_end_package:nn { hyperref }
          {
            \str_if_eq:onTF { \Hy@driver } { hdvipdfm }
              {
                \ctex_at_shipout_first:n
                  { \special { pdf:tounicode~GBK-EUC-UCS2 } }
              }
              { \RequirePackage { xCJK2uni } }
          }
      }
  }
  { \ctex_hypersetup:n { pdfencoding = unicode } }
\ctex_at_end_package:nn { CJKfntef }
  {
    \normalem
    \cs_new_protected:Npn \__ctex_clear_fntef_color:n #1
      { \tl_clear:c { CJK#1color } }
    \clist_map_inline:nn
      { underdot , underline , underdblline , underwave , sout , xout }
      { \__ctex_clear_fntef_color:n {#1} }
  }
\cs_new_protected: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:Npn \ctex_update_ccglue:
  {
    \cs_set_protected:Npn \CJKglue
      { \skip_horizontal:N \l__ctex_ccglue_skip }
    \cs_if_exist:NT \__ctex_ccglue:
      { \cs_set_eq:NN \__ctex_ccglue: \CJKglue }
  }
\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 }
\ctex_at_end:n
  {
    \cs_set_protected:Npn \__ctex_update_stretch_auxii:
      {
        \ctex_if_ccglue_touched:TF
          { \ctex_update_ccwd: }
          { \__ctex_update_stretch_auxiii: }
      }
  }
\cs_new_protected: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:Npx \CTEX@selectfont@hook
      { \exp_not:o { \CTEX@selectfont@hook #1 } }
  }
\cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing:
\bool_if:NTF \c__ctex_everysel_loaded_bool
  {
    \cs_if_free:NF \@EverySelectfont@Init
      {
        \group_begin:
        \cs_set:Npn \__ctex_tmp:N #1
          {
            \tl_set:Nn \l__ctex_tmp_tl {#1}
            \cs_new_eq:NN \CTEX@selectfont@save #1
            \cs_new_protected:Npn \__ctex_restore_selectfont:
              {
                \cs_if_free:NF \scr@new@selectfont
                  {
                    \cs_if_free:NF \par@update
                      { \tl_put_right:Nn #1 { \par@update } }
                    \cs_set_eq:NN \scr@selectfont \CTEX@selectfont@save
                    \cs_set_eq:NN \scr@new@selectfont #1
                  }
                \tl_put_left:Nn \@EverySelectfont@Init
                  { \cs_set_eq:NN #1 \CTEX@selectfont@save }
                \cs_undefine:N \__ctex_restore_selectfont:
              }
          }
        \ctex_parse_name:NN \__ctex_tmp:N \selectfont
      \exp_last_unbraced:NNo \group_end:
      \ctex_patch_cmd_once:NnnnTF { \l__ctex_tmp_tl }
        { \ExplSyntaxOff }
        { \size@update }
        { \CTEX@selectfont@hook \size@update }
        { \__ctex_restore_selectfont: }
        { \ctex_patch_failure:N \selectfont }
      }
    \cs_new_protected:Npn \ctex_gadd_selectfont_hook:n
      { \EverySelectfont }
  }
  {
    \cs_new_protected:Npn \ctex_gadd_selectfont_hook:n
      { \ctex_gadd_ltxhook:nn { selectfont } }
  }
\ctex_gadd_selectfont_hook:n
  { \cs_if_exist:NF \CJK@plane { \CTEX@selectfont@hook } }
\ctex_define:n
  {
    space .choice: ,
    space / true  .code:n =
      { \ctex_ignorespaces_case:N \prg_do_nothing: } ,
    space / auto  .code:n =
      { \ctex_ignorespaces_case:N \ctex_auto_ignorespaces: } ,
    space / false .code:n =
      { \ctex_ignorespaces_case:N \tex_ignorespaces:D } ,
    space .default:n = { true } ,
    space .initial:n = { auto }
  }
\ctex_define:n
  {
    punct .code:n =
      {
        \tl_set:Ne \l__ctex_punct_tl {#1}
        \punctstyle { \l__ctex_punct_tl }
      } ,
    punct .default:n = { quanjiao } ,
  }
\ctex_define:n
  { experiment .meta:nn = { ctex / experiment } {#1} }
\keys_define:nn { ctex / experiment }
  {
    CJKecglue .code:n =
      { \msg_warning:nn { ctex } { CJKecglue-unsupported } } ,
    CJKecglue .value_required:n = true
  }
%% 
%%
%% End of file `ctex-engine-pdftex.def'.
