%%
%% This is file `ctexsize.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ctex-kernel.dtx  (with options: `style,ctexsize')
%% -----------------------------------------------------------------------
%%   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'.             *
%% -----------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}[2026/06/01]
\RequirePackage{expl3}
\GetIdInfo $Id: ctex-kernel.dtx 2.6.3 2026-07-08 18:13:24 +0800 8c6212ee Mingyu Hsia <myhsia@outlook.com>$
  {Chinese font size definition (CTEX)}
\ProvidesExplPackage{ctexsize}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\cs_if_exist:NF \NewDocumentCommand
  { \RequirePackage { xparse } }
\prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexsize }
\RequirePackage { fix-cm }
\cs_new_protected:Npn \ctex_define_option:n
  { \keys_define:nn { ctex / option } }
\int_new:N \g__ctex_font_size_int
\int_gset:Nn \g__ctex_font_size_int { -1 }
\ctex_define_option:n
  {
    experiment / font-size-system .tl_gset:N = \g__ctex_font_size_system_tl ,
    experiment / font-size-system .initial:n = { word } ,
    experiment / font-size-system .value_required:n = true ,
    zihao .choice: ,
    zihao .value_required:n = true ,
    zihao /     5  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 0 } } ,
    zihao /    -4  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 1 } } ,
    zihao / false  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 2 } } ,
  }
\tl_clear_new:N \l__ctex_tmp_tl
\clist_map_inline:nn
  {
    10pt , 11pt , 12pt ,
     8pt ,  9pt , 14pt , 17pt , 20pt , 25pt , 30pt , 36pt , 48pt , 60pt
  }
  {
    \tl_put_right:Nn \l__ctex_tmp_tl
      {
        #1 .code:n =
          { \int_gset:Nn \g__ctex_font_size_int { 2 } } ,
        #1 .value_forbidden:n = true ,
      }
  }
\exp_args:No \ctex_define_option:n { \l__ctex_tmp_tl }
\tl_clear:N \l__ctex_tmp_tl
\cs_if_exist:NTF \ProcessKeyOptions
  { \ProcessKeyOptions [ ctex / option ] }
  {
    \RequirePackage { l3keys2e }
    \ProcessKeysOptions { ctex / option }
  }
\NewDocumentCommand \zihao { m }
  { \exp_args:Ne \ctex_zihao:n {#1} \tex_ignorespaces:D }
\cs_new_protected:Npn \ctex_zihao:n #1
  {
    \prop_get:NnNTF \c__ctex_font_size_prop {#1} \l__ctex_font_size_tl
      { \exp_after:wN \fontsize \l__ctex_font_size_tl \selectfont }
      { \msg_error:nnn { ctex } { fontsize } {#1} }
  }
\msg_new:nnnn { ctex } { fontsize }
  { Undefined~Chinese~font~size~`#1'~in~command~\token_to_str:N \zihao.}
  {
    The~old~font~size~is~used~if~you~continue.\\
    The~available~font~sizes~are~listed~as~follow.\\
    \seq_use:Nnnn \c__ctex_font_size_seq { ~and~ } { ,~ } { ,~and~ }.
  }
\prop_new:N \l__ctex_font_size_temp_prop
\seq_new:N  \l__ctex_font_size_temp_seq
\cs_new_protected:Npn \__ctex_save_font_size:nn #1#2
  {
    \prop_put:Nne \l__ctex_font_size_temp_prop {#1}
      {
        { \dim_to_decimal:n {#2} }
        { \dim_to_decimal:n { (#2) * 6 / 5 } }
      }
    \seq_put_right:Nn \l__ctex_font_size_temp_seq {#1}
  }
\cs_new_eq:NN \ctex_save_font_size:nn \__ctex_save_font_size:nn
\group_begin:
  \prop_clear:N \l__ctex_font_size_temp_prop
  \seq_clear:N  \l__ctex_font_size_temp_seq
  \str_case:onF { \g__ctex_font_size_system_tl }
    {
      { word }
      {
        \clist_map_inline:nn
          {
            {  8 } { 5    bp } ,
            {  7 } { 5.5  bp } ,
            { -6 } { 6.5  bp } ,
            {  6 } { 7.5  bp } ,
            { -5 } { 9    bp } ,
            {  5 } { 10.5 bp } ,
            { -4 } { 12   bp } ,
            {  4 } { 14   bp } ,
            { -3 } { 15   bp } ,
            {  3 } { 16   bp } ,
            { -2 } { 18   bp } ,
            {  2 } { 22   bp } ,
            { -1 } { 24   bp } ,
            {  1 } { 26   bp } ,
            { -0 } { 36   bp } ,
            {  0 } { 42   bp }
          }
          { \__ctex_save_font_size:nn #1 }
      }
      { letterpress }
      {
        \clist_map_inline:nn
          {
            {  8 } { 4    bp } ,
            {  7 } { 5.25 bp } ,
            { -6 } { 7.5  bp } ,
            {  6 } { 8    bp } ,
            { -5 } { 9    bp } ,
            {  5 } { 10.5 bp } ,
            { -4 } { 12   bp } ,
            {  4 } { 14   bp } ,
            { -3 } { 15   bp } ,
            {  3 } { 16   bp } ,
            { -2 } { 18   bp } ,
            {  2 } { 21   bp } ,
            { -1 } { 24   bp } ,
            {  1 } { 28   bp } ,
            { -0 } { 36   bp } ,
            {  0 } { 42   bp }
          }
          { \__ctex_save_font_size:nn #1 }
      }
    }
    {
      \file_if_exist:nTF { ctex-fontsize- \g__ctex_font_size_system_tl .def }
        {
          \ctex_file_input:n
            { ctex-fontsize- \g__ctex_font_size_system_tl .def }
        }
        {
          \msg_error:nne { ctex } { fontsize-system-not-found }
            { \g__ctex_font_size_system_tl }
          \clist_map_inline:nn
            {
              {  8 } { 5    bp } ,
              {  7 } { 5.5  bp } ,
              { -6 } { 6.5  bp } ,
              {  6 } { 7.5  bp } ,
              { -5 } { 9    bp } ,
              {  5 } { 10.5 bp } ,
              { -4 } { 12   bp } ,
              {  4 } { 14   bp } ,
              { -3 } { 15   bp } ,
              {  3 } { 16   bp } ,
              { -2 } { 18   bp } ,
              {  2 } { 22   bp } ,
              { -1 } { 24   bp } ,
              {  1 } { 26   bp } ,
              { -0 } { 36   bp } ,
              {  0 } { 42   bp }
            }
            { \__ctex_save_font_size:nn #1 }
        }
    }
  \exp_args:NNe \prop_const_from_keyval:Nn \c__ctex_font_size_prop
    { \prop_to_keyval:N \l__ctex_font_size_temp_prop }
  \exp_args:NNe \seq_const_from_clist:Nn \c__ctex_font_size_seq
    { \seq_use:Nn \l__ctex_font_size_temp_seq { , } }
\group_end:
\msg_new:nnnn { ctex } { fontsize-system-not-found }
  {
    CTeX~font~size~system~`#1'~could~not~be~found.
    \\ The~`word'~system~will~be~used~instead.
  }
  { You~may~need~to~create~`ctex-fontsize-#1.def'. }
\cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
  {
    \__ctex_get_font_sizes:Nn \l__ctex_font_size_tl { {#1} {#2} {#3} {#4} }
    \exp_after:wN \DeclareMathSizes \l__ctex_font_size_tl
  }
\cs_new_protected:Npn \__ctex_get_font_sizes:Nn #1#2
  {
    \tl_clear:N #1
    \tl_map_inline:nn {#2}
      {
        \prop_get:NnNTF \c__ctex_font_size_prop {##1} \l__ctex_tmp_tl
          { \tl_put_right:Ne #1 { { \tl_head:N \l__ctex_tmp_tl } } }
          { \tl_put_right:Ne #1 { { \dim_to_decimal:n { ##1 } } } }
      }
  }
\clist_map_inline:nn
  {
    {  8 }{  8 }{ 5pt }{ 5pt } ,
    {  7 }{  7 }{ 5pt }{ 5pt } ,
    { -6 }{ -6 }{ 5pt }{ 5pt } ,
    {  6 }{  6 }{ 5pt }{ 5pt } ,
    { -5 }{ -5 }{ 6pt }{ 5pt } ,
    {  5 }{  5 }{ 7pt }{ 5pt } ,
    { -4 }{ -4 }{ 8pt }{ 6pt } ,
    {  4 }{  4 }{  5 }{  6 } ,
    { -3 }{ -3 }{ -4 }{ -5 } ,
    {  3 }{  3 }{  4 }{  5 } ,
    { -2 }{ -2 }{ -3 }{ -4 } ,
    {  2 }{  2 }{  3 }{  4 } ,
    { -1 }{ -1 }{ -2 }{ -3 } ,
    {  1 }{  1 }{  2 }{  3 } ,
    { -0 }{ -0 }{ -1 }{ -2 } ,
    {  0 }{  0 }{  1 }{  2 }
  }
  { \ctex_declare_math_sizes:nnnn #1 }
\cs_new_protected:Npn \ctex_set_font_size:Nnn #1#2#3
  {
    \prop_get:NnNTF \c__ctex_font_size_prop {#2} \l__ctex_font_size_tl
      { \exp_after:wN \__ctex_set_font_size:nnNn \l__ctex_font_size_tl #1 {#3} }
      { \msg_error:nnn { ctex } { fontsize } {#2} }
  }
\cs_new_protected:Npn \__ctex_set_font_size:nnNn #1#2#3#4
  { \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
\int_case:nn { \g__ctex_font_size_int }
  {
    { 0 } { \file_input:n { ctex-c5size.clo } }
    { 1 } { \file_input:n { ctex-cs4size.clo } }
  }
\normalsize
%% -----------------------------------------------------------------------
%%   This work consists of the files ctex.dtx,                           *
%%                                   ctex-kernel.dtx,                    *
%%                                   ctex-engine.dtx,                    *
%%                                   ctex-scheme.dtx,                    *
%%                                   ctex-auxpkg.dtx,                    *
%%                                   ctex-fontset.dtx,                   *
%%                                   ctexpunct.spa,                      *
%%                                   ctxdoc.cls,                         *
%%                                   ctxdocstrip.tex,                    *
%%                                   ctex-zhconv.lua,                    *
%%                                   ctex-zhconv-index.lua,              *
%%                                   ctex-zhconv-make.lua,               *
%%                 the derived files ctex.ins,                           *
%%                                   ctex.sty,                           *
%%                                   ctexsize.sty,                       *
%%                                   ctexheading.sty,                    *
%%                                   ctexart.cls,                        *
%%                                   ctexbook.cls,                       *
%%                                   ctexrep.cls,                        *
%%                                   ctexbeamer.cls,                     *
%%                                   ctexcap.sty,                        *
%%                                   ctexhook.sty,                       *
%%                                   ctexpatch.sty,                      *
%%                                   ctex-c5size.clo,                    *
%%                                   ctex-cs4size.clo,                   *
%%                                   ctex-heading-article.def,           *
%%                                   ctex-heading-book.def,              *
%%                                   ctex-heading-report.def,            *
%%                                   ctex-heading-beamer.def,            *
%%                                   ctexbackend.cfg,                    *
%%                                   ctex-engine-pdftex.def,             *
%%                                   ctex-engine-xetex.def,              *
%%                                   ctex-engine-luatex.def,             *
%%                                   ctex-engine-aptex.def,              *
%%                                   ctex-engine-uptex.def,              *
%%                                   ctex-name-utf8.cfg,                 *
%%                                   ctex-name-gbk.cfg,                  *
%%                                   ctex.cfg,                           *
%%                                   ctexopts.cfg,                       *
%%                                   ctex-scheme-plain.def,              *
%%                                   ctex-scheme-plain-article.def,      *
%%                                   ctex-scheme-plain-book.def,         *
%%                                   ctex-scheme-plain-report.def,       *
%%                                   ctex-scheme-plain-beamer.def,       *
%%                                   ctex-scheme-chinese.def,            *
%%                                   ctex-scheme-chinese-article.def,    *
%%                                   ctex-scheme-chinese-book.def,       *
%%                                   ctex-scheme-chinese-report.def,     *
%%                                   ctex-scheme-chinese-beamer.def,     *
%%                                   ctex-fontset-adobe.def,             *
%%                                   ctex-fontset-fandol.def,            *
%%                                   ctex-fontset-founder.def,           *
%%                                   ctex-fontset-hanyi.def,             *
%%                                   ctex-fontset-mac.def,               *
%%                                   ctex-fontset-macnew.def,            *
%%                                   ctex-fontset-macold.def,            *
%%                                   ctex-fontset-ubuntu.def,            *
%%                                   ctex-fontset-windows.def,           *
%%                                   c19rm.fd,                           *
%%                                   c19sf.fd,                           *
%%                                   c19tt.fd,                           *
%%                                   c70rm.fd,                           *
%%                                   c70sf.fd,                           *
%%                                   c70tt.fd,                           *
%%                                   jy2zhrm.fd,                         *
%%                                   jy2zhsf.fd,                         *
%%                                   jy2zhtt.fd,                         *
%%                                   jt2zhrm.fd,                         *
%%                                   jt2zhsf.fd,                         *
%%                                   jt2zhtt.fd,                         *
%%                                   ctexspa.def,                        *
%%                     translator-theorem-dictionary-ChineseUTF8.dict,   *
%%                     translator-theorem-dictionary-ChineseGBK.dict,    *
%%                                   ctex-spa-make.tex,                  *
%%                                   ctex-spa-macro.tex,                 *
%%                                   ctex-zhmap-adobe.tex,               *
%%                                   ctex-zhmap-fandol.tex,              *
%%                                   ctex-zhmap-founder.tex,             *
%%                                   ctex-zhmap-hanyi.tex,               *
%%                                   ctex-zhmap-mac.tex,                 *
%%                                   ctex-zhmap-ubuntu.tex,              *
%%                                   ctex-zhmap-windows.tex,             *
%%           the documentation files ctex.pdf,                           *
%%                               and README.md.                          *
%% -----------------------------------------------------------------------
%%
%% End of file `ctexsize.sty'.
