| 1 |
%% |
| 2 |
%% This is file `ctex-engine-uptex.def', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% ctex.dtx (with options: `uptex') |
| 8 |
%% |
| 9 |
%% Copyright (C) 2003--2022 |
| 10 |
%% CTEX.ORG and any individual authors listed in the documentation. |
| 11 |
%% --------------------------------------------------------------------- |
| 12 |
%% |
| 13 |
%% This work may be distributed and/or modified under the |
| 14 |
%% conditions of the LaTeX Project Public License, either |
| 15 |
%% version 1.3c of this license or (at your option) any later |
| 16 |
%% version. This version of this license is in |
| 17 |
%% http://www.latex-project.org/lppl/lppl-1-3c.txt |
| 18 |
%% and the latest version of this license is in |
| 19 |
%% http://www.latex-project.org/lppl.txt |
| 20 |
%% and version 1.3 or later is part of all distributions of |
| 21 |
%% LaTeX version 2005/12/01 or later. |
| 22 |
%% |
| 23 |
%% This work has the LPPL maintenance status "maintained". |
| 24 |
%% |
| 25 |
%% --------------------------------------------------------------------- |
| 26 |
%% |
| 27 |
\GetIdInfo$Id: ctex.dtx 13a2256 2022-07-14 18:54:09 +0800 Qing Lee <[email protected]> $ |
| 28 |
{upTeX adapter (CTEX)} |
| 29 |
\ProvidesExplFile{ctex-engine-uptex.def} |
| 30 |
{\ExplFileDate}{2.5.10}{\ExplFileDescription} |
| 31 |
\cs_new_protected:Npn \ctex_set_zhmap:n |
| 32 |
{ \tl_gput_right:Nx \g__ctex_zhmap_tl } |
| 33 |
\cs_new_protected:Npn \ctex_use_zhmap: |
| 34 |
{ \tl_use:N \g__ctex_zhmap_tl } |
| 35 |
\cs_if_exist:NTF \ctex_gadd_ltxhook:nn |
| 36 |
{ |
| 37 |
\cs_new_protected:Npn \ctex_at_shipout_first:n |
| 38 |
{ \ctex_gadd_ltxhook:nn { shipout/firstpage } } |
| 39 |
\ctex_at_shipout_first:n { \ctex_use_zhmap: } |
| 40 |
} |
| 41 |
{ |
| 42 |
\cs_new_protected:Npn \ctex_add_dvi_zhmap: |
| 43 |
{ \AtBeginDvi { \ctex_use_zhmap: } } |
| 44 |
\ctex_after_end_preamble:n { \ctex_add_dvi_zhmap: } |
| 45 |
\ctex_at_end_package:nn { atbegshi } |
| 46 |
{ |
| 47 |
\cs_new_protected:Npn \ctex_at_shipout_first:n |
| 48 |
{ \AtBeginShipoutFirst } |
| 49 |
\ctex_at_shipout_first:n { \ctex_use_zhmap: } |
| 50 |
\cs_gset_eq:NN \ctex_add_dvi_zhmap: \prg_do_nothing: |
| 51 |
} |
| 52 |
} |
| 53 |
\tl_new:N \g__ctex_zhmap_tl |
| 54 |
\@onlypreamble \ctex_set_zhmap:n |
| 55 |
\NewDocumentCommand \CJKfamily { m } |
| 56 |
{ \kanjifamily {#1} \selectfont } |
| 57 |
\DeclareErrorKanjiFont {JY2}{zhrm}{m}{n}{10} |
| 58 |
\DeclareKanjiSubstitution {JY2}{zhrm}{m}{n} |
| 59 |
\DeclareKanjiSubstitution {JT2}{zhrm}{m}{n} |
| 60 |
\DeclareSymbolFont{mincho}{JY2}{zhrm}{m}{n} |
| 61 |
\SetSymbolFont{mincho}{bold}{JY2}{zhrm}{bx}{n} |
| 62 |
\jfam \symmincho |
| 63 |
\ctex_patch_cmd_once:NnnnTF \em |
| 64 |
{ \ExplSyntaxOff } |
| 65 |
{ \eminnershape \else \gtfamily \itshape } |
| 66 |
{ \eminnershape \else \itshape } |
| 67 |
{ } |
| 68 |
{ |
| 69 |
\ctex_patch_cmd:Nnn \em |
| 70 |
{ \mcfamily \upshape \else \gtfamily \itshape } |
| 71 |
{ \eminnershape \else \itshape } |
| 72 |
} |
| 73 |
\cs_set_nopar:Npn \eminnershape { \upshape } |
| 74 |
\cs_new_protected:Npn \ctex_set_upfamily:nnn #1#2#3 |
| 75 |
{ |
| 76 |
\DeclareKanjiFamily{JY2}{#1}{} |
| 77 |
\DeclareKanjiFamily{JT2}{#1}{} |
| 78 |
\DeclareFontShape{JY2}{#1}{m}{n}{<->~ #2-h}{} |
| 79 |
\DeclareFontShape{JT2}{#1}{m}{n}{<->~ #2-v}{} |
| 80 |
\tl_if_empty:nF {#3} |
| 81 |
{ |
| 82 |
\DeclareFontShape{JY2}{#1}{b}{n}{<->~ #3-h}{} |
| 83 |
\DeclareFontShape{JT2}{#1}{b}{n}{<->~ #3-v}{} |
| 84 |
\DeclareFontShape{JY2}{#1}{bx}{n}{<->~ #3-h}{} |
| 85 |
\DeclareFontShape{JT2}{#1}{bx}{n}{<->~ #3-v}{} |
| 86 |
} |
| 87 |
} |
| 88 |
\cs_new_protected:Npn \ctex_set_upmap:nnn #1#2#3 |
| 89 |
{ |
| 90 |
\ctex_set_zhmap:n |
| 91 |
{ |
| 92 |
\special { pdf:mapline~#1-h~UniGB-UTF16-H~#2 } |
| 93 |
\special { pdf:mapline~#1-v~UniGB-UTF16-V~#2 } |
| 94 |
\tl_if_empty:nF {#3} |
| 95 |
{ |
| 96 |
\special { pdf:mapline~#1b-h~UniGB-UTF16-H~#3 } |
| 97 |
\special { pdf:mapline~#1b-v~UniGB-UTF16-V~#3 } |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
\cs_new_protected:Npn \ctex_set_upmap_unicode:nnn #1#2#3 |
| 102 |
{ |
| 103 |
\ctex_set_zhmap:n |
| 104 |
{ |
| 105 |
\special { pdf:mapline~#1-h~unicode~#2 } |
| 106 |
\special { pdf:mapline~#1-v~unicode~#2 } |
| 107 |
\tl_if_empty:nF {#3} |
| 108 |
{ |
| 109 |
\special { pdf:mapline~#1b-h~unicode~#3 } |
| 110 |
\special { pdf:mapline~#1b-v~unicode~#3 } |
| 111 |
} |
| 112 |
} |
| 113 |
} |
| 114 |
\cs_new_protected:Npn \ctex_set_upfonts:nnnnnn #1#2#3#4#5#6 |
| 115 |
{ |
| 116 |
\ctex_set_upmap:nnn { upserif } {#1} {#2} |
| 117 |
\ctex_set_upmap:nnn { upserifit } {#3} {} |
| 118 |
\ctex_set_upmap:nnn { upsans } {#4} {#5} |
| 119 |
\ctex_set_upmap:nnn { upmono } {#6} {} |
| 120 |
} |
| 121 |
\@onlypreamble \ctex_set_upfamily:nnn |
| 122 |
\@onlypreamble \ctex_set_upmap:nnn |
| 123 |
\@onlypreamble \ctex_set_upmap_unicode:nnn |
| 124 |
\@onlypreamble \ctex_set_upfonts:nnnnnn |
| 125 |
\bool_if:NT \c__ctex_everysel_loaded_bool |
| 126 |
{ \RequirePackage { pxeverysel } } |
| 127 |
\cs_new_protected:Npn \ctex_provide_font_hook:NNN #1#2 |
| 128 |
{ |
| 129 |
\exp_args:Nc \__ctex_provide_font_hook_aux:NNNN |
| 130 |
{ CTEX \cs_to_str:N #2 } #1#2 |
| 131 |
} |
| 132 |
\cs_if_exist:NTF \ctex_gadd_ltxhook:nn |
| 133 |
{ |
| 134 |
\cs_new_protected:Npn \__ctex_provide_font_hook_aux:NNNN #1#2#3#4 |
| 135 |
{ |
| 136 |
\tl_new:N #1 |
| 137 |
\exp_args:Nx \ctex_gadd_ltxhook:nn { \cs_to_str:N #2 } {#1} |
| 138 |
} |
| 139 |
} |
| 140 |
{ |
| 141 |
\cs_new_protected:Npn \__ctex_provide_font_hook_aux:NNNN #1#2#3#4 |
| 142 |
{ |
| 143 |
\tl_new:N #1 |
| 144 |
\cs_if_exist:NTF #3 |
| 145 |
{ \tl_gput_right:Nn #3 {#1} } |
| 146 |
{ \ctex_parse_name:NN \tl_replace_once:Nnn #2 {#4} { #1#4 } } |
| 147 |
} |
| 148 |
} |
| 149 |
\ctex_provide_font_hook:NNN \rmfamily \@rmfamilyhook \selectfont |
| 150 |
\ctex_provide_font_hook:NNN \sffamily \@sffamilyhook \selectfont |
| 151 |
\ctex_provide_font_hook:NNN \ttfamily \@ttfamilyhook \selectfont |
| 152 |
\tl_if_exist:NF \CJKfamilydefault |
| 153 |
{ \tl_const:Nn \CJKfamilydefault { \CJKrmdefault } } |
| 154 |
\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { zhrm } } |
| 155 |
\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { zhsf } } |
| 156 |
\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { zhtt } } |
| 157 |
\tl_gput_right:Nn \CTEX@rmfamilyhook { \kanjifamily { \CJKrmdefault } } |
| 158 |
\tl_gput_right:Nn \CTEX@sffamilyhook { \kanjifamily { \CJKsfdefault } } |
| 159 |
\tl_gput_right:Nn \CTEX@ttfamilyhook { \kanjifamily { \CJKttdefault } } |
| 160 |
\tl_gset:Nn \kanjifamilydefault { \CJKfamilydefault } |
| 161 |
\normalfont |
| 162 |
\ctex_at_end_preamble:n { \ctex_update_default_family: } |
| 163 |
\cs_new_protected:Npn \ctex_update_default_family: |
| 164 |
{ |
| 165 |
\tl_if_eq:NNT \CJKfamilydefault \l__ctex_family_default_init_tl |
| 166 |
{ |
| 167 |
\group_begin: |
| 168 |
\cs_set_eq:NN \__ctex_family_default_wrap:n \exp_not:n |
| 169 |
\tl_gset:Nx \CJKfamilydefault |
| 170 |
{ |
| 171 |
\str_case:onF { \familydefault } |
| 172 |
{ |
| 173 |
{ \rmdefault } { \exp_not:N \CJKrmdefault } |
| 174 |
{ \sfdefault } { \exp_not:N \CJKsfdefault } |
| 175 |
{ \ttdefault } { \exp_not:N \CJKttdefault } |
| 176 |
} |
| 177 |
{ \CJKfamilydefault } |
| 178 |
} |
| 179 |
\group_end: |
| 180 |
} |
| 181 |
} |
| 182 |
\tl_new:N \l__ctex_family_default_init_tl |
| 183 |
\cs_new_eq:NN \__ctex_family_default_wrap:n \use:n |
| 184 |
\tl_set:Nx \l__ctex_family_default_init_tl |
| 185 |
{ |
| 186 |
\exp_not:N \__ctex_family_default_wrap:n |
| 187 |
{ \exp_not:o { \CJKfamilydefault } } |
| 188 |
} |
| 189 |
\tl_gset_eq:NN \CJKfamilydefault \l__ctex_family_default_init_tl |
| 190 |
\ctex_hypersetup:n |
| 191 |
{ |
| 192 |
driverfallback = dvipdfmx , |
| 193 |
pdfencoding = pdfdoc |
| 194 |
} |
| 195 |
\ctex_at_end_package:nn { hyperref } |
| 196 |
{ |
| 197 |
\ctex_at_shipout_first:n |
| 198 |
{ \special { pdf:tounicode~UTF8-UTF16 } } |
| 199 |
} |
| 200 |
\cs_new_protected:Npn \ctex_update_ccwd: |
| 201 |
{ \skip_set:Nn \ccwd { 1zw + \tex_kanjiskip:D } } |
| 202 |
\dim_new:N \ccwd |
| 203 |
\cs_new_protected:Npn \ctex_update_ccglue: |
| 204 |
{ \skip_set_eq:NN \tex_kanjiskip:D \l__ctex_ccglue_skip } |
| 205 |
\skip_new:N \l__ctex_ccglue_skip |
| 206 |
\prg_new_conditional:Npnn \ctex_if_ccglue_touched: { TF } |
| 207 |
{ |
| 208 |
\skip_if_eq:nnTF { \l__ctex_ccglue_skip } { \tex_kanjiskip:D } |
| 209 |
{ \prg_return_false: } { \prg_return_true: } |
| 210 |
} |
| 211 |
\cs_new_protected:Npn \ctex_update_em_unit: |
| 212 |
{ \dim_set:Nn \ccwd { 1zw } } |
| 213 |
\cs_new_protected:Npn \ctex_add_to_selectfont:n #1 |
| 214 |
{ |
| 215 |
\cs_set_protected:Npx \CTEX@selectfont@hook |
| 216 |
{ \exp_not:o { \CTEX@selectfont@hook #1 } } |
| 217 |
} |
| 218 |
\cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: |
| 219 |
\bool_if:NTF \c__ctex_everysel_loaded_bool |
| 220 |
{ |
| 221 |
\cs_if_free:NF \@EverySelectfont@Init |
| 222 |
{ |
| 223 |
\group_begin: |
| 224 |
\cs_set:Npn \__ctex_tmp:N #1 |
| 225 |
{ |
| 226 |
\tl_set:Nn \l__ctex_tmp_tl {#1} |
| 227 |
\cs_new_eq:NN \CTEX@selectfont@save #1 |
| 228 |
\cs_new_protected:Npn \__ctex_restore_selectfont: |
| 229 |
{ |
| 230 |
\cs_if_free:NF \scr@new@selectfont |
| 231 |
{ |
| 232 |
\cs_if_free:NF \par@update |
| 233 |
{ |
| 234 |
\tl_put_right:Nn \@EverySelectfont@Init |
| 235 |
{ \tl_put_right:Nn #1 { \par@update } } |
| 236 |
} |
| 237 |
\cs_set_eq:NN \scr@new@selectfont #1 |
| 238 |
\cs_set_eq:NN \CTEX@selectfont@save \scr@selectfont |
| 239 |
} |
| 240 |
\tl_put_left:Nn \@EverySelectfont@Init |
| 241 |
{ \cs_set_eq:NN #1 \CTEX@selectfont@save } |
| 242 |
\cs_undefine:N \__ctex_restore_selectfont: |
| 243 |
} |
| 244 |
} |
| 245 |
\ctex_parse_name:NN \__ctex_tmp:N \selectfont |
| 246 |
\exp_last_unbraced:NNo \group_end: |
| 247 |
\ctex_patch_cmd_once:NnnnTF { \l__ctex_tmp_tl } |
| 248 |
{ \ExplSyntaxOff } |
| 249 |
{ \size@update } |
| 250 |
{ \CTEX@selectfont@hook \size@update } |
| 251 |
{ \__ctex_restore_selectfont: } |
| 252 |
{ \ctex_patch_failure:N \selectfont } |
| 253 |
} |
| 254 |
\cs_new_protected:Npn \ctex_gadd_selectfont_hook:n |
| 255 |
{ \EverySelectfont } |
| 256 |
} |
| 257 |
{ |
| 258 |
\cs_new_protected:Npn \ctex_gadd_selectfont_hook:n |
| 259 |
{ \ctex_gadd_ltxhook:nn { selectfont } } |
| 260 |
} |
| 261 |
\ctex_gadd_selectfont_hook:n { \CTEX@selectfont@hook } |
| 262 |
\cs_new_protected:Npn \ctex_update_xkanjiskip: |
| 263 |
{ |
| 264 |
\skip_if_eq:nnT |
| 265 |
{ \tex_xkanjiskip:D } { \l__ctex_xkanjiskip_skip } |
| 266 |
{ |
| 267 |
\skip_set:Nn \l__ctex_xkanjiskip_skip { \l__ctex_xkanjiskip_tl } |
| 268 |
\skip_set_eq:NN \tex_xkanjiskip:D \l__ctex_xkanjiskip_skip |
| 269 |
} |
| 270 |
} |
| 271 |
\tl_new:N \l__ctex_xkanjiskip_tl |
| 272 |
\tl_set:Nn \l__ctex_xkanjiskip_tl |
| 273 |
{ .25zw plus 1pt minus 1pt } |
| 274 |
\skip_new:N \l__ctex_xkanjiskip_skip |
| 275 |
\skip_set:Nn \l__ctex_xkanjiskip_skip |
| 276 |
{ \tex_xkanjiskip:D } |
| 277 |
\ctex_add_to_selectfont:n { \ctex_update_xkanjiskip: } |
| 278 |
\ctex_define:n |
| 279 |
{ |
| 280 |
space .code:n = |
| 281 |
{ \msg_warning:nn { ctex } { invalid-option } } |
| 282 |
} |
| 283 |
\ctex_define:n |
| 284 |
{ |
| 285 |
punct .code:n = |
| 286 |
{ |
| 287 |
\tl_set:Nx \l__ctex_punct_tl {#1} |
| 288 |
\msg_warning:nn { ctex } { invalid-option } |
| 289 |
} , |
| 290 |
punct .default:n = { quanjiao } , |
| 291 |
} |
| 292 |
%% |
| 293 |
%% |
| 294 |
%% End of file `ctex-engine-uptex.def'. |