diff options
author | Karl Berry <karl@freefriends.org> | 2020-05-02 22:24:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-05-02 22:24:14 +0000 |
commit | 15f0c94913f0d5cb24dd909c5358b3a997994dd7 (patch) | |
tree | 9043df32cd0199835f5b3f9804ad132907857139 /Master/texmf-dist/tex/latex/ctex/engine | |
parent | 151fbc4b66cb3705f6ce20368a2c6f7c06b8d57d (diff) |
ctex (2may20)
git-svn-id: svn://tug.org/texlive/trunk@54976 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ctex/engine')
5 files changed, 592 insertions, 702 deletions
diff --git a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-aptex.def b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-aptex.def index 8cd15c75bb6..24584de60d4 100644 --- a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-aptex.def +++ b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-aptex.def @@ -6,9 +6,9 @@ %% %% ctex.dtx (with options: `aptex') %% -%% Copyright (C) 2003--2019 +%% Copyright (C) 2003--2020 %% 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 @@ -20,57 +20,42 @@ %% 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'. +%% 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 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee@gmail.com> $ {Asian pTeX adapter (CTEX)} \ProvidesExplFile{ctex-engine-aptex.def} - {\ExplFileDate}{2.4.16}{\ExplFileDescription} -\cs_new_protected_nopar:Npn \ctex_set_zhmap:n #1 - { - \AtBeginDvi {#1} - \ctex_at_end_package:nn { atbegshi } - { \AtBeginShipoutFirst {#1} } - } + {\ExplFileDate}{2.5.1}{\ExplFileDescription} +\cs_new_protected:Npn \ctex_set_zhmap:n + { \tl_gput_right:Nx \g__ctex_zhmap_tl } +\cs_new_protected:Npn \ctex_use_zhmap: + { \tl_use:N \g__ctex_zhmap_tl } +\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 } + { + \AtBeginShipoutFirst { \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 -\tl_set:Nn \CJKrmdefault { zhrm } -\tl_set:Nn \CJKsfdefault { zhsf } -\tl_set:Nn \CJKttdefault { zhtt } -\tl_set:Nn \CJKfamilydefault { \CJKrmdefault } +\tl_if_exist:NF \CJKfamilydefault + { \tl_const:Nn \CJKfamilydefault { \CJKrmdefault } } +\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { zhrm } } +\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { zhsf } } +\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { zhtt } } \tl_set:Nn \kanjifamilydefault { \CJKfamilydefault } -\RenewDocumentCommand \rmfamily { } - { - \not@math@alphabet \rmfamily \mathrm - \romanfamily \rmdefault - \kanjifamily \CJKrmdefault - \selectfont - } -\RenewDocumentCommand \sffamily { } - { - \not@math@alphabet \sffamily \mathsf - \romanfamily \sfdefault - \kanjifamily \CJKsfdefault - \selectfont - } -\RenewDocumentCommand \ttfamily { } - { - \not@math@alphabet \ttfamily \mathtt - \romanfamily \ttdefault - \kanjifamily \CJKttdefault - \selectfont - } +\g@addto@macro \@rmfamilyhook { \kanjifamily { \CJKrmdefault } } +\g@addto@macro \@sffamilyhook { \kanjifamily { \CJKsfdefault } } +\g@addto@macro \@ttfamilyhook { \kanjifamily { \CJKttdefault } } \NewDocumentCommand \CJKfamily { m } - { - \kanjifamily {#1} - \selectfont - } -\DeclareErrorKanjiFont{JY2}{zhrm}{m}{n}{10} -\DeclareKanjiSubstitution{JY2}{zhrm}{m}{n} -\DeclareKanjiSubstitution{JT2}{zhrm}{m}{n} + { \kanjifamily {#1} \selectfont } +\DeclareErrorKanjiFont {JY2}{zhrm}{m}{n}{10} +\DeclareKanjiSubstitution {JY2}{zhrm}{m}{n} +\DeclareKanjiSubstitution {JT2}{zhrm}{m}{n} \DeclareSymbolFont{mincho}{JY2}{zhrm}{m}{n} \SetSymbolFont{mincho}{bold}{JY2}{zhrm}{bx}{n} \jfam \symmincho @@ -87,43 +72,59 @@ { \eminnershape \else \itshape } } \cs_set_nopar:Npn \eminnershape { \upshape } -\cs_new_protected_nopar:Npn \ctex_set_upfamily:nnn #1 #2 #3 +\cs_new_protected:Npn \ctex_set_upfamily:nnn #1#2#3 { \DeclareKanjiFamily{JY2}{#1}{} \DeclareKanjiFamily{JT2}{#1}{} \DeclareFontShape{JY2}{#1}{m}{n}{<->~ #2-h}{} \DeclareFontShape{JT2}{#1}{m}{n}{<->~ #2-v}{} - \tl_if_empty:nF { #3 } + \tl_if_empty:nF {#3} { + \DeclareFontShape{JY2}{#1}{b}{n}{<->~ #3-h}{} + \DeclareFontShape{JT2}{#1}{b}{n}{<->~ #3-v}{} \DeclareFontShape{JY2}{#1}{bx}{n}{<->~ #3-h}{} \DeclareFontShape{JT2}{#1}{bx}{n}{<->~ #3-v}{} } } -\@onlypreamble \ctex_set_upfamily:nnn -\cs_new_protected_nopar:Npn \ctex_set_upmap:nnn #1 #2 #3 +\cs_new_protected:Npn \ctex_set_upmap:nnn #1#2#3 { \ctex_set_zhmap:n { - \special{ pdf:mapline~ #1-h~ UniGB-UTF16-H~ #2 } - \special{ pdf:mapline~ #1-v~ UniGB-UTF16-V~ #2 } - \tl_if_empty:nF { #3 } + \special { pdf:mapline~#1-h~UniGB-UTF16-H~#2 } + \special { pdf:mapline~#1-v~UniGB-UTF16-V~#2 } + \tl_if_empty:nF {#3} { - \special{ pdf:mapline~ #1b-h~ UniGB-UTF16-H~ #3 } - \special{ pdf:mapline~ #1b-v~ UniGB-UTF16-V~ #3 } + \special { pdf:mapline~#1b-h~UniGB-UTF16-H~#3 } + \special { pdf:mapline~#1b-v~UniGB-UTF16-V~#3 } } } } -\@onlypreamble \ctex_set_upmap:nnn -\cs_new_protected_nopar:Npn \ctex_set_upfonts:nnnnnn #1 #2 #3 #4 #5 #6 +\cs_new_protected:Npn \ctex_set_upmap_unicode:nnn #1#2#3 + { + \ctex_set_zhmap:n + { + \special { pdf:mapline~#1-h~unicode~#2 } + \special { pdf:mapline~#1-v~unicode~#2 } + \tl_if_empty:nF {#3} + { + \special { pdf:mapline~#1b-h~unicode~#3 } + \special { pdf:mapline~#1b-v~unicode~#3 } + } + } + } +\cs_new_protected:Npn \ctex_set_upfonts:nnnnnn #1#2#3#4#5#6 { - \ctex_set_upmap:nnn { upserif } { #1 } { #2 } - \ctex_set_upmap:nnn { upserifit } { #3 } {} - \ctex_set_upmap:nnn { upsans } { #4 } { #5 } - \ctex_set_upmap:nnn { upmono } { #6 } {} + \ctex_set_upmap:nnn { upserif } {#1} {#2} + \ctex_set_upmap:nnn { upserifit } {#3} {} + \ctex_set_upmap:nnn { upsans } {#4} {#5} + \ctex_set_upmap:nnn { upmono } {#6} {} } +\@onlypreamble \ctex_set_upfamily:nnn +\@onlypreamble \ctex_set_upmap:nnn +\@onlypreamble \ctex_set_upmap_unicode:nnn \@onlypreamble \ctex_set_upfonts:nnnnnn \RequirePackage { pxeverysel } -\cs_new_protected_nopar:Npn \ctex_update_default_family: +\cs_new_protected:Npn \ctex_update_default_family: { \tl_if_eq:NNT \CJKfamilydefault \l__ctex_family_default_init_tl { @@ -150,34 +151,13 @@ { \exp_not:o { \CJKfamilydefault } } } \tl_gset_eq:NN \CJKfamilydefault \l__ctex_family_default_init_tl -\cs_new_protected_nopar:Npn \ctex_detected_platform: - { - \tl_gset:Nx \g__ctex_fontset_tl - { - \str_case:onF { \ngostype } - { - { Win32 } { windows } - { Win64 } { windows } - { Darwin } { mac } - } - { fandol } - } - } \ctex_hypersetup:n { driverfallback = dvipdfmx } \ctex_at_end_package:nn { hyperref } - { \AtBeginShipoutFirst { \special { pdf:tounicode~ UTF8-UTF16 } } } -\msg_new:nnn { ctex } { fntef-not-available } - { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ ApLaTeX. } -\msg_warning:nn { ctex } { fntef-not-available } -\clist_map_inline:nn - { underdot , underline , underdblline , underwave , sout , xout } - { \cs_new_eq:cN { CTEX#1 } \use:n } -\cs_new_eq:NN \CTEXfilltwosides \use_none:n -\cs_new_eq:NN \endCTEXfilltwosides \prg_do_nothing: -\cs_new_protected_nopar:Npn \ctex_update_ccwd: + { \AtBeginShipoutFirst { \special { pdf:tounicode~UTF8-UTF16 } } } +\cs_new_protected:Npn \ctex_update_ccwd: { \skip_set:Nn \ccwd { 1zw + \tex_kanjiskip:D } } \dim_new:N \ccwd -\cs_new_protected_nopar:Npn \ctex_update_ccglue: +\cs_new_protected:Npn \ctex_update_ccglue: { \skip_set_eq:NN \tex_kanjiskip:D \l__ctex_ccglue_skip } \skip_new:N \l__ctex_ccglue_skip \prg_new_conditional:Npnn \ctex_if_ccglue_touched: { TF } @@ -185,11 +165,11 @@ \skip_if_eq:nnTF { \l__ctex_ccglue_skip } { \tex_kanjiskip:D } { \prg_return_false: } { \prg_return_true: } } -\cs_new_protected_nopar:Npn \ctex_update_em_unit: +\cs_new_protected:Npn \ctex_update_em_unit: { \dim_set:Nn \ccwd { 1zw } } \cs_new_protected:Npn \ctex_add_to_selectfont:n #1 { - \cs_set_protected_nopar:Npx \CTEX@selectfont@hook + \cs_set_protected:Npx \CTEX@selectfont@hook { \exp_not:o { \CTEX@selectfont@hook #1 } } } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: @@ -199,10 +179,20 @@ { \tl_set:Nn \l__ctex_tmp_tl {#1} \cs_new_eq:NN \CTEX@selectfont@save #1 - \cs_new_protected_nopar:Npn \__ctex_restore_selectfont: + \cs_new_protected:Npn \__ctex_restore_selectfont: { + \cs_if_free:NF \scr@new@selectfont + { + \cs_if_free:NF \par@update + { + \tl_put_right:Nn \@EverySelectfont@Init + { \tl_put_right:Nn #1 { \par@update } } + } + \cs_set_eq:NN \scr@new@selectfont #1 + \cs_set_eq:NN \CTEX@selectfont@save \scr@selectfont + } \tl_put_left:Nn \@EverySelectfont@Init - { \let #1 \CTEX@selectfont@save } + { \cs_set_eq:NN #1 \CTEX@selectfont@save } \cs_undefine:N \__ctex_restore_selectfont: } } @@ -216,7 +206,7 @@ { \ctex_patch_failure:N \selectfont } \fi: \EverySelectfont { \CTEX@selectfont@hook } -\cs_new_protected_nopar:Npn \ctex_update_xkanjiskip: +\cs_new_protected:Npn \ctex_update_xkanjiskip: { \skip_if_eq:nnT { \tex_xkanjiskip:D } { \l__ctex_xkanjiskip_skip } @@ -232,21 +222,20 @@ \skip_set:Nn \l__ctex_xkanjiskip_skip { \tex_xkanjiskip:D } \ctex_add_to_selectfont:n { \ctex_update_xkanjiskip: } -\keys_define:nn { ctex } +\ctex_define:n { space .code:n = { \msg_warning:nn { ctex } { invalid-option } } } -\keys_define:nn { ctex } +\ctex_define:n { punct .code:n = { - \tl_set:Nx \l__ctex_punct_tl { #1 } + \tl_set:Nx \l__ctex_punct_tl {#1} \msg_warning:nn { ctex } { invalid-option } } , punct .default:n = { quanjiao } , } -\tl_set:Nn \l__ctex_encoding_tl { UTF8 } %% %% %% End of file `ctex-engine-aptex.def'. diff --git a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def index 351bb810745..6ccee7c96a2 100644 --- a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def +++ b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def @@ -6,9 +6,9 @@ %% %% ctex.dtx (with options: `luatex') %% -%% Copyright (C) 2003--2019 +%% Copyright (C) 2003--2020 %% 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 @@ -20,16 +20,14 @@ %% 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'. +%% 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 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee@gmail.com> $ {LuaLaTeX adapter (CTEX)} \ProvidesExplFile{ctex-engine-luatex.def} - {\ExplFileDate}{2.4.16}{\ExplFileDescription} + {\ExplFileDate}{2.5.1}{\ExplFileDescription} \msg_new:nnn { ctex } { luatexja-loaded } { Package~`luatexja'~can~not~be~loaded~before~`ctex'.\\ @@ -39,28 +37,29 @@ { \msg_critical:nnx { ctex } { luatexja-loaded } { \g_file_curr_name_str } } { \tl_const:cn { ver@ltj-latex.\@pkgextension } { 9999/99/99 } } \RequirePackage { luatexja } -\@ifpackagelater { luatexja } { 2015/09/21 } { } +\@ifpackagelater { luatexja } { 2020/04/12 } { } { \msg_error:nnn { ctex } { package-too-old } { luatexja } } \RequirePackage { fontspec } -\@ifpackagelater { fontspec } { 2014/05/25 } { } +\@ifpackagelater { fontspec } { 2020/02/21 } { } { \msg_error:nnn { ctex } { package-too-old } { fontspec } } \ExplSyntaxOff \ltjdefcharrange{1}{"80-"36F, "1E00-"1EFF} \ltjdefcharrange{2}{"370-"4FF, "1F00-"1FFF} \ltjdefcharrange{3}{% - "2000-"206F, "2070-"243F, "2460-"24FF, "2500-"27BF, "2900-"29FF, - "2B00-"2BFF} + "2000-"243F, "2460-"24FF, "2500-"27BF, "2900-"29FF, "2B00-"2BFF} \ltjdefcharrange{4}{% "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF, - "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F, - "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese + "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A95F, "A980-"ABFF, "E000-"F8FF, + "FB00-"FE0F, "FE20-"FE2F, "FE70-"FEFF, "10000-"1AFFF, "1B170-"1F0FF, + "1F300-"1FFFF, "2000-"206F} \ltjdefcharrange{5}{"D800-"DFFF, "E0000-"E00FF, "E01F0-"10FFFF} \ltjdefcharrange{6}{% "2E80-"2EFF, "3000-"30FF, "3190-"319F, "31F0-"4DBF, - "4E00-"9FFF, "F900-"FAFF, "FE10-"FE6F, "20000-"2FFFF, "E0100-"E01EF} + "4E00-"9FFF, "F900-"FAFF, "FE10-"FE1F, "FE30-"FE6F, "FF00-"FFEF, + "1B000-"1B16F, "1F100-"1F2FF, "20000-"3FFFF, "E0100-"E01EF} \ltjdefcharrange{7}{% - "1100-"11FF, "2F00-"2FFF, "3100-"31EF, "A000-"A4CF, - "A830-"A83F, "AC00-"D7FF} + "1100-"11FF, "2F00-"2FFF, "3100-"318F, "31A0-"31EF, "A000-"A4CF, + "A960-"A97F, "AC00-"D7FF} \ltjdefcharrange{8}{"A7, "A8, "B0, "B1, "B4, "B6, "D7, "F7} \ltjdefcharrange{9}{% "2018, "2019, "201C, "201D, "2013, "2014, "2025, "2026, "2027, "2E3A} @@ -78,42 +77,112 @@ } \ExplSyntaxOn \RequirePackage { xunicode-addon } -\AtBeginUTFCommand +\AtBeginUTFCommand { \CTEX@beginallalchar } +\AtEndUTFCommand { \CTEX@endallalchar } +\cs_new_protected:Npn \CTEX@beginallalchar { \group_begin: - \lua_now:e { tex.globaldefs = 0 } - \ltj@allalchar - } -\AtEndUTFCommand { \group_end: } -\cs_set_protected:Npn \fontspec_visible_space: - { - \tex_iffontchar:D \tex_font:D "2423 \exp_stop_f: - \ltjalchar "2423 \exp_stop_f: - \else: - \fontspec_visible_space_fallback: - \fi: + \ctex_ltj_zero_globaldefs: + \ltj@allalchar } +\cs_new_protected:Npn \CTEX@endallalchar + { \group_end: } \ctex_at_end_package:nn { listings } + { \RequirePackage { lltjp-listings } } +\group_begin: +\char_set_catcode_space:n { 32 } +\lua_now:e { - \use:x - { - \exp_not:N \RequirePackage { lltjp-listings } - \tl_set:Nn \exp_not:N \lstlistingname - { \exp_not:o { \lstlistingname } } - \tl_set:Nn \exp_not:N \lstlistlistingname - { \exp_not:o { \lstlistlistingname } } - } + local func = lua.get_functions_table() + local ltjfont = luatexja.jfont + local getattribute = tex.getattribute + local set_lua = token.set_lua + local scan_int, scan_arg = token.scan_int, token.scan_argument + local new_luafunction = luatexbase.new_luafunction + local id = new_luafunction("ctex") + func[id] = ltjfont.add_kyenc_list + set_lua("ctex_ltj_add_kyenc:n", id, "global", "protected") + local id = new_luafunction("ctex") + func[id] = ltjfont.is_kenc + set_lua("ctex_ltj_is_kenc:n", id, "global") + local id = new_luafunction("ctex") + func[id] = function () + local s = scan_arg() + local is_braced, is_quoted + if s:sub(1,1) == '{' and s:sub(-1)=='}' then + is_braced = true; s = s:sub(2,-2) + end + if s:sub(1,1) == '"' and s:sub(-1) == '"' then + is_quoted = true; s = s:sub(2,-2) + end + s = s .. ltjfont.print_aftl_address() + if is_braced then s = '{'..s..'}' + elseif is_quoted then s = '"'..s..'"' + end + tex.sprint(-2, s) + end + set_lua("ctex_ltj_patch_external_font:n", id, "global") + local id = new_luafunction("ctex") + func[id] = function () + font.current(getattribute("ltj@curjfnt")) + end + set_lua("ctex_ltj_use_jfont:", id, "global", "protected") + local id = new_luafunction("ctex") + func[id] = function () + local b = tonumber(scan_arg()) + local e = tonumber(scan_arg()) + local alt = scan_arg() + local base = scan_arg() + ltjfont.set_alt_font_latex(b, e, alt, base) + end + set_lua("ctex_ltj_set_alt_font:nnnn", id, "global", "protected") + local id = new_luafunction("ctex") + func[id] = function () + local base = scan_arg() + ltjfont.clear_alt_font_latex(base) + end + set_lua("ctex_ltj_clear_alt_font:n", id, "global", "protected") + local id = new_luafunction("ctex") + func[id] = function () + local base = scan_arg() + local size = scan_arg() + ltjfont.output_alt_font_cmd("y", base) + ltjfont.pickup_alt_font_a(size) + end + set_lua("ctex_ltj_pickup_alt_font:nn", id, "global", "protected") + local id = new_luafunction("ctex") + func[id] = function () + local num = scan_int() + local base = scan_arg() + ltjfont.pickup_alt_font_b(num, base) + end + set_lua("__ctex_ltj_pickup_alt_font:Nn", id, "global", "protected") + local id = new_luafunction("ctex") + func[id] = \LuaTeXjaversion > 20200412.0 + and ltjfont.does_alt_set + or function () + local base = scan_arg() + ltjfont.does_alt_set(base) + end + set_lua("__ctex_ltj_if_alt_set:nT", id, "global") + local id = new_luafunction("ctex") + func[id] = function () + tex.set("globaldefs", 0) + end + set_lua("ctex_ltj_zero_globaldefs:", id, "global", "protected") } -\cs_new_protected_nopar:Npn \ctex_ltj_select_font: +\group_end: +\cs_new_protected:Npn \ctex_ltj_select_font: { - \cs_if_exist_use:cF { \l__ctex_ltj_current_font_tl } + \group_begin: \exp_args:NNc \group_end: + \cs_if_exist_use:NF { \l__ctex_ltj_current_font_tl } { \tl_if_empty:NF \CJK@family { \__ctex_ltj_select_font_aux: } } } \tl_new:N \CJK@family \tl_new:N \l__ctex_ltj_current_font_tl \tl_set:Nn \l__ctex_ltj_current_font_tl { \CJK@encoding / \CJK@family / \f@series / \f@shape / \f@size } -\cs_new_protected_nopar:Npn \__ctex_ltj_select_font_aux: +\cs_new_protected:Npn \__ctex_ltj_select_font_aux: { \group_begin: \tl_set_eq:NN \f@encoding \CJK@encoding @@ -126,14 +195,18 @@ \cs_if_exist:cF { \l__ctex_ltj_current_font_tl } { \__ctex_ltj_select_font_aux: } } -\cs_new_protected_nopar:Npn \__ctex_ltj_push_fontname:n #1 +\cs_new_protected:Npn \__ctex_ltj_push_fontname:n #1 { - \cs_gset_eq:NN \__ctex_ltj_save_fontname:w \font@name + \seq_gpush:No \g__ctex_ltj_fontname_seq { \font@name } \cs_gset_nopar:Npx \font@name {#1} } -\cs_new_protected_nopar:Npn \__ctex_ltj_pop_fontname: - { \cs_gset_eq:NN \font@name \__ctex_ltj_save_fontname:w } -\cs_new_protected_nopar:Npn \ctex_ltj_pickup_font: +\cs_new_protected:Npn \__ctex_ltj_pop_fontname: + { + \seq_gpop:NNT \g__ctex_ltj_fontname_seq \l__ctex_ltj_tmp_tl + { \cs_gset_eq:NN \font@name \l__ctex_ltj_tmp_tl } + } +\seq_new:N \g__ctex_ltj_fontname_seq +\cs_new_protected:Npn \ctex_ltj_pickup_font: { \exp_after:wN \cs_if_exist:NF \font@name { @@ -155,7 +228,7 @@ } \exp_after:wN \globaljfont \font@name \external@font \scan_stop: \font@name - \lua_now:e { font.current(tex.getattribute('ltj@curjfnt')) } + \ctex_ltj_use_jfont: \use:c { \f@encoding + \f@family } \use:c { \curr@fontshape } } @@ -181,53 +254,46 @@ } \prg_new_conditional:Npnn \ctex_ltj_if_alternate_shape_exist:n #1 { T , F , TF } { - \lua_now:e { luatexja.jfont.does_alt_set ('\lua_escape:e {#1}') } - \prg_return_true: \else: \prg_return_false: \fi: + \__ctex_ltj_if_alt_set:nT {#1} { \prg_return_true: \use_none:n } + \prg_return_false: } -\cs_new_nopar:Npn \__ctex_ltj_patch_external_font:w #1 ~ at - { #1 \lua_now:e { luatexja.jfont.print_aftl_address() } ~ at } -\cs_new_protected_nopar:Npn \ctex_ltj_select_alternate_font: +\cs_new:Npn \__ctex_ltj_patch_external_font:w #1 ~ at + { \ctex_ltj_patch_external_font:n {#1} ~ at } +\cs_new_protected:Npn \ctex_ltj_select_alternate_font: { \ctex_ltj_if_alternate_shape_exist:nT { \l__ctex_ltj_current_shape_tl } { - \lua_now:e - { - luatexja.jfont.output_alt_font_cmd - ('y', '\lua_escape:e { \l__ctex_ltj_current_shape_tl }') - } - \lua_now:e { luatexja.jfont.pickup_alt_font_a ('\f@size') } + \ctex_ltj_pickup_alt_font:nn + { \l__ctex_ltj_current_shape_tl } { \f@size } } } \tl_new:N \l__ctex_ltj_current_shape_tl \tl_set:Nn \l__ctex_ltj_current_shape_tl { \CJK@encoding / \CJK@family / \f@series / \f@shape } -\cs_new_protected_nopar:Npn \ltj@pickup@altfont@auxy #1 +\cs_new_protected:Npn \ltj@pickup@altfont@auxy #1 { \cs_if_exist:cF { #1/\f@size } { \group_begin: - \use:x { \exp_not:N \split@name #1 / \f@size } \@nil + \use:e { \exp_not:N \split@name #1 / \f@size } \@nil \__ctex_ltj_push_fontname:n { \use:c { \curr@fontshape / \f@size } } \ctex_ltj_pickup_font: \group_end: \__ctex_ltj_pop_fontname: } } -\cs_new_protected_nopar:Npn \ltj@pickup@altfont@copy #1#2 +\cs_new_protected:Npn \ltj@pickup@altfont@copy #1#2 { \ltj@@getjfontnumber #1 - \lua_now:e - { - luatexja.jfont.pickup_alt_font_b - ( \int_use:N \ltj@tempcntc, '\lua_escape:e {#2}' ) - } + \__ctex_ltj_pickup_alt_font:Nn \ltj@tempcntc {#2} } \cs_new:Npn \ctex_ltj_if_jfont:nTF #1 { - \lua_now:e - { luatexja.jfont.is_kenc( string.match('\lua_escape:e {#1}', '[^/]+') ) } + \ctex_ltj_is_kenc:n { \__ctex_ltj_ltj_if_jfont:w #1 / \q_stop } \ifin@ \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi: } +\cs_new:Npn \__ctex_ltj_ltj_if_jfont:w #1 / #2 \q_stop + {#1} \cs_new:Npn \ctex_ltj_if_jfont_math:NTF #1 { \exp_after:wN \__ctex_ltj_if_jfont_math:w \token_to_str:N #1 \q_stop } \group_begin: @@ -235,16 +301,16 @@ \cs_new:Npn \__ctex_ltj_if_jfont_math:w #1 M #2#3 \q_stop { \ctex_ltj_if_jfont:nTF {#3} } \group_end: -\cs_new_protected_nopar:Npn \ctex_ltj_get_and_define_fonts:nN #1#2 +\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts:nN #1#2 { - \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 } + \exp_args:No \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 } { \ctex_ltj_get_and_define_fonts_ja:nN } { \ctex_ltj_get_and_define_fonts_al:nN } {#1} #2 } \cs_new_eq:NN \ctex_ltj_get_and_define_fonts_al:nN \getanddefine@fonts \cs_set_eq:NN \getanddefine@fonts \ctex_ltj_get_and_define_fonts:nN -\cs_new_protected_nopar:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2 +\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2 { \tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \tf@size } } \ctex_ltj_pickup_font: \tl_set_eq:NN \textfont@name \font@name @@ -260,7 +326,7 @@ \ltj@@set@stackfont #1 , \font@name \c_colon_str { MJSS } } } -\cs_new_protected_nopar:Npn \ctex_ltj_use_math_group:Nn #1#2 +\cs_new_protected:Npn \ctex_ltj_use_math_group:Nn #1#2 { \mode_if_math:T { @@ -292,14 +358,14 @@ } { \cs_set_eq:NN \use@mathgroup \ctex_ltj_use_math_group:Nn - \cs_set_protected_nopar:Npn \ctex_ltj_math_group_hook: + \cs_set_protected:Npn \ctex_ltj_math_group_hook: { \__um_switchto_literal: } \ctex_ltj_set_math_letter:NN \__um_sym:nnn \__um_input_math_symbol_table: } } -\cs_new_protected_nopar:Npn \ctex_mono_jfm:n #1 +\cs_new_protected:Npn \ctex_mono_jfm:n #1 { \str_if_eq:nnTF {#1} { plain } { \tl_set:Nn \l__ctex_ltj_jfm_tl { mono } } @@ -310,24 +376,22 @@ \ctex_mono_jfm:o { \l__ctex_punct_tl } \tl_const:Nn \CJK@encoding { LTJY3 } \DeclareFontEncoding { \CJK@encoding } { } { } -\use:x +\use:e { \exp_not:N \DeclareFontSubstitution - { \CJK@encoding } { song } { \mddefault } { \updefault } + { \CJK@encoding } { song } { \mddefault } { \shapedefault } } -\lua_now:e { luatexja.jfont.add_kyenc_list('\CJK@encoding') } -\cs_new_protected_nopar:Npn \__ctex_ltj_change_encoding: - { \tl_set_eq:NN \g_fontspec_encoding_tl \CJK@encoding } +\ctex_ltj_add_kyenc:n { \CJK@encoding } \DeclareFontFamily { \CJK@encoding } { song } { } -\DeclareFontShape { \CJK@encoding } { song } { \mddefault } { \updefault } +\DeclareFontShape { \CJK@encoding } { song } { \mddefault } { \shapedefault } { <-> psft:SimSun:cid=Adobe-GB1-5;jfm=\l__ctex_ltj_jfm_tl } { } -\DeclareFontShape { \CJK@encoding } { song } { \bfdefault } { \updefault } +\DeclareFontShape { \CJK@encoding } { song } { \bfdefault } { \shapedefault } { <-> psft:SimHei:cid=Adobe-GB1-5;jfm=\l__ctex_ltj_jfm_tl } { } \tl_const:Nn \c__ctex_ltj_math_tl { CJKmath } \DeclareSymbolFont { \c__ctex_ltj_math_tl } - { \CJK@encoding } { song } { \mddefault } { \updefault } + { \CJK@encoding } { song } { \mddefault } { \shapedefault } \SetSymbolFont { \c__ctex_ltj_math_tl } { bold } - { \CJK@encoding } { song } { \bfdefault } { \updefault } + { \CJK@encoding } { song } { \bfdefault } { \shapedefault } \int_const:Nn \c__ctex_ltj_math_fam_int { \use:c { sym \c__ctex_ltj_math_tl } } \jfam \c__ctex_ltj_math_fam_int \newfontfeature { CID } { cid = #1 } @@ -343,7 +407,7 @@ { \group_begin: \clist_clear:N \l__ctex_ltj_char_range_clist - \seq_clear:N \l__ctex_ltj_alternate_seq + \prop_clear:N \l__ctex_ltj_alternate_prop \tl_set:Nn \l__ctex_ltj_base_CJKfamily_tl {#1} \keys_set_known:nnN { ctex_ltj / fontspec } {#2} \l__ctex_ltj_tmp_tl \clist_set:No \l__ctex_ltj_font_options_clist { \l__ctex_ltj_tmp_tl } @@ -360,15 +424,16 @@ } \tl_new:N \l__ctex_ltj_base_CJKfamily_tl \clist_new:N \l__ctex_ltj_font_options_clist -\cs_new_protected_nopar:Npn \__ctex_ltj_use_global_options:N #1 +\cs_new_protected:Npn \__ctex_ltj_use_global_options:N #1 { \clist_concat:NNN #1 \g__ctex_ltj_default_features_clist #1 - \clist_put_left:Nx #1 { JFM = \l__ctex_ltj_jfm_tl } + \clist_put_left:Nx #1 + { NFSSEncoding = \CJK@encoding , JFM = \l__ctex_ltj_jfm_tl } } \prop_new:N \g__ctex_ltj_family_name_prop \prop_new:N \g__ctex_ltj_family_font_name_prop \prop_new:N \g__ctex_ltj_family_font_options_prop -\cs_new_protected_nopar:Npn \__ctex_ltj_check_family:n #1 +\cs_new_protected:Npn \__ctex_ltj_check_family:n #1 { \prop_gpop:NnNT \g__ctex_ltj_family_font_name_prop {#1} \l__ctex_ltj_tmp_tl { @@ -387,28 +452,24 @@ \tl_new:N \l__ctex_ltj_tmp_tl \msg_new:nnn { ctex } { redefine-family } { Redefining~CJKfamily~`\__ctex_ltj_msg_family_map:n {#1}'~(#2). } -\cs_new_protected_nopar:Npn \__ctex_ltj_gset_family_cs:nn #1#2 +\cs_new_protected:Npn \__ctex_ltj_gset_family_cs:nn #1#2 { - \cs_gset_protected_nopar:cpx { \__ctex_ltj_family_csname:n {#1} } + \cs_gset_protected:cpx { \__ctex_ltj_family_csname:n {#1} } { \group_begin: - \__ctex_ltj_change_encoding: \exp_not:n { \cs_set_eq:NN \CJKfamily \use_none:n } - \exp_not:n { \cs_set_eq:NN \CTEX@fontfamily \use_none:n } - \exp_not:n { \fontspec_set_family:Nnn \g__ctex_ltj_fontspec_family_tl } + \exp_not:n { \fontspec_gset_family:Nnn \g__ctex_ltj_fontspec_family_tl } { \exp_not:o { \l__ctex_ltj_font_options_clist } } {#2} \prop_gput:Nno \exp_not:N \g__ctex_ltj_family_name_prop {#1} { \exp_not:N \g__ctex_ltj_fontspec_family_tl } - \tl_gset_eq:NN \exp_not:N \g__ctex_ltj_fontspec_family_tl - \exp_not:N \g__ctex_ltj_fontspec_family_tl \__ctex_ltj_set_alternate_family:n {#1} \group_end: } } \tl_new:N \l__ctex_ltj_base_family_tl \tl_new:N \g__ctex_ltj_fontspec_family_tl -\cs_new_nopar:Npn \__ctex_ltj_family_csname:n #1 { ctex_ltj/family/#1 } -\cs_new_protected_nopar:Npn \__ctex_ltj_set_alternate_family:n #1 +\cs_new:Npn \__ctex_ltj_family_csname:n #1 { ctex_ltj/family/#1 } +\cs_new_protected:Npn \__ctex_ltj_set_alternate_family:n #1 { \tl_set:Nn \l__ctex_ltj_base_CJKfamily_tl {#1} \tl_set_eq:NN \l__ctex_ltj_base_family_tl \g__ctex_ltj_fontspec_family_tl @@ -418,7 +479,7 @@ \cs_new:Npn \__ctex_ltj_alternate_cs:n #1 { ctex_ltj/alternate_family/#1 } \NewDocumentCommand \CJKfamily { m } { \ctex_ltj_switch_family:x {#1} \tex_ignorespaces:D } -\cs_new_protected_nopar:Npn \ctex_ltj_switch_family:n #1 +\cs_new_protected:Npn \ctex_ltj_switch_family:n #1 { \ctex_ltj_family_if_exist:nNTF {#1} \CJK@family { @@ -443,7 +504,7 @@ } } \prg_generate_conditional_variant:Nnn \ctex_ltj_family_if_exist:nN { x } { T , F , TF } -\cs_new_protected_nopar:Npn \__ctex_ltj_family_unknown_warning:n #1 +\cs_new_protected:Npn \__ctex_ltj_family_unknown_warning:n #1 { \prop_if_empty:NF \g__ctex_ltj_family_font_name_prop { @@ -460,7 +521,7 @@ Unknown~CJK~family~`\__ctex_ltj_msg_family_map:n {#1}'~is~being~ignored.\\ Try~to~use~`\__ctex_ltj_msg_def_family_map:n {#1}'~to~define~it. } -\cs_new_nopar:Npn \__ctex_ltj_msg_def_family_map:n #1 +\cs_new:Npn \__ctex_ltj_msg_def_family_map:n #1 { \str_case_e:nnF {#1} { @@ -471,7 +532,7 @@ { \token_to_str:N \setCJKfamilyfont \{ #1 \} } [...]\{...\} } -\cs_new_nopar:Npn \__ctex_ltj_msg_family_map:n #1 +\cs_new:Npn \__ctex_ltj_msg_family_map:n #1 { \str_case_e:nnF {#1} { @@ -481,21 +542,21 @@ } {#1} } -\cs_new_protected_nopar:Npn \ctex_ltj_fontspec:nn #1#2 +\cs_new_protected:Npn \ctex_ltj_fontspec:nn #1#2 { \prop_get:NnNTF \g__ctex_ltj_fontspec_prop { CJKfontspec/#1/#2/id } \l_ctex_ltj_family_tl { \ctex_ltj_switch_family:x { \l_ctex_ltj_family_tl } } { \int_gincr:N \g__ctex_ltj_family_int - \__ctex_ltj_fontspec:xnn + \__ctex_ltj_fontspec:enn { CJKfontspec ( \int_use:N \g__ctex_ltj_family_int ) } {#1} {#2} } } -\cs_new_protected_nopar:Npn \ctex_ltj_fontspec:xx #1#2 - { \use:x { \ctex_ltj_fontspec:nn {#1} {#2} } } -\cs_new_protected_nopar:Npn \__ctex_ltj_fontspec:nnn #1#2#3 +\cs_new_protected:Npn \ctex_ltj_fontspec:ee #1#2 + { \use:e { \ctex_ltj_fontspec:nn {#1} {#2} } } +\cs_new_protected:Npn \__ctex_ltj_fontspec:nnn #1#2#3 { \bool_if:NT \l__ctex_ltj_add_alternate_bool { @@ -515,11 +576,11 @@ \ctex_ltj_set_family:nnn {#1} {#2} {#3} \ctex_ltj_switch_family:n {#1} } -\cs_generate_variant:Nn \__ctex_ltj_fontspec:nnn { x } +\cs_generate_variant:Nn \__ctex_ltj_fontspec:nnn { e } \prop_new:N \g__ctex_ltj_fontspec_prop -\cs_new_protected_nopar:Npn \ctex_ltj_add_font_features:n #1 +\cs_new_protected:Npn \ctex_ltj_add_font_features:n #1 { \ctex_ltj_add_font_features:xn { \l_ctex_ltj_family_tl } {#1} } -\cs_new_protected_nopar:Npn \ctex_ltj_add_font_features:nn #1#2 +\cs_new_protected:Npn \ctex_ltj_add_font_features:nn #1#2 { \prop_get:NnNTF \g__ctex_ltj_family_font_name_prop {#1} \l__ctex_ltj_tmp_tl @@ -528,7 +589,7 @@ {#1} \l__ctex_ltj_font_options_clist \clist_put_right:Nn \l__ctex_ltj_font_options_clist {#2} \bool_set_true:N \l__ctex_ltj_add_alternate_bool - \ctex_ltj_fontspec:xx + \ctex_ltj_fontspec:ee { \exp_not:o { \l__ctex_ltj_font_options_clist } } { \exp_not:o { \l__ctex_ltj_tmp_tl } } } @@ -544,16 +605,16 @@ } \cs_new_protected:Npn \__ctex_ltj_pass_args:nnnn #1#2#3#4 { - \IfNoValueTF {#2} + \tl_if_novalue:nTF {#2} { \__ctex_ltj_post_arg:w {#1} {#3} {#4} } { - \use:x { #1 {#2} {#3} } + \use:e { #1 {#2} {#3} } #4 } } \NewDocumentCommand \__ctex_ltj_post_arg:w { m m m O { } } { - \use:x { #1 {#4} {#2} } + \use:e { #1 {#4} {#2} } #3 } \NewDocumentCommand \setCJKfamilyfont { m o m } @@ -565,8 +626,8 @@ \NewDocumentCommand \newCJKfontfamily { o m o m } { \tl_set:Nx \l__ctex_ltj_tmp_tl - { \IfNoValueTF {#1} { \cs_to_str:N #2 } {#1} } - \cs_new_protected_nopar:Npx #2 + { \tl_if_novalue:nTF {#1} { \cs_to_str:N #2 } {#1} } + \cs_new_protected:Npx #2 { \ctex_ltj_switch_family:n { \l__ctex_ltj_tmp_tl } } \__ctex_ltj_pass_args:nnnn { \ctex_ltj_set_family:nnn { \l__ctex_ltj_tmp_tl } } {#3} {#4} @@ -623,29 +684,12 @@ \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 } } -\RenewDocumentCommand \fontfamily { m } - { - \tl_set:Nx \f@family {#1} - \CTEX@fontfamily {#1} - } -\cs_new_protected_nopar:Npn \CTEX@fontfamily #1 - { - \str_if_eq:nnTF {#1} { \familydefault } - { \CJKfamily { \CJKfamilydefault } } - { \__ctex_ltj_update_family_aux: } - } -\cs_new_protected_nopar:Npn \__ctex_ltj_update_family_aux: - { - \str_case_e:nn { \f@family } - { - { \rmdefault } { \CJKfamily { \CJKrmdefault } } - { \sfdefault } { \CJKfamily { \CJKsfdefault } } - { \ttdefault } { \CJKfamily { \CJKttdefault } } - { \familydefault } { \CJKfamily { \CJKfamilydefault } } - } - } +\g@addto@macro \@rmfamilyhook { \CJKfamily { \CJKrmdefault } } +\g@addto@macro \@sffamilyhook { \CJKfamily { \CJKsfdefault } } +\g@addto@macro \@ttfamilyhook { \CJKfamily { \CJKttdefault } } +\g@addto@macro \@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } } \ctex_at_end_preamble:n { \ctex_update_default_family: } -\cs_new_protected_nopar:Npn \ctex_ltj_ensure_default_family: +\cs_new_protected:Npn \ctex_ltj_ensure_default_family: { \prop_if_empty:NF \g__ctex_ltj_family_font_name_prop { @@ -670,7 +714,7 @@ \ctex_ltj_update_mathfont: } } -\cs_new_protected_nopar:Npn \ctex_ltj_update_mathfont: +\cs_new_protected:Npn \ctex_ltj_update_mathfont: { \ctex_ltj_family_if_exist:xNTF { \c__ctex_ltj_math_tl } \l__ctex_ltj_tmp_tl { \ctex_ltj_update_mathfont:n { \l__ctex_ltj_tmp_tl } } @@ -679,91 +723,93 @@ { \ctex_ltj_update_mathfont:n { \l__ctex_ltj_tmp_tl } } } } -\cs_new_protected_nopar:Npn \ctex_ltj_update_mathfont:n #1 +\cs_new_protected:Npn \ctex_ltj_update_mathfont:n #1 { \tl_const:Nx \c__ctex_ltj_math_family_tl {#1} \DeclareSymbolFont { \c__ctex_ltj_math_tl } { \CJK@encoding } - { \c__ctex_ltj_math_family_tl } { \mddefault } { \updefault } + { \c__ctex_ltj_math_family_tl } { \mddefault } { \shapedefault } \cs_if_free:cTF - { \CJK@encoding/\c__ctex_ltj_math_family_tl/\bfdefault/\updefault } + { \CJK@encoding/\c__ctex_ltj_math_family_tl/\bfdefault/\shapedefault } { \SetSymbolFont { \c__ctex_ltj_math_tl } { bold } { \CJK@encoding } - { \c__ctex_ltj_math_family_tl } { \mddefault } { \updefault } + { \c__ctex_ltj_math_family_tl } { \mddefault } { \shapedefault } } { \SetSymbolFont { \c__ctex_ltj_math_tl } { bold } { \CJK@encoding } - { \c__ctex_ltj_math_family_tl } { \bfdefault } { \updefault } + { \c__ctex_ltj_math_family_tl } { \bfdefault } { \shapedefault } } } \keys_define:nn { ctex_ltj / fontspec } { - AlternateFont .code:n = \ctex_ltj_set_alternate_seq:n {#1} , + AlternateFont .code:n = \ctex_ltj_set_alternate_prop:n {#1} , AlternateFont .value_required:n = true , CharRange .clist_set:N = \l__ctex_ltj_char_range_clist , CharRange .value_required:n = true } -\group_begin: - \char_set_catcode_other:N \| - \cs_set:Npn \__ctex_ltj_tmp:w #1 - { - \cs_new_protected:Npn \ctex_ltj_set_alternate_seq:n ##1 - { - \clist_if_empty:NT \l__ctex_ltj_char_range_clist - { - \tl_set:Nn \l__ctex_ltj_tmp_tl { ##1 } - \tl_replace_all:Nnn \l__ctex_ltj_tmp_tl {#1} { || } - \seq_set_split:NnV \l__ctex_ltj_tmp_seq { || } \l__ctex_ltj_tmp_tl - \seq_set_filter:NNn \l__ctex_ltj_tmp_seq \l__ctex_ltj_tmp_seq - { ! \tl_if_blank_p:n { ####1 } } - \seq_concat:NNN \l__ctex_ltj_alternate_seq - \l__ctex_ltj_alternate_seq \l__ctex_ltj_tmp_seq - } - } - } - \char_set_catcode_active:N \| - \__ctex_ltj_tmp:w { || } -\group_end: -\seq_new:N \l__ctex_ltj_tmp_seq -\seq_new:N \l__ctex_ltj_alternate_seq -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nnF #1#2#3 +\cs_new_protected:Npn \ctex_ltj_set_alternate_prop:n #1 + { \clist_map_function:nN {#1} \__ctex_ltj_push_alternate_prop:n } +\cs_new_protected:Npn \__ctex_ltj_push_alternate_prop:n #1 + { + \clist_set:Nx \l__ctex_ltj_tmp_clist { \tl_head:n {#1} } + \tl_remove_all:Nn \l__ctex_ltj_tmp_clist { ~ } + \exp_args:No \__ctex_ltj_push_alternate_prop:nn + { \l__ctex_ltj_tmp_clist } {#1} + } +\cs_new_protected:Npn \__ctex_ltj_push_alternate_prop:nn #1 + { + \prop_remove:Nn \l__ctex_ltj_alternate_prop {#1} + \prop_put:Nnn \l__ctex_ltj_alternate_prop {#1} + } +\clist_new:N \l__ctex_ltj_tmp_clist +\prop_new:N \l__ctex_ltj_alternate_prop +\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnF { \clist_if_empty:NTF \l__ctex_ltj_char_range_clist - { - \__ctex_ltj_check_family:n {#1} - \seq_if_empty:NF \l__ctex_ltj_alternate_seq - { \ctex_ltj_save_alternate_seq:cn { \__ctex_ltj_alternate_cs:n {#1} } {#2} } - #3 - } - { \ctex_ltj_set_alternate_family:nn {#1} {#2} } + { \__ctex_ltj_set_family_aux:nnn } + { \__ctex_ltj_set_alternate_family_aux:nnn } } -\cs_new_protected_nopar:Npn \ctex_ltj_save_alternate_seq:Nn #1#2 +\cs_new_protected:Npn \__ctex_ltj_set_family_aux:nnn #1#2#3 { - \seq_map_inline:Nn \l__ctex_ltj_alternate_seq - { \ctex_ltj_save_alternate_seq:Nnnwnw #1 {#2} ##1 { } \q_stop } + \__ctex_ltj_check_family:n {#1} + \prop_if_empty:NF \l__ctex_ltj_alternate_prop + { \ctex_ltj_save_alternate_seq:cn { \__ctex_ltj_alternate_cs:n {#1} } {#2} } + #3 } -\cs_generate_variant:Nn \ctex_ltj_save_alternate_seq:Nn { c } -\NewDocumentCommand \ctex_ltj_save_alternate_seq:Nnnwnw - { m m m +O{ } m u{ \q_stop } } +\cs_new_protected:Npn \__ctex_ltj_set_alternate_family_aux:nnn #1#2#3 + { \ctex_ltj_set_alternate_family:nn {#1} {#2} } +\cs_new_protected:Npn \ctex_ltj_save_alternate_seq:Nn #1#2 + { + \prop_map_inline:Nn \l__ctex_ltj_alternate_prop + { \__ctex_ltj_save_alternate_auxi:w ##2 { } \q_mark #1 {#2} } + } +\cs_new_protected:Npn \__ctex_ltj_save_alternate_auxi:w #1#2# { - \clist_set:Nn \l__ctex_ltj_char_range_clist {#3} - \clist_set:Nn \l__ctex_ltj_alternate_options_clist {#4} + \tl_if_blank:nTF {#2} + { \__ctex_ltj_save_alternate_auxii:w {#1} } + { \__ctex_ltj_save_alternate_auxii:w {#1} {#2} } + } +\cs_new_protected:Npn \__ctex_ltj_save_alternate_auxii:w #1#2#3 #4 \q_mark #5#6 + { + \clist_set:Nn \l__ctex_ltj_char_range_clist {#1} + \clist_set:Nn \l__ctex_ltj_alternate_options_clist {#3} \__ctex_ltj_use_global_options:N \l__ctex_ltj_alternate_options_clist - \tl_if_blank:nTF {#5} - { \tl_set:Nn \l__ctex_ltj_tmp_tl {#2} } + \tl_if_blank:nTF {#2} + { \tl_set:Nn \l__ctex_ltj_tmp_tl {#6} } { - \tl_set:Nn \l__ctex_ltj_tmp_tl {#5} - \tl_replace_all:Nnn \l__ctex_ltj_tmp_tl { * } {#2} + \tl_set:Nx \l__ctex_ltj_tmp_tl { \tl_trim_spaces:n {#2} } + \tl_replace_all:Nnn \l__ctex_ltj_tmp_tl { * } {#6} } - \use:x + \use:e { - \ctex_ltj_save_alternate_family:Nnnn \exp_not:N #1 + \ctex_ltj_save_alternate_family:Nnnn \exp_not:N #5 { \exp_not:o { \l__ctex_ltj_char_range_clist } } { \exp_not:o { \l__ctex_ltj_alternate_options_clist } } { \exp_not:o { \l__ctex_ltj_tmp_tl } } } } \clist_new:N \l__ctex_ltj_alternate_options_clist -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nn #1#2 +\cs_generate_variant:Nn \ctex_ltj_save_alternate_seq:Nn { c } +\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nn #1#2 { \__ctex_ltj_update_family_uid:N \l__ctex_ltj_font_options_clist \__ctex_ltj_use_global_options:N \l__ctex_ltj_font_options_clist @@ -772,23 +818,22 @@ { \l__ctex_ltj_char_range_clist } { \l__ctex_ltj_font_options_clist } {#2} {#1} } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:Nnnnn #1#2#3#4#5 +\cs_new_protected:Npn \ctex_ltj_set_alternate_family:Nnnnn #1#2#3#4#5 { \prop_get:NnNT \g__ctex_ltj_family_name_prop {#5} \l__ctex_ltj_base_family_tl { \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } \ctex_ltj_save_alternate_family:Nnnn #1 {#2} {#3} {#4} } \cs_generate_variant:Nn \ctex_ltj_set_alternate_family:Nnnnn { coo } -\cs_new_protected_nopar:Npn \ctex_ltj_save_alternate_family:Nnnn #1#2#3#4 +\cs_new_protected:Npn \ctex_ltj_save_alternate_family:Nnnn #1#2#3#4 { \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } - \cs_gset_protected_nopar:Npx #1 + \cs_gset_protected:Npx #1 { \exp_not:o { #1 \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } } } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nnn #1#2#3 +\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnn #1#2#3 { \group_begin: - \__ctex_ltj_change_encoding: \cs_set_eq:NN \CJKfamily \use_none:n \ctex_ltj_swap_cs:NN \DeclareFontShape@ \ctex_ltj_declare_alternate_shape:nnnnnn @@ -805,7 +850,7 @@ \cs_undefine:N \__ctex_ltj_tmp:w } \keys_define:nn { fontspec } { LTJFONTUID .code:n = } -\cs_new_protected_nopar:Npn \__ctex_ltj_update_family_uid:N #1 +\cs_new_protected:Npn \__ctex_ltj_update_family_uid:N #1 { \int_gincr:N \g__ctex_ltj_family_int \clist_put_right:Nx #1 { LTJFONTUID = \int_use:N \g__ctex_ltj_family_int } @@ -815,10 +860,9 @@ { \ctex_ltj_declare_alternate_shape:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6} \ctex_ltj_set_alternate_shape:Nnnnnnn \l__ctex_ltj_char_range_clist - { \l__ctex_ltj_base_family_tl } {#3} {#4} - { \l_fontspec_family_tl } {#3} {#4} + { \l__ctex_ltj_base_family_tl } {#3} {#4} {#2} {#3} {#4} } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:Nnnnnnn #1#2#3#4#5#6#7 +\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:Nnnnnnn #1#2#3#4#5#6#7 { \clist_map_inline:Nn #1 { @@ -829,73 +873,67 @@ } { \ctex_ltj_set_alternate_shape:nnn { #2/#3/#4 } { #5/#6/#7 } { ##1 } } } - \__ctex_ltj_save_alternate_shape:cnn + \__ctex_ltj_save_alternate_shape:cn { \__ctex_ltj_alternate_cs:n { clear / \l__ctex_ltj_base_CJKfamily_tl } } - { luatexja.jfont.clear_alt_font_latex } - { '\lua_escape:e { \CJK@encoding/#2/#3/#4 }' } + { \ctex_ltj_clear_alt_font:n { \CJK@encoding/#2/#3/#4 } } } \NewDocumentCommand \ctex_ltj_set_alternate_shape:nnn { m m > { \SplitArgument { 1 } { -> } } m } { \ctex_ltj_set_alternate_shape:nnnn {#1} {#2} #3 } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:nnnn #1#2#3#4 +\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnnn #1#2#3#4 { - \ctex_ltj_set_alternate_shape:n + \ctex_ltj_set_alternate_shape:e { - \IfNoValueTF {#4} - { \int_eval:n {#3} , \int_eval:n {#3} , } - { - \int_eval:n { \tl_if_blank:nTF {#3} { "80 } {#3} } , - \int_eval:n { \tl_if_blank:nTF {#4} { "10FFFF } {#4} } , - } - '\lua_escape:e { \CJK@encoding/#2 }' , - '\lua_escape:e { \CJK@encoding/#1 }' + \__ctex_ltj_range_normalization:nn {#3} {#4} + { \CJK@encoding / \exp_not:n {#2} } + { \CJK@encoding / \exp_not:n {#1} } } } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:n #1 +\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:n #1 { - \lua_now:e { luatexja.jfont.set_alt_font_latex ( #1 ) } - \__ctex_ltj_save_alternate_shape:cnn + \ctex_ltj_set_alt_font:nnnn #1 + \__ctex_ltj_save_alternate_shape:cn { \__ctex_ltj_alternate_cs:n { reset / \l__ctex_ltj_base_CJKfamily_tl } } - { luatexja.jfont.set_alt_font_latex } {#1} + { \ctex_ltj_set_alt_font:nnnn #1 } } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:nnN #1#2#3 +\cs_generate_variant:Nn \ctex_ltj_set_alternate_shape:n { e } +\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnN #1#2#3 { \tl_map_inline:Nn #3 { \ctex_ltj_set_alternate_shape:n { - ##1 , - '\lua_escape:e { \CJK@encoding/#2 }' , - '\lua_escape:e { \CJK@encoding/#1 }' + ##1 + { \CJK@encoding/#2 } + { \CJK@encoding/#1 } } } } -\cs_new_protected_nopar:Npn \__ctex_ltj_save_alternate_shape:Nnn #1#2#3 +\cs_new_protected:Npn \__ctex_ltj_save_alternate_shape:Nn #1#2 { \group_begin: - \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } - \cs_set_eq:NN \l__ctex_ltj_base_family_tl \scan_stop: - \cs_set_eq:NN \lua_escape:e \scan_stop: - \cs_gset_protected_nopar:Npx #1 - { \exp_not:o {#1} \exp_not:N \lua_now:e { #2 ( #3 ) } } + \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } + \cs_set_eq:NN \l__ctex_ltj_base_family_tl \scan_stop: + \cs_gset_protected:Npx #1 { \exp_not:o {#1} #2 } \group_end: } -\cs_generate_variant:Nn \__ctex_ltj_save_alternate_shape:Nnn { c } -\keys_define:nn { ctex } +\cs_generate_variant:Nn \__ctex_ltj_save_alternate_shape:Nn { c } +\ctex_define:n { clearalternatefont .code:n = - { \clist_map_function:xN {#1} \ctex_ltj_clear_alternate_font:n } , + { \clist_map_function:eN {#1} \ctex_ltj_clear_alternate_font:n } , resetalternatefont .code:n = - { \clist_map_function:xN {#1} \ctex_ltj_reset_alternate_font:n } , + { \clist_map_function:eN {#1} \ctex_ltj_reset_alternate_font:n } , clearalternatefont .default:n = \l_ctex_ltj_family_tl , resetalternatefont .default:n = \l_ctex_ltj_family_tl } -\cs_new_protected_nopar:Npn \ctex_ltj_clear_alternate_font:n #1 +\cs_new_protected:Npn \ctex_ltj_clear_alternate_font:n #1 { \group_begin: \ctex_ltj_family_if_exist:xNTF {#1} \l__ctex_ltj_base_family_tl { - \cs_if_exist_use:cT { \__ctex_ltj_alternate_cs:n { clear / #1 } } + \cs_if_exist_use:cT + { \__ctex_ltj_alternate_cs:n { clear / #1 } } { \prop_gput:Nno \g__ctex_ltj_reset_alternate_prop {#1} { \l__ctex_ltj_base_family_tl } @@ -906,7 +944,7 @@ { \__ctex_ltj_family_unknown_warning:n {#1} } \group_end: } -\cs_new_protected_nopar:Npn \ctex_ltj_reset_alternate_font:n #1 +\cs_new_protected:Npn \ctex_ltj_reset_alternate_font:n #1 { \group_begin: \prop_gpop:NnNT \g__ctex_ltj_reset_alternate_prop {#1} \CJK@family @@ -918,18 +956,18 @@ \group_end: } \prop_new:N \g__ctex_ltj_reset_alternate_prop -\cs_generate_variant:Nn \clist_map_function:nN { x } -\keys_define:nn { ctex } +\cs_generate_variant:Nn \clist_map_function:nN { e } +\ctex_define:n { - declarecharrange .code:n = \ctex_ltj_declare_char_range:x {#1} , + declarecharrange .code:n = \ctex_ltj_declare_char_range:e {#1} , declarecharrange .value_required:n = true } -\cs_new_protected_nopar:Npn \ctex_ltj_declare_char_range:n #1 +\cs_new_protected:Npn \ctex_ltj_declare_char_range:n #1 { \clist_map_inline:nn {#1} { \__ctex_ltj_declare_char_range:nn ##1 } } -\cs_generate_variant:Nn \ctex_ltj_declare_char_range:n { x } -\cs_new_protected_nopar:Npn \__ctex_ltj_declare_char_range:nn #1#2 - { \use:x { \ctex_ltj_declare_char_range:nn { \tl_trim_spaces:n {#1} } } {#2} } -\cs_new_protected_nopar:Npn \ctex_ltj_declare_char_range:nn #1#2 +\cs_generate_variant:Nn \ctex_ltj_declare_char_range:n { e } +\cs_new_protected:Npn \__ctex_ltj_declare_char_range:nn #1 + { \exp_args:Ne \ctex_ltj_declare_char_range:nn { \tl_trim_spaces:n {#1} } } +\cs_new_protected:Npn \ctex_ltj_declare_char_range:nn #1#2 { \tl_clear:N \l__ctex_ltj_char_range_tl \clist_map_function:nN {#2} \ctex_ltj_save_char_range:n @@ -942,19 +980,26 @@ \NewDocumentCommand \ctex_ltj_save_char_range:n { > { \SplitArgument { 1 } { -> } } m } { \ctex_ltj_save_char_range:nn #1 } -\cs_new_protected_nopar:Npn \ctex_ltj_save_char_range:nn #1#2 +\cs_new_protected:Npn \ctex_ltj_save_char_range:nn #1#2 { \tl_put_right:Nx \l__ctex_ltj_char_range_tl - { { - \IfNoValueTF {#2} - { \int_eval:n {#1} , \int_eval:n {#1} } - { - \int_eval:n { \tl_if_blank:nTF {#1} { "80 } {#1} } , - \int_eval:n { \tl_if_blank:nTF {#2} { "10FFFF } {#2} } - } - } } + { { \__ctex_ltj_range_normalization:nn {#1} {#2} } } + } +\cs_new:Npn \__ctex_ltj_range_normalization:nn #1#2 + { + \tl_if_novalue:nTF {#2} + { + { \int_eval:n {#1} } + { \int_eval:n {#1} } + } + { + { \int_eval:n { \tl_if_blank:nTF {#1} { \c__ctex_ltj_range_min_int } {#1} } } + { \int_eval:n { \tl_if_blank:nTF {#2} { \c__ctex_ltj_range_max_int } {#2} } } + } } -\cs_new_protected_nopar:Npn \ctex_ltj_def_char_range_key:n #1 +\int_const:Nn \c__ctex_ltj_range_min_int { "80 } +\int_const:Nn \c__ctex_ltj_range_max_int { \c_max_char_int } +\cs_new_protected:Npn \ctex_ltj_def_char_range_key:n #1 { \keys_if_exist:nnF { ctex_ltj / fontspec } {#1} { @@ -965,28 +1010,8 @@ \cs_new_protected:Npn \ctex_ltj_char_range_key:nn #1#2 { \tl_if_blank:nTF {#2} - { \tl_set:Nn \l__ctex_ltj_char_range_clist {#1} } - { - \clist_if_empty:NT \l__ctex_ltj_char_range_clist - { - \tl_set:Nn \l__ctex_ltj_tmp_tl { {#1} } - \__ctex_ltj_char_range_parse_feature:w #2 \q_stop - } - } - } -\NewDocumentCommand \__ctex_ltj_char_range_parse_feature:w - { +o o u { \q_stop } } - { - \exp_args:NNf \tl_put_right:Nn \l__ctex_ltj_tmp_tl - { - \IfNoValueTF {#1} { {#3} } - { - \IfNoValueTF {#2} - { \tl_if_blank:nTF {#3} { { [#1] } } { [ {#1} ] {#3} } } - { [ {#1} ] { [#2] } } - } - } - \seq_put_right:No \l__ctex_ltj_alternate_seq { \l__ctex_ltj_tmp_tl } + { \clist_set:Nn \l__ctex_ltj_char_range_clist {#1} } + { \__ctex_ltj_push_alternate_prop:nn {#1} { {#1} #2 } } } \AtBeginDocument { @@ -996,14 +1021,14 @@ { } { \ctex_patch_failure:N \verbatim@font } } -\cs_new_protected_nopar:Npn \CTEX@verbatim@font@hook +\cs_new_protected:Npn \CTEX@verbatim@font@hook { \ltjsetparameter { autospacing = false , autoxspacing = false } } \cs_set_eq:NN \@@italiccorr \/ -\cs_new_protected_nopar:Npn \ctex_ltj_set_kanjiskip:N +\cs_new_protected:Npn \ctex_ltj_set_kanjiskip:N { \ltj@setpar@global \ltjsetkanjiskip } -\cs_new_protected_nopar:Npn \ctex_ltj_set_xkanjiskip:N +\cs_new_protected:Npn \ctex_ltj_set_xkanjiskip:N { \ltj@setpar@global \ltjsetxkanjiskip } -\cs_new_protected_nopar:Npn \ctex_update_default_family: +\cs_new_protected:Npn \ctex_update_default_family: { \tl_if_eq:NNT \CJKfamilydefault \l__ctex_family_default_init_tl { @@ -1031,35 +1056,11 @@ { \exp_not:o { \CJKfamilydefault } } } \tl_gset_eq:NN \CJKfamilydefault \l__ctex_family_default_init_tl -\cs_new_protected_nopar:Npn \ctex_detected_platform: - { - \tl_gset:Nx \g__ctex_fontset_tl - { - \lua_now:e - { - if ~ os.name == 'windows' then ~ - tex.sprint ( 'windows' ) - elseif ~ os.name == 'macosx' then ~ - tex.sprint ( 'mac' ) - else ~ - tex.sprint ( 'fandol' ) - end - } - } - } \ctex_hypersetup:n { pdfencoding = unicode } -\msg_new:nnn { ctex } { fntef-not-available } - { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ LuaLaTeX. } -\msg_warning:nn { ctex } { fntef-not-available } -\clist_map_inline:nn - { underdot , underline , underdblline , underwave , sout , xout } - { \cs_new_eq:cN { CTEX#1 } \use:n } -\cs_new_eq:NN \CTEXfilltwosides \use_none:n -\cs_new_eq:NN \endCTEXfilltwosides \prg_do_nothing: -\cs_new_protected_nopar:Npn \ctex_update_ccwd: +\cs_new_protected:Npn \ctex_update_ccwd: { \skip_set:Nn \ccwd { \ltjgetparameter { kanjiskip } + \zw } } \dim_new:N \ccwd -\cs_new_protected_nopar:Npn \ctex_update_ccglue: +\cs_new_protected:Npn \ctex_update_ccglue: { \ctex_ltj_set_kanjiskip:N \l__ctex_ccglue_skip } \skip_new:N \l__ctex_ccglue_skip \prg_new_conditional:Npnn \ctex_if_ccglue_touched: { TF } @@ -1067,11 +1068,11 @@ \skip_if_eq:nnTF { \l__ctex_ccglue_skip } { \ltjgetparameter { kanjiskip } } { \prg_return_false: } { \prg_return_true: } } -\cs_new_protected_nopar:Npn \ctex_update_em_unit: +\cs_new_protected:Npn \ctex_update_em_unit: { \dim_set:Nn \ccwd { \zw } } \cs_new_protected:Npn \ctex_add_to_selectfont:n #1 { - \cs_set_protected_nopar:Npx \CTEX@selectfont@hook + \cs_set_protected:Npx \CTEX@selectfont@hook { \exp_not:o { \CTEX@selectfont@hook #1 } } } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: @@ -1081,10 +1082,15 @@ { \tl_set:Nn \l__ctex_tmp_tl {#1} \cs_new_eq:NN \CTEX@selectfont@save #1 - \cs_new_protected_nopar:Npn \__ctex_restore_selectfont: + \cs_new_protected:Npn \__ctex_restore_selectfont: { + \cs_if_free:NF \scr@new@selectfont + { + \cs_set_eq:NN \scr@new@selectfont #1 + \cs_set_eq:NN \CTEX@selectfont@save \scr@selectfont + } \tl_put_left:Nn \@EverySelectfont@Init - { \let #1 \CTEX@selectfont@save } + { \cs_set_eq:NN #1 \CTEX@selectfont@save } \cs_undefine:N \__ctex_restore_selectfont: } } @@ -1105,7 +1111,7 @@ } \tl_set:Nn \CJK@family { song } \selectfont \tl_clear:N \CJK@family -\cs_new_protected_nopar:Npn \ctex_update_xkanjiskip: +\cs_new_protected:Npn \ctex_update_xkanjiskip: { \skip_if_eq:nnT { \ltjgetparameter { xkanjiskip } } { \l__ctex_xkanjiskip_skip } @@ -1124,44 +1130,42 @@ \dim_new:N \cht \dim_new:N \cdp \dim_new:N \cwd -\newluafunction \g__ctex_kanjisize_func \group_begin: \char_set_catcode_space:n { 32 } \lua_now:e { local nulltable = { } - local t = lua.get_functions_table() local fmt = luatexja.jfont.font_metric_table local getattribute = tex.getattribute local setdimen = tex.setdimen - t[\int_use:N \g__ctex_kanjisize_func] = function () - local ft = fmt[getattribute('ltj@curjfnt')] or nulltable + local func = lua.get_functions_table() + local id = luatexbase.new_luafunction("ctex") + func[id] = function () + local ft = fmt[getattribute("ltj@curjfnt")] or nulltable local ft = ft and ft.char_type or nulltable local fk = ft and ft[0] or nulltable - setdimen('cht', fk.height or 0) - setdimen('cdp', fk.depth or 0) - setdimen('cwd', fk.width or ft.zw or 0) + setdimen("cht", fk.height or 0) + setdimen("cdp", fk.depth or 0) + setdimen("cwd", fk.width or ft.zw or 0) end + token.set_lua("ctex_update_kanjisize:", id, "global", "protected") } \group_end: -\cs_new_protected_nopar:Npn \ctex_update_kanjisize: - { \tex_luafunction:D \g__ctex_kanjisize_func } \ctex_add_to_selectfont:n { \ctex_update_kanjisize: } -\keys_define:nn { ctex } +\ctex_define:n { space .code:n = { \msg_warning:nn { ctex } { invalid-option } } } -\keys_define:nn { ctex } +\ctex_define:n { punct .code:n = { - \tl_set:Nx \l__ctex_punct_tl { #1 } + \tl_set:Nx \l__ctex_punct_tl {#1} \ctex_mono_jfm:o { \l__ctex_punct_tl } } , punct .default:n = { quanjiao } , } -\tl_set:Nn \l__ctex_encoding_tl { UTF8 } %% %% %% End of file `ctex-engine-luatex.def'. diff --git a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def index 04b47108953..e447c91fff9 100644 --- a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def +++ b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def @@ -6,9 +6,9 @@ %% %% ctex.dtx (with options: `pdftex') %% -%% Copyright (C) 2003--2019 +%% Copyright (C) 2003--2020 %% 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 @@ -20,26 +20,31 @@ %% 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'. +%% 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 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee@gmail.com> $ {(pdf)LaTeX adapter (CTEX)} \ProvidesExplFile{ctex-engine-pdftex.def} - {\ExplFileDate}{2.4.16}{\ExplFileDescription} -\cs_new_protected_nopar:Npn \ctex_set_zhmap:n #1 + {\ExplFileDate}{2.5.1}{\ExplFileDescription} +\cs_new_protected:Npn \ctex_set_zhmap:n + { \tl_gput_right:Nx \g__ctex_zhmap_tl } +\cs_new_protected:Npn \ctex_use_zhmap: + { \tl_use:N \g__ctex_zhmap_tl } +\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 } { - \AtBeginDvi {#1} - \ctex_at_end_package:nn { atbegshi } - { \AtBeginShipoutFirst {#1} } + \AtBeginShipoutFirst { \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_nopar:Npn \ctex_family_cmap:nn #1#2 +\cs_new_protected:Npn \ctex_family_cmap:nn #1#2 { \cs_if_free:cF { #1 + #2 } { @@ -49,22 +54,22 @@ } \cs_generate_variant:Nn \ctex_family_cmap:nn { x } \cs_new_eq:NN \CTEX@Family@CMap \ctex_family_cmap:xn -\cs_new_protected_nopar:Npn \ctex_add_cmap:n #1 +\cs_new_protected:Npn \ctex_add_cmap:n #1 { \cs_if_free:NF \CJK@plane { \ctex_add_cmap:cn { __ctex_add_cmap_ #1 \CJK@plane : } {#1} } } -\cs_new_protected_nopar:Npn \ctex_add_cmap:Nn #1#2 +\cs_new_protected:Npn \ctex_add_cmap:Nn #1#2 { \cs_if_exist:NF #1 { \__ctex_save_cmap:Nn #1 {#2} } #1 } \cs_generate_variant:Nn \ctex_add_cmap:Nn { c } -\cs_new_protected_nopar:Npn \__ctex_save_cmap:Nn #1#2 +\cs_new_protected:Npn \__ctex_save_cmap:Nn #1#2 { - \tl_set:Nx \l__ctex_tmp_tl { \str_lower_case:n {#2} \CJK@plane } + \tl_set:Nx \l__ctex_tmp_tl { \str_lowercase:n {#2} \CJK@plane } \tex_immediate:D \tex_pdfobj:D stream ~ file { \l__ctex_tmp_tl .cmap } - \cs_new_protected_nopar:Npx #1 + \cs_new_protected:Npx #1 { \exp_not:N \tex_pdffontattr:D \exp_not:N \tex_font:D { /ToUnicode ~ \int_use:N \tex_pdflastobj:D \c_space_tl 0 ~ R } @@ -85,14 +90,14 @@ } { \group_end: } \if_bool:N \g__ctex_zhmCJK_bool - \PassOptionsToPackage { encoding = \l__ctex_encoding_tl } { zhmCJK } + \PassOptionsToPackage { encoding = \g__ctex_encoding_tl } { zhmCJK } \RequirePackage { zhmCJK } \else: - \str_if_eq:onTF { \l__ctex_encoding_tl } { GBK } + \str_if_eq:onTF { \g__ctex_encoding_tl } { GBK } { \RequirePackage { CJK } } { \RequirePackage { CJKutf8 } } \RequirePackage { CJKpunct , CJKspace } - \cs_new_protected_nopar:Npn \ctex_load_zhmap:nnnn #1#2#3#4 + \cs_new_protected:Npn \ctex_load_zhmap:nnnn #1#2#3#4 { \tl_set:Nn \CJKrmdefault {#1} \tl_set:Nn \CJKsfdefault {#2} @@ -100,7 +105,7 @@ \ctex_set_zhmap:n { \ctex_zhmap_input:n {#4} } } \@onlypreamble \ctex_load_zhmap:nnnn - \cs_new_protected_nopar:Npn \ctex_zhmap_input:n #1 + \cs_new_protected:Npn \ctex_zhmap_input:n #1 { \ctex_file_wrapper:nnn { @@ -118,24 +123,12 @@ \tl_if_exist:NF \CJKrmdefault { \tl_new:N \CJKrmdefault } \tl_if_exist:NF \CJKsfdefault { \tl_new:N \CJKsfdefault } \tl_if_exist:NF \CJKttdefault { \tl_new:N \CJKttdefault } - \ctex_preto_cmd:NnnTF \rmfamily { \ExplSyntaxOff } - { \CJKfamily { \CJKrmdefault } } - { } - { \ctex_patch_failure:N \rmfamily } - \ctex_preto_cmd:NnnTF \sffamily { \ExplSyntaxOff } - { \CJKfamily { \CJKsfdefault } } - { } - { \ctex_patch_failure:N \sffamily } - \ctex_preto_cmd:NnnTF \ttfamily { \ExplSyntaxOff } - { \CJKfamily { \CJKttdefault } } - { } - { \ctex_patch_failure:N \ttfamily } - \ctex_preto_cmd:NnnTF \normalfont { \ExplSyntaxOff } - { \CJKfamily { \CJKfamilydefault } } - { \cs_set_eq:NN \reset@font \normalfont } - { \ctex_patch_failure:N \normalfont } + \g@addto@macro \@rmfamilyhook { \CJKfamily { \CJKrmdefault } } + \g@addto@macro \@sffamilyhook { \CJKfamily { \CJKsfdefault } } + \g@addto@macro \@ttfamilyhook { \CJKfamily { \CJKttdefault } } + \g@addto@macro \@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } } \fi: -\cs_new_protected_nopar:Npn \ctex_CJK_input:n #1 +\cs_new_protected:Npn \ctex_CJK_input:n #1 { \ctex_file_wrapper:nnn { @@ -152,7 +145,7 @@ } \cs_set_eq:NN \CJK@input \ctex_CJK_input:n \if_cs_exist:N \CJK@surr - \cs_new_protected_nopar:Npn \ctex_plane_to_utfxvibe:Nn #1#2 + \cs_new_protected:Npn \ctex_plane_to_utfxvibe:Nn #1#2 { \tl_set:Nx \l__ctex_tmp_tl {#2} \int_set:Nn \l__ctex_tmp_int @@ -179,7 +172,7 @@ } \ctex_at_end_preamble:n { \ctex_update_default_family: } \reverse_if:N \if_bool:N \g__ctex_zhmCJK_bool - \str_if_eq:onF { \l__ctex_encoding_tl } { UTF8 } + \str_if_eq:onF { \g__ctex_encoding_tl } { UTF8 } { \CJK@makeActive \CJK@loadBinding { standard } @@ -187,21 +180,21 @@ \exp_args:Nx \ctex_at_end_preamble:n { \exp_not:N \CJK@envStart - { } { \l__ctex_encoding_tl } { \exp_not:N \CJKfamilydefault } + { } { \g__ctex_encoding_tl } { \exp_not:N \CJKfamilydefault } \exp_not:N \CJKtilde } \fi: \cs_new_eq:NN \ctex_auto_ignorespaces: \CJK@@ignorespaces -\cs_new_protected_nopar:Npn \ctex_ignorespaces_case:N #1 +\cs_new_protected:Npn \ctex_ignorespaces_case:N #1 { - \cs_set_protected_nopar:Npn \ctex_set_ignorespaces: + \cs_set_protected:Npn \ctex_set_ignorespaces: { \cs_set_eq:NN \CJK@ignorespaces #1 } \ctex_set_ignorespaces: } -\cs_new_protected_nopar:Npn \ctex_set_ignorespaces: +\cs_new_protected:Npn \ctex_set_ignorespaces: { \cs_set_eq:NN \CJK@ignorespaces \ctex_auto_ignorespaces: } \ctex_gadd_hook:Nn \CJKhook { \ctex_set_ignorespaces: } -\cs_new_protected_nopar:Npn \ctex_punct_set:n #1 +\cs_new_protected:Npn \ctex_punct_set:n #1 { \clist_map_inline:Nn \c__ctex_punct_family_clist { @@ -218,12 +211,12 @@ zhsong , zhhei , zhfs , zhkai , zhli , zhyou , zhsongb , zhheil , zhheib , zhyoub , zhyahei , zhyaheib } -\cs_new_protected_nopar:Npn \ctex_punct_map_family:nn #1#2 +\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_nopar:Npn \ctex_punct_map_bfseries:nn #1#2 +\cs_new_protected:Npn \ctex_punct_map_bfseries:nn #1#2 { \clist_map_inline:nn {#1} { @@ -231,7 +224,7 @@ \ctex_punct_map_series:nnn { ##1 } { bx } {#2} } } -\cs_new_protected_nopar:Npn \ctex_punct_map_series:nnn #1#2#3 +\cs_new_protected:Npn \ctex_punct_map_series:nnn #1#2#3 { \CJKpunctmapfamily { C19 } {#1} {#2} { m } {#3} \CJKpunctmapfamily { C19 } {#1} {#2} { it } {#3} @@ -240,7 +233,7 @@ \CJKpunctmapfamily { C70 } {#1} {#2} { it } {#3} \CJKpunctmapfamily { C70 } {#1} {#2} { sl } {#3} } -\cs_new_protected_nopar:Npn \ctex_punct_map_itshape:nn #1#2 +\cs_new_protected:Npn \ctex_punct_map_itshape:nn #1#2 { \CJKpunctmapfamily { C19 } {#1} { m } { it } {#2} \CJKpunctmapfamily { C19 } {#1} { b } { it } {#2} @@ -249,11 +242,11 @@ \CJKpunctmapfamily { C70 } {#1} { b } { it } {#2} \CJKpunctmapfamily { C70 } {#1} { bx } { it } {#2} } -\cs_new_protected_nopar:Npn \ctex_punct_space:nn #1#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 } -\cs_new_protected_nopar:Npn \ctex_update_default_family: +\cs_new_protected:Npn \ctex_update_default_family: { \tl_if_eq:NNT \CJKfamilydefault \l__ctex_family_default_init_tl { @@ -280,31 +273,8 @@ { \exp_not:o { \CJKfamilydefault } } } \tl_gset_eq:NN \CJKfamilydefault \l__ctex_family_default_init_tl -\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_upper_case_file_str } - { \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 } } - } -\str_const:Nx \c__ctex_upper_case_file_str - { \exp_args:No \str_upper_case:n { \g_file_curr_name_str } } -\cs_new_protected_nopar:Npn \ctex_if_macosx:TF #1#2 - { - \file_if_exist:nTF { \c__ctex_macosx_file_str } - { \tl_gset:Nn \g__ctex_fontset_tl {#1} } - { \tl_gset:Nn \g__ctex_fontset_tl {#2} } - } -\str_const:Nn \c__ctex_macosx_file_str { /Library/Fonts/Songti.ttc } \ctex_hypersetup:n { driverfallback = dvipdfmx } -\str_if_eq:onTF { \l__ctex_encoding_tl } { GBK } +\str_if_eq:onTF { \g__ctex_encoding_tl } { GBK } { \ctex_hypersetup:n { CJKbookmarks = true } \sys_if_output_pdf:TF @@ -322,49 +292,24 @@ } } { \ctex_hypersetup:n { pdfencoding = unicode } } -\RequirePackage { CJKfntef } -\normalem -\cs_new_protected_nopar:Npn \__ctex_clear_fntef_color:n #1 - { \tl_clear:c { CJK#1color } } -\clist_map_inline:nn - { underdot , underline , underdblline , underwave , sout , xout } +\ctex_at_end_package:nn { CJKfntef } { - \__ctex_clear_fntef_color:n {#1} - \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 } -\clist_map_inline:nn - { - underdotbasesep , underdotsep , underlinebasesep , - underlinesep , underdbllinesep , underdbllinebasesep , - underwavebasesep , underwavesep , southeight , - underdotcolor , underwavecolor , underlinecolor , - underdbllinecolor , soutcolor , xoutcolor + \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_eq:cc { CTEX#1 } { CJK#1 } - \cs_set_nopar:cpx { CJK#1 } { \exp_not:c { CTEX#1 } } - } -\cs_new_protected_nopar:Npn \ctex_update_ccwd: +\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_nopar:Npn \ctex_update_ccglue: +\cs_new_protected:Npn \ctex_update_ccglue: { - \cs_set_protected_nopar:Npn \CJKglue + \cs_set_protected:Npn \CJKglue { \skip_horizontal:N \l__ctex_ccglue_skip } } \skip_new:N \l__ctex_ccglue_skip @@ -374,11 +319,11 @@ \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: +\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_nopar:Npx \CTEX@selectfont@hook + \cs_set_protected:Npx \CTEX@selectfont@hook { \exp_not:o { \CTEX@selectfont@hook #1 } } } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: @@ -388,10 +333,17 @@ { \tl_set:Nn \l__ctex_tmp_tl {#1} \cs_new_eq:NN \CTEX@selectfont@save #1 - \cs_new_protected_nopar:Npn \__ctex_restore_selectfont: + \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 - { \let #1 \CTEX@selectfont@save } + { \cs_set_eq:NN #1 \CTEX@selectfont@save } \cs_undefine:N \__ctex_restore_selectfont: } } @@ -405,7 +357,7 @@ { \ctex_patch_failure:N \selectfont } \fi: \EverySelectfont { \cs_if_exist:NF \CJK@plane { \CTEX@selectfont@hook } } -\keys_define:nn { ctex } +\ctex_define:n { space .choice: , space / true .code:n = @@ -417,11 +369,11 @@ space .default:n = { true } , space .initial:n = { auto } } -\keys_define:nn { ctex } +\ctex_define:n { punct .code:n = { - \tl_set:Nx \l__ctex_punct_tl { #1 } + \tl_set:Nx \l__ctex_punct_tl {#1} \punctstyle { \l__ctex_punct_tl } } , punct .default:n = { quanjiao } , diff --git a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-uptex.def b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-uptex.def index 0ef4edfae63..7f24ee2da25 100644 --- a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-uptex.def +++ b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-uptex.def @@ -6,9 +6,9 @@ %% %% ctex.dtx (with options: `uptex') %% -%% Copyright (C) 2003--2019 +%% Copyright (C) 2003--2020 %% 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 @@ -20,57 +20,42 @@ %% 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'. +%% 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 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee@gmail.com> $ {upTeX adapter (CTEX)} \ProvidesExplFile{ctex-engine-uptex.def} - {\ExplFileDate}{2.4.16}{\ExplFileDescription} -\cs_new_protected_nopar:Npn \ctex_set_zhmap:n #1 - { - \AtBeginDvi {#1} - \ctex_at_end_package:nn { atbegshi } - { \AtBeginShipoutFirst {#1} } - } + {\ExplFileDate}{2.5.1}{\ExplFileDescription} +\cs_new_protected:Npn \ctex_set_zhmap:n + { \tl_gput_right:Nx \g__ctex_zhmap_tl } +\cs_new_protected:Npn \ctex_use_zhmap: + { \tl_use:N \g__ctex_zhmap_tl } +\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 } + { + \AtBeginShipoutFirst { \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 -\tl_set:Nn \CJKrmdefault { zhrm } -\tl_set:Nn \CJKsfdefault { zhsf } -\tl_set:Nn \CJKttdefault { zhtt } -\tl_set:Nn \CJKfamilydefault { \CJKrmdefault } +\tl_if_exist:NF \CJKfamilydefault + { \tl_const:Nn \CJKfamilydefault { \CJKrmdefault } } +\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { zhrm } } +\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { zhsf } } +\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { zhtt } } \tl_set:Nn \kanjifamilydefault { \CJKfamilydefault } -\RenewDocumentCommand \rmfamily { } - { - \not@math@alphabet \rmfamily \mathrm - \romanfamily \rmdefault - \kanjifamily \CJKrmdefault - \selectfont - } -\RenewDocumentCommand \sffamily { } - { - \not@math@alphabet \sffamily \mathsf - \romanfamily \sfdefault - \kanjifamily \CJKsfdefault - \selectfont - } -\RenewDocumentCommand \ttfamily { } - { - \not@math@alphabet \ttfamily \mathtt - \romanfamily \ttdefault - \kanjifamily \CJKttdefault - \selectfont - } +\g@addto@macro \@rmfamilyhook { \kanjifamily { \CJKrmdefault } } +\g@addto@macro \@sffamilyhook { \kanjifamily { \CJKsfdefault } } +\g@addto@macro \@ttfamilyhook { \kanjifamily { \CJKttdefault } } \NewDocumentCommand \CJKfamily { m } - { - \kanjifamily {#1} - \selectfont - } -\DeclareErrorKanjiFont{JY2}{zhrm}{m}{n}{10} -\DeclareKanjiSubstitution{JY2}{zhrm}{m}{n} -\DeclareKanjiSubstitution{JT2}{zhrm}{m}{n} + { \kanjifamily {#1} \selectfont } +\DeclareErrorKanjiFont {JY2}{zhrm}{m}{n}{10} +\DeclareKanjiSubstitution {JY2}{zhrm}{m}{n} +\DeclareKanjiSubstitution {JT2}{zhrm}{m}{n} \DeclareSymbolFont{mincho}{JY2}{zhrm}{m}{n} \SetSymbolFont{mincho}{bold}{JY2}{zhrm}{bx}{n} \jfam \symmincho @@ -87,43 +72,59 @@ { \eminnershape \else \itshape } } \cs_set_nopar:Npn \eminnershape { \upshape } -\cs_new_protected_nopar:Npn \ctex_set_upfamily:nnn #1 #2 #3 +\cs_new_protected:Npn \ctex_set_upfamily:nnn #1#2#3 { \DeclareKanjiFamily{JY2}{#1}{} \DeclareKanjiFamily{JT2}{#1}{} \DeclareFontShape{JY2}{#1}{m}{n}{<->~ #2-h}{} \DeclareFontShape{JT2}{#1}{m}{n}{<->~ #2-v}{} - \tl_if_empty:nF { #3 } + \tl_if_empty:nF {#3} { + \DeclareFontShape{JY2}{#1}{b}{n}{<->~ #3-h}{} + \DeclareFontShape{JT2}{#1}{b}{n}{<->~ #3-v}{} \DeclareFontShape{JY2}{#1}{bx}{n}{<->~ #3-h}{} \DeclareFontShape{JT2}{#1}{bx}{n}{<->~ #3-v}{} } } -\@onlypreamble \ctex_set_upfamily:nnn -\cs_new_protected_nopar:Npn \ctex_set_upmap:nnn #1 #2 #3 +\cs_new_protected:Npn \ctex_set_upmap:nnn #1#2#3 { \ctex_set_zhmap:n { - \special{ pdf:mapline~ #1-h~ UniGB-UTF16-H~ #2 } - \special{ pdf:mapline~ #1-v~ UniGB-UTF16-V~ #2 } - \tl_if_empty:nF { #3 } + \special { pdf:mapline~#1-h~UniGB-UTF16-H~#2 } + \special { pdf:mapline~#1-v~UniGB-UTF16-V~#2 } + \tl_if_empty:nF {#3} { - \special{ pdf:mapline~ #1b-h~ UniGB-UTF16-H~ #3 } - \special{ pdf:mapline~ #1b-v~ UniGB-UTF16-V~ #3 } + \special { pdf:mapline~#1b-h~UniGB-UTF16-H~#3 } + \special { pdf:mapline~#1b-v~UniGB-UTF16-V~#3 } } } } -\@onlypreamble \ctex_set_upmap:nnn -\cs_new_protected_nopar:Npn \ctex_set_upfonts:nnnnnn #1 #2 #3 #4 #5 #6 +\cs_new_protected:Npn \ctex_set_upmap_unicode:nnn #1#2#3 + { + \ctex_set_zhmap:n + { + \special { pdf:mapline~#1-h~unicode~#2 } + \special { pdf:mapline~#1-v~unicode~#2 } + \tl_if_empty:nF {#3} + { + \special { pdf:mapline~#1b-h~unicode~#3 } + \special { pdf:mapline~#1b-v~unicode~#3 } + } + } + } +\cs_new_protected:Npn \ctex_set_upfonts:nnnnnn #1#2#3#4#5#6 { - \ctex_set_upmap:nnn { upserif } { #1 } { #2 } - \ctex_set_upmap:nnn { upserifit } { #3 } {} - \ctex_set_upmap:nnn { upsans } { #4 } { #5 } - \ctex_set_upmap:nnn { upmono } { #6 } {} + \ctex_set_upmap:nnn { upserif } {#1} {#2} + \ctex_set_upmap:nnn { upserifit } {#3} {} + \ctex_set_upmap:nnn { upsans } {#4} {#5} + \ctex_set_upmap:nnn { upmono } {#6} {} } +\@onlypreamble \ctex_set_upfamily:nnn +\@onlypreamble \ctex_set_upmap:nnn +\@onlypreamble \ctex_set_upmap_unicode:nnn \@onlypreamble \ctex_set_upfonts:nnnnnn \RequirePackage { pxeverysel } -\cs_new_protected_nopar:Npn \ctex_update_default_family: +\cs_new_protected:Npn \ctex_update_default_family: { \tl_if_eq:NNT \CJKfamilydefault \l__ctex_family_default_init_tl { @@ -150,44 +151,13 @@ { \exp_not:o { \CJKfamilydefault } } } \tl_gset_eq:NN \CJKfamilydefault \l__ctex_family_default_init_tl -\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_upper_case_file_str } - { \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 } } - } -\str_const:Nx \c__ctex_upper_case_file_str - { \exp_args:No \str_upper_case:n { \g_file_curr_name_str } } -\cs_new_protected_nopar:Npn \ctex_if_macosx:TF #1#2 - { - \file_if_exist:nTF { \c__ctex_macosx_file_str } - { \tl_gset:Nn \g__ctex_fontset_tl {#1} } - { \tl_gset:Nn \g__ctex_fontset_tl {#2} } - } -\str_const:Nn \c__ctex_macosx_file_str { /Library/Fonts/Songti.ttc } \ctex_hypersetup:n { driverfallback = dvipdfmx } \ctex_at_end_package:nn { hyperref } - { \AtBeginShipoutFirst { \special { pdf:tounicode~ UTF8-UTF16 } } } -\msg_new:nnn { ctex } { fntef-not-available } - { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ upLaTeX. } -\msg_warning:nn { ctex } { fntef-not-available } -\clist_map_inline:nn - { underdot , underline , underdblline , underwave , sout , xout } - { \cs_new_eq:cN { CTEX#1 } \use:n } -\cs_new_eq:NN \CTEXfilltwosides \use_none:n -\cs_new_eq:NN \endCTEXfilltwosides \prg_do_nothing: -\cs_new_protected_nopar:Npn \ctex_update_ccwd: + { \AtBeginShipoutFirst { \special { pdf:tounicode~UTF8-UTF16 } } } +\cs_new_protected:Npn \ctex_update_ccwd: { \skip_set:Nn \ccwd { 1zw + \tex_kanjiskip:D } } \dim_new:N \ccwd -\cs_new_protected_nopar:Npn \ctex_update_ccglue: +\cs_new_protected:Npn \ctex_update_ccglue: { \skip_set_eq:NN \tex_kanjiskip:D \l__ctex_ccglue_skip } \skip_new:N \l__ctex_ccglue_skip \prg_new_conditional:Npnn \ctex_if_ccglue_touched: { TF } @@ -195,11 +165,11 @@ \skip_if_eq:nnTF { \l__ctex_ccglue_skip } { \tex_kanjiskip:D } { \prg_return_false: } { \prg_return_true: } } -\cs_new_protected_nopar:Npn \ctex_update_em_unit: +\cs_new_protected:Npn \ctex_update_em_unit: { \dim_set:Nn \ccwd { 1zw } } \cs_new_protected:Npn \ctex_add_to_selectfont:n #1 { - \cs_set_protected_nopar:Npx \CTEX@selectfont@hook + \cs_set_protected:Npx \CTEX@selectfont@hook { \exp_not:o { \CTEX@selectfont@hook #1 } } } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: @@ -209,10 +179,20 @@ { \tl_set:Nn \l__ctex_tmp_tl {#1} \cs_new_eq:NN \CTEX@selectfont@save #1 - \cs_new_protected_nopar:Npn \__ctex_restore_selectfont: + \cs_new_protected:Npn \__ctex_restore_selectfont: { + \cs_if_free:NF \scr@new@selectfont + { + \cs_if_free:NF \par@update + { + \tl_put_right:Nn \@EverySelectfont@Init + { \tl_put_right:Nn #1 { \par@update } } + } + \cs_set_eq:NN \scr@new@selectfont #1 + \cs_set_eq:NN \CTEX@selectfont@save \scr@selectfont + } \tl_put_left:Nn \@EverySelectfont@Init - { \let #1 \CTEX@selectfont@save } + { \cs_set_eq:NN #1 \CTEX@selectfont@save } \cs_undefine:N \__ctex_restore_selectfont: } } @@ -226,7 +206,7 @@ { \ctex_patch_failure:N \selectfont } \fi: \EverySelectfont { \CTEX@selectfont@hook } -\cs_new_protected_nopar:Npn \ctex_update_xkanjiskip: +\cs_new_protected:Npn \ctex_update_xkanjiskip: { \skip_if_eq:nnT { \tex_xkanjiskip:D } { \l__ctex_xkanjiskip_skip } @@ -242,21 +222,20 @@ \skip_set:Nn \l__ctex_xkanjiskip_skip { \tex_xkanjiskip:D } \ctex_add_to_selectfont:n { \ctex_update_xkanjiskip: } -\keys_define:nn { ctex } +\ctex_define:n { space .code:n = { \msg_warning:nn { ctex } { invalid-option } } } -\keys_define:nn { ctex } +\ctex_define:n { punct .code:n = { - \tl_set:Nx \l__ctex_punct_tl { #1 } + \tl_set:Nx \l__ctex_punct_tl {#1} \msg_warning:nn { ctex } { invalid-option } } , punct .default:n = { quanjiao } , } -\tl_set:Nn \l__ctex_encoding_tl { UTF8 } %% %% %% End of file `ctex-engine-uptex.def'. diff --git a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def index 3b3752a9bca..26435410903 100644 --- a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def +++ b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def @@ -6,9 +6,9 @@ %% %% ctex.dtx (with options: `xetex') %% -%% Copyright (C) 2003--2019 +%% Copyright (C) 2003--2020 %% 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 @@ -20,16 +20,14 @@ %% 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'. +%% 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 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee@gmail.com> $ {XeLaTeX adapter (CTEX)} \ProvidesExplFile{ctex-engine-xetex.def} - {\ExplFileDate}{2.4.16}{\ExplFileDescription} + {\ExplFileDate}{2.5.1}{\ExplFileDescription} \RequirePackage { xeCJK } \exp_args:Nx \xeCJKsetup { @@ -38,67 +36,31 @@ } \@ifpackagelater { fontspec } { 2014/05/25 } { } { \msg_error:nnn { ctex } { package-too-old } { fontspec } } -\cs_new_protected_nopar:Npn \ctex_detected_platform: +\ctex_hypersetup:n { pdfencoding = unicode } +\ctex_at_end_package:nn { xeCJKfntef } { - \file_if_exist:nTF { /dev/null } + \@ifpackagelater { xeCJKfntef } { 2014/11/04 } { - \file_if_exist:nTF { nul: } - { - \file_if_exist:nTF { \c__ctex_upper_case_file_str } - { \ctex_if_macosx:TF { mac } { windows } } - { \ctex_if_macosx:TF { mac } { fandol } } - } - { \ctex_if_macosx:TF { mac } { fandol } } + \cs_new_protected:Npn \__ctex_clear_fntef_color:n #1 + { \xeCJKsetup { #1 / format = { } } } } - { \tl_gset:Nn \g__ctex_fontset_tl { windows } } - } -\str_const:Nx \c__ctex_upper_case_file_str - { \exp_args:No \str_upper_case:n { \g_file_curr_name_str } } -\cs_new_protected_nopar:Npn \ctex_if_macosx:TF #1#2 - { - \file_if_exist:nTF { \c__ctex_macosx_file_str } - { \tl_gset:Nn \g__ctex_fontset_tl {#1} } - { \tl_gset:Nn \g__ctex_fontset_tl {#2} } - } -\str_const:Nn \c__ctex_macosx_file_str { /Library/Fonts/Songti.ttc } -\ctex_hypersetup:n { pdfencoding = unicode } -\RequirePackage { xeCJKfntef } -\@ifpackagelater { xeCJKfntef } { 2014/11/04 } - { - \cs_new_protected_nopar:Npn \__ctex_clear_fntef_color:n #1 - { \xeCJKsetup { #1 / format = { } } } - } - { - \cs_new_protected_nopar: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_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: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_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: +\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_nopar:Npn \ctex_update_ccglue: +\cs_new_protected:Npn \ctex_update_ccglue: { - \cs_set_protected_nopar:Npn \CJKglue + \cs_set_protected:Npn \CJKglue { \skip_horizontal:N \l__ctex_ccglue_skip } } \skip_new:N \l__ctex_ccglue_skip @@ -108,11 +70,11 @@ \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: +\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_nopar:Npx \CTEX@selectfont@hook + \cs_set_protected:Npx \CTEX@selectfont@hook { \exp_not:o { \CTEX@selectfont@hook #1 } } } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: @@ -122,10 +84,15 @@ { \tl_set:Nn \l__ctex_tmp_tl {#1} \cs_new_eq:NN \CTEX@selectfont@save #1 - \cs_new_protected_nopar:Npn \__ctex_restore_selectfont: + \cs_new_protected:Npn \__ctex_restore_selectfont: { + \cs_if_free:NF \scr@new@selectfont + { + \cs_set_eq:NN \scr@new@selectfont #1 + \cs_set_eq:NN \CTEX@selectfont@save \scr@selectfont + } \tl_put_left:Nn \@EverySelectfont@Init - { \let #1 \CTEX@selectfont@save } + { \cs_set_eq:NN #1 \CTEX@selectfont@save } \cs_undefine:N \__ctex_restore_selectfont: } } @@ -139,7 +106,7 @@ { \ctex_patch_failure:N \selectfont } \fi: \EverySelectfont { \CTEX@selectfont@hook } -\keys_define:nn { ctex } +\ctex_define:n { space .choice: , space / true .code:n = @@ -151,16 +118,15 @@ space .default:n = { true } , space .initial:n = { auto } } -\keys_define:nn { ctex } +\ctex_define:n { punct .code:n = { - \tl_set:Nx \l__ctex_punct_tl { #1 } + \tl_set:Nx \l__ctex_punct_tl {#1} \xeCJKsetup { PunctStyle = \l__ctex_punct_tl } } , punct .default:n = { quanjiao } , } -\tl_set:Nn \l__ctex_encoding_tl { UTF8 } %% %% %% End of file `ctex-engine-xetex.def'. |