| 1 |
%% |
| 2 |
%% This is file `ctex-engine-luatex.def', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% ctex.dtx (with options: `luatex') |
| 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 |
{LuaLaTeX adapter (CTEX)} |
| 29 |
\ProvidesExplFile{ctex-engine-luatex.def} |
| 30 |
{\ExplFileDate}{2.5.10}{\ExplFileDescription} |
| 31 |
\msg_new:nnn { ctex } { luatexja-loaded } |
| 32 |
{ |
| 33 |
Package~`luatexja'~can~not~be~loaded~before~`ctex'.\\ |
| 34 |
Loading~file~`#1'~will~abort! |
| 35 |
} |
| 36 |
\@ifpackageloaded { luatexja } |
| 37 |
{ \msg_critical:nnx { ctex } { luatexja-loaded } { \g_file_curr_name_str } } |
| 38 |
{ |
| 39 |
\ctex_at_begin_package:nn { luatexja } |
| 40 |
{ \msg_redirect_name:nnn { ctexhook } { disable-package } { info } } |
| 41 |
\ctex_at_end_package:nn { luatexja } |
| 42 |
{ \msg_redirect_name:nnn { ctexhook } { disable-package } { } } |
| 43 |
\ctex_disable_package:n { ltj-latex } |
| 44 |
} |
| 45 |
\RequirePackage { luatexja } |
| 46 |
\@ifpackagelater { luatexja } { 2020/04/12 } { } |
| 47 |
{ \msg_error:nnn { ctex } { package-too-old } { luatexja } } |
| 48 |
\RequirePackage { fontspec } |
| 49 |
\@ifpackagelater { fontspec } { 2020/02/21 } { } |
| 50 |
{ \msg_error:nnn { ctex } { package-too-old } { fontspec } } |
| 51 |
\ctex_at_end:n { \char_set_catcode_comment:n { \ltjlineendcomment } } |
| 52 |
\ExplSyntaxOff |
| 53 |
\ltjdefcharrange{1}{"80-"36F, "1E00-"1EFF} |
| 54 |
\ltjdefcharrange{2}{"370-"4FF, "1F00-"1FFF} |
| 55 |
\ltjdefcharrange{3}{% |
| 56 |
"2000-"243F, "2460-"24FF, "2500-"27BF, "2900-"29FF, "2B00-"2BFF} |
| 57 |
\ltjdefcharrange{4}{% |
| 58 |
"500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF, |
| 59 |
"2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A95F, "A980-"ABFF, "E000-"F8FF, |
| 60 |
"FB00-"FE0F, "FE20-"FE2F, "FE70-"FEFF, "10000-"1AFFF, "1B170-"1F0FF, |
| 61 |
"1F300-"1FFFF, "2000-"206F} |
| 62 |
\ltjdefcharrange{5}{"D800-"DFFF, "E0000-"E00FF, "E01F0-"10FFFF} |
| 63 |
\ltjdefcharrange{6}{% |
| 64 |
"2E80-"2EFF, "3000-"30FF, "3190-"319F, "31F0-"4DBF, |
| 65 |
"4E00-"9FFF, "F900-"FAFF, "FE10-"FE1F, "FE30-"FE6F, "FF00-"FFEF, |
| 66 |
"1B000-"1B16F, "1F100-"1F2FF, "20000-"3FFFF, "E0100-"E01EF} |
| 67 |
\ltjdefcharrange{7}{% |
| 68 |
"1100-"11FF, "2F00-"2FFF, "3100-"318F, "31A0-"31EF, "A000-"A4CF, |
| 69 |
"A960-"A97F, "AC00-"D7FF} |
| 70 |
\ltjdefcharrange{8}{"A7, "A8, "B0, "B1, "B4, "B6, "D7, "F7} |
| 71 |
\ltjdefcharrange{9}{% |
| 72 |
"00B7, "2018, "2019, "201C, "201D, "2013, "2014, "2025, "2026, "2027, "2E3A} |
| 73 |
\ltjsetparameter{jacharrange={-1, -2, -3, -4, -5, +6, +7, -8, +9}} |
| 74 |
\directlua{for x=128,255 do luatexja.math.is_math_letters[x] = true end} |
| 75 |
\@ifpackagelater{luatexja}{2020/08/08} |
| 76 |
{ \ltjsetparameter { autospacing, autoxspacing, differentjfm = paverage } } |
| 77 |
{ |
| 78 |
\directlua{ |
| 79 |
local s = kpse.find_file('ltj-kinsoku.lua', 'tex') |
| 80 |
luatexja.stack.charprop_stack_table[0] = s and dofile(s) or {} |
| 81 |
} |
| 82 |
\ltjsetparameter{kanjiskip=\z@ plus .4pt minus .5pt, |
| 83 |
xkanjiskip=.25\zw plus 1pt minus 1pt, |
| 84 |
autospacing, autoxspacing, jacharrange={-1}, |
| 85 |
yalbaselineshift=\z@, yjabaselineshift=\z@, |
| 86 |
jcharwidowpenalty=500, differentjfm=paverage |
| 87 |
} |
| 88 |
} |
| 89 |
\ExplSyntaxOn |
| 90 |
\cs_new_protected:Npn \CTEX@alchar #1 |
| 91 |
{ \CTEX@beginallalchar #1 \CTEX@endallalchar } |
| 92 |
\cs_new_protected:Npn \CTEX@beginallalchar |
| 93 |
{ |
| 94 |
\group_begin: |
| 95 |
\ctex_ltj_zero_globaldefs: |
| 96 |
\ltj@allalchar |
| 97 |
} |
| 98 |
\cs_new_protected:Npn \CTEX@endallalchar |
| 99 |
{ \group_end: } |
| 100 |
\cs_new_protected:Npn \CTEX@chardef@text@cmd #1 |
| 101 |
{ |
| 102 |
\cs_set_eq:NN \@ifdefinable \@@ifdefinable |
| 103 |
\tl_set:Nn \l__ctex_ltj_cmd_tl {#1} |
| 104 |
\tex_afterassignment:D \__ctex_ltj_chardef_text_cmd: |
| 105 |
\tex_chardef:D #1 |
| 106 |
} |
| 107 |
\tl_new:N \l__ctex_ltj_cmd_tl |
| 108 |
\cs_new_protected:Npn \__ctex_ltj_chardef_text_cmd: |
| 109 |
{ \exp_after:wN \__ctex_ltj_chardef_text_cmd_aux:N \l__ctex_ltj_cmd_tl } |
| 110 |
\cs_new_protected:Npn \__ctex_ltj_chardef_text_cmd_aux:N #1 |
| 111 |
{ |
| 112 |
\int_compare:nNnF {#1} < { "80 } |
| 113 |
{ \cs_set_protected:Npx #1 { \CTEX@alchar { \tex_Uchar:D #1 } } } |
| 114 |
} |
| 115 |
\cs_new_protected:Npn \CTEX@text@composite@x #1#2 |
| 116 |
{ |
| 117 |
\CTEX@beginallalchar |
| 118 |
\cs_if_exist_use:NF #1 {#2} |
| 119 |
\CTEX@endallalchar |
| 120 |
} |
| 121 |
\cs_new_protected:Npx \CTEX@add@unicode@accent #1#2 |
| 122 |
{ |
| 123 |
\CTEX@beginallalchar |
| 124 |
\exp_not:N \tl_if_blank:nTF {#2} { \tex_Uchar:D "A0 ~ } {#2} |
| 125 |
\exp_not:N \tex_Uchar:D \tex_numexpr:D #1 \scan_stop: |
| 126 |
\CTEX@endallalchar |
| 127 |
} |
| 128 |
\cs_new_protected:Npn \CTEX@patch@text@cmd #1 |
| 129 |
{ |
| 130 |
\exp_args:NNc \__ctex_ltj_patch_text_cmd:NN #1 |
| 131 |
{ \UnicodeEncodingName \token_to_str:N #1 } |
| 132 |
} |
| 133 |
\cs_new_protected:Npn \__ctex_ltj_patch_text_cmd:NN #1#2 |
| 134 |
{ |
| 135 |
\cs_set_eq:NN \CTEX@textcmd #2 |
| 136 |
\ctex_preto_cmd:NnnTF \CTEX@textcmd |
| 137 |
{ \ExplSyntaxOff \makeatletter } |
| 138 |
{ \CTEX@beginallalchar } |
| 139 |
{ |
| 140 |
\ctex_appto_cmd:NnnTF \CTEX@textcmd |
| 141 |
{ \ExplSyntaxOff \makeatletter } |
| 142 |
{ \CTEX@endallalchar } |
| 143 |
{ \cs_set_eq:NN #2 \CTEX@textcmd } |
| 144 |
{ \ctex_patch_failure:N #1 } |
| 145 |
} |
| 146 |
{ \ctex_patch_failure:N #1 } |
| 147 |
} |
| 148 |
\cs_new_protected:Npn \CTEX@patch@tunec |
| 149 |
{ |
| 150 |
\cs_set_eq:NN \chardef@text@cmd \CTEX@chardef@text@cmd |
| 151 |
\ctex_file_input:n { tuenc.def } |
| 152 |
\cs_set_eq:NN \@text@composite@x \CTEX@text@composite@x |
| 153 |
\cs_set_eq:NN \add@unicode@accent \CTEX@add@unicode@accent |
| 154 |
\CTEX@patch@text@cmd \textasteriskcentered |
| 155 |
} |
| 156 |
\@ifpackageloaded { xunicode } |
| 157 |
{ } |
| 158 |
{ \CTEX@patch@tunec } |
| 159 |
\ctex_at_end_package:nn { xunicode } |
| 160 |
{ |
| 161 |
\RequirePackage { xunicode-addon } |
| 162 |
\AtBeginUTFCommand { \CTEX@beginallalchar } |
| 163 |
\AtEndUTFCommand { \CTEX@endallalchar } |
| 164 |
} |
| 165 |
\ctex_at_end_package:nn { listings } |
| 166 |
{ \RequirePackage { lltjp-listings } } |
| 167 |
\group_begin: |
| 168 |
\char_set_catcode_space:n { 32 } |
| 169 |
\lua_now:e |
| 170 |
{ |
| 171 |
ctex = ctex or { } |
| 172 |
local ctex = ctex |
| 173 |
local functions = lua.get_functions_table() |
| 174 |
local new_luafunction = luatexbase.new_luafunction |
| 175 |
local create, set_lua = token.create, token.set_lua |
| 176 |
local lua_cmds = { |
| 177 |
lua_call = true , |
| 178 |
lua_expandable_call = true , |
| 179 |
} |
| 180 |
local newluacmd = function (name, func, ...) |
| 181 |
local tok = create(name) |
| 182 |
local id = lua_cmds[tok.cmdname] and tok.index |
| 183 |
local id = id or new_luafunction(name) |
| 184 |
set_lua(name, id, ...) |
| 185 |
functions[id] = func |
| 186 |
end |
| 187 |
ctex.newluacmd = newluacmd |
| 188 |
local ltjfont = luatexja.jfont |
| 189 |
local getattribute = tex.getattribute |
| 190 |
local tex_set, sprint = tex.set, tex.sprint |
| 191 |
local scan_int, scan_arg = token.scan_int, token.scan_argument |
| 192 |
newluacmd("ctex_ltj_add_kyenc:n", ltjfont.add_kyenc_list, "global", "protected") |
| 193 |
newluacmd("ctex_ltj_is_kenc:n", ltjfont.is_kenc, "global") |
| 194 |
newluacmd("ctex_ltj_patch_external_font:n", function () |
| 195 |
local s = scan_arg() |
| 196 |
local is_braced, is_quoted |
| 197 |
if s:sub(1,1) == '{' and s:sub(-1)=='}' then |
| 198 |
is_braced = true; s = s:sub(2,-2) |
| 199 |
end |
| 200 |
if s:sub(1,1) == '"' and s:sub(-1) == '"' then |
| 201 |
is_quoted = true; s = s:sub(2,-2) |
| 202 |
end |
| 203 |
s = s .. ltjfont.print_aftl_address() |
| 204 |
if is_braced then s = '{'..s..'}' |
| 205 |
elseif is_quoted then s = '"'..s..'"' |
| 206 |
end |
| 207 |
sprint(-2, s) |
| 208 |
end, "global") |
| 209 |
newluacmd("ctex_ltj_set_alt_font:nnnn", function () |
| 210 |
local b = tonumber(scan_arg()) |
| 211 |
local e = tonumber(scan_arg()) |
| 212 |
local alt = scan_arg() |
| 213 |
local base = scan_arg() |
| 214 |
ltjfont.set_alt_font_latex(b, e, alt, base) |
| 215 |
end, "global", "protected") |
| 216 |
newluacmd("ctex_ltj_clear_alt_font:n", function () |
| 217 |
local base = scan_arg() |
| 218 |
ltjfont.clear_alt_font_latex(base) |
| 219 |
end, "global", "protected") |
| 220 |
newluacmd("ctex_ltj_pickup_alt_font:nn", function () |
| 221 |
local base = scan_arg() |
| 222 |
local size = scan_arg() |
| 223 |
ltjfont.output_alt_font_cmd("y", base) |
| 224 |
ltjfont.pickup_alt_font_a(size) |
| 225 |
end, "global", "protected") |
| 226 |
newluacmd("__ctex_ltj_pickup_alt_font:Nn", function () |
| 227 |
local num = scan_int() |
| 228 |
local base = scan_arg() |
| 229 |
ltjfont.pickup_alt_font_b(num, base) |
| 230 |
end, "global", "protected") |
| 231 |
newluacmd("__ctex_ltj_if_alt_set:nT", ltjfont.does_alt_set, "global") |
| 232 |
newluacmd("ctex_ltj_zero_globaldefs:", function () |
| 233 |
tex_set("globaldefs", 0) |
| 234 |
end, "global", "protected") |
| 235 |
} |
| 236 |
\group_end: |
| 237 |
\cs_new_protected:Npn \ctex_ltj_select_font: |
| 238 |
{ |
| 239 |
\group_begin: \exp_args:NNc \group_end: |
| 240 |
\cs_if_exist_use:NF { \l__ctex_ltj_current_font_tl } |
| 241 |
{ \tl_if_empty:NF \CJK@family { \__ctex_ltj_select_font_aux: } } |
| 242 |
} |
| 243 |
\tl_new:N \CJK@family |
| 244 |
\tl_new:N \l__ctex_ltj_current_font_tl |
| 245 |
\tl_set:Nn \l__ctex_ltj_current_font_tl |
| 246 |
{ \CJK@encoding / \CJK@family / \f@series / \f@shape / \f@size } |
| 247 |
\cs_new_protected:Npn \__ctex_ltj_select_font_aux: |
| 248 |
{ |
| 249 |
\group_begin: |
| 250 |
\tl_set_eq:NN \f@encoding \CJK@encoding |
| 251 |
\tl_set_eq:NN \f@family \CJK@family |
| 252 |
\cs_set_eq:NN \pickup@font \ctex_ltj_pickup_font: |
| 253 |
\__ctex_ltj_push_fontname:n { \curr@fontshape / \f@size } |
| 254 |
\ctex_ltj_pickup_font: |
| 255 |
\group_end: |
| 256 |
\font@name |
| 257 |
\__ctex_ltj_pop_fontname: |
| 258 |
\cs_if_exist:cF { \l__ctex_ltj_current_font_tl } |
| 259 |
{ \__ctex_ltj_select_font_aux: } |
| 260 |
} |
| 261 |
\cs_new_protected:Npn \__ctex_ltj_push_fontname:n #1 |
| 262 |
{ |
| 263 |
\seq_gpush:No \g__ctex_ltj_fontname_seq { \font@name } |
| 264 |
\tl_gset:Nx \font@name { \exp_not:c {#1} } |
| 265 |
} |
| 266 |
\cs_new_protected:Npn \__ctex_ltj_pop_fontname: |
| 267 |
{ |
| 268 |
\seq_gpop:NNT \g__ctex_ltj_fontname_seq \l__ctex_ltj_tmp_tl |
| 269 |
{ \tl_gset_eq:NN \font@name \l__ctex_ltj_tmp_tl } |
| 270 |
} |
| 271 |
\seq_new:N \g__ctex_ltj_fontname_seq |
| 272 |
\cs_new_protected:Npn \ctex_ltj_pickup_font: |
| 273 |
{ |
| 274 |
\exp_after:wN \cs_if_exist:NF \font@name |
| 275 |
{ |
| 276 |
\group_begin: |
| 277 |
\cs_set_eq:NN \extract@font \ctex_ltj_extract_font: |
| 278 |
\cs_set_eq:NN \do@subst@correction \ctex_ltj_subst_font: |
| 279 |
\define@newfont |
| 280 |
\group_end: |
| 281 |
} |
| 282 |
} |
| 283 |
\cs_new_eq:NN \pickup@jfont \ctex_ltj_pickup_font: |
| 284 |
\cs_new_protected_nopar:Npn \ctex_ltj_extract_font: |
| 285 |
{ |
| 286 |
\get@external@font |
| 287 |
\ctex_ltj_if_alternate_shape_exist:nT { \curr@fontshape } |
| 288 |
{ |
| 289 |
\tl_set:Nx \external@font |
| 290 |
{ \exp_after:wN \__ctex_ltj_patch_external_font:w \external@font } |
| 291 |
} |
| 292 |
\exp_after:wN \globaljfont \font@name \external@font \scan_stop: |
| 293 |
\font@name |
| 294 |
\ctex_ltj_use_jfont: |
| 295 |
\use:c { \f@encoding + \f@family } |
| 296 |
\use:c { \curr@fontshape } |
| 297 |
} |
| 298 |
\cs_new_protected_nopar:Npn \ctex_ltj_use_jfont: |
| 299 |
{ \tex_setfontid:D \ltj@curjfnt } |
| 300 |
\cs_new_protected_nopar:Npn \ctex_ltj_subst_font: |
| 301 |
{ |
| 302 |
\ctex_ltj_if_alternate_shape_exist:nF { \curr@fontshape } |
| 303 |
{ |
| 304 |
\group_begin: |
| 305 |
\tl_set_eq:NN \CJK@family \f@family |
| 306 |
\cs_if_exist:cF { \l__ctex_ltj_current_font_tl } |
| 307 |
{ |
| 308 |
\cs_gset_protected_nopar:Npx \subst@correction |
| 309 |
{ |
| 310 |
\cs_new_eq:NN |
| 311 |
\exp_not:c { \l__ctex_ltj_current_font_tl } |
| 312 |
\font@name |
| 313 |
} |
| 314 |
\group_insert_after:N \group_insert_after:N |
| 315 |
\group_insert_after:N \subst@correction |
| 316 |
} |
| 317 |
\group_end: |
| 318 |
} |
| 319 |
} |
| 320 |
\prg_new_conditional:Npnn \ctex_ltj_if_alternate_shape_exist:n #1 { T , F , TF } |
| 321 |
{ |
| 322 |
\__ctex_ltj_if_alt_set:nT {#1} { \prg_return_true: \use_none:n } |
| 323 |
\prg_return_false: |
| 324 |
} |
| 325 |
\cs_new:Npn \__ctex_ltj_patch_external_font:w #1 ~ at |
| 326 |
{ \ctex_ltj_patch_external_font:n {#1} ~ at } |
| 327 |
\cs_new_protected:Npn \ctex_ltj_select_alternate_font: |
| 328 |
{ |
| 329 |
\ctex_ltj_if_alternate_shape_exist:nT { \l__ctex_ltj_current_shape_tl } |
| 330 |
{ |
| 331 |
\ctex_ltj_pickup_alt_font:nn |
| 332 |
{ \l__ctex_ltj_current_shape_tl } { \f@size } |
| 333 |
} |
| 334 |
} |
| 335 |
\tl_new:N \l__ctex_ltj_current_shape_tl |
| 336 |
\tl_set:Nn \l__ctex_ltj_current_shape_tl |
| 337 |
{ \CJK@encoding / \CJK@family / \f@series / \f@shape } |
| 338 |
\cs_new_protected:Npn \ltj@pickup@altfont@auxy #1 |
| 339 |
{ |
| 340 |
\cs_if_exist:cF { #1/\f@size } |
| 341 |
{ |
| 342 |
\group_begin: |
| 343 |
\use:e { \exp_not:N \split@name #1 / \f@size } \@nil |
| 344 |
\__ctex_ltj_push_fontname:n { \curr@fontshape / \f@size } |
| 345 |
\ctex_ltj_pickup_font: |
| 346 |
\group_end: |
| 347 |
\__ctex_ltj_pop_fontname: |
| 348 |
} |
| 349 |
} |
| 350 |
\cs_new_protected:Npn \ltj@pickup@altfont@copy #1#2 |
| 351 |
{ |
| 352 |
\ltj@@getjfontnumber #1 |
| 353 |
\__ctex_ltj_pickup_alt_font:Nn \ltj@tempcntc {#2} |
| 354 |
} |
| 355 |
\cs_new:Npn \ctex_ltj_if_jfont:nTF #1 |
| 356 |
{ |
| 357 |
\ctex_ltj_is_kenc:n { \__ctex_ltj_ltj_if_jfont:w #1 / \q_stop } |
| 358 |
\legacy_if:nTF { in@ } |
| 359 |
} |
| 360 |
\cs_new:Npn \__ctex_ltj_ltj_if_jfont:w #1 / #2 \q_stop |
| 361 |
{#1} |
| 362 |
\cs_new:Npn \ctex_ltj_if_jfont_math:NTF #1 |
| 363 |
{ \exp_after:wN \__ctex_ltj_if_jfont_math:w \token_to_str:N #1 \q_stop } |
| 364 |
\group_begin: |
| 365 |
\char_set_catcode_other:N M |
| 366 |
\cs_new:Npn \__ctex_ltj_if_jfont_math:w #1 M #2#3 \q_stop |
| 367 |
{ \ctex_ltj_if_jfont:nTF {#3} } |
| 368 |
\group_end: |
| 369 |
\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts:nN #1#2 |
| 370 |
{ |
| 371 |
\exp_args:No \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 } |
| 372 |
{ \ctex_ltj_get_and_define_fonts_ja:nN } |
| 373 |
{ \ctex_ltj_get_and_define_fonts_al:nN } |
| 374 |
{#1} #2 |
| 375 |
} |
| 376 |
\cs_new_eq:NN \ctex_ltj_get_and_define_fonts_al:nN \getanddefine@fonts |
| 377 |
\cs_set_eq:NN \getanddefine@fonts \ctex_ltj_get_and_define_fonts:nN |
| 378 |
\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2 |
| 379 |
{ |
| 380 |
\tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \tf@size } } |
| 381 |
\ctex_ltj_pickup_font: \tl_set_eq:NN \textfont@name \font@name |
| 382 |
\tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \sf@size } } |
| 383 |
\ctex_ltj_pickup_font: \tl_set_eq:NN \scriptfont@name \font@name |
| 384 |
\tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \ssf@size } } |
| 385 |
\ctex_ltj_pickup_font: |
| 386 |
\tl_put_right:Nx \math@fonts |
| 387 |
{ |
| 388 |
\ltj@setpar@global |
| 389 |
\ltj@@set@stackfont #1 , \textfont@name \c_colon_str { MJT } |
| 390 |
\ltj@@set@stackfont #1 , \scriptfont@name \c_colon_str { MJS } |
| 391 |
\ltj@@set@stackfont #1 , \font@name \c_colon_str { MJSS } |
| 392 |
} |
| 393 |
} |
| 394 |
\cs_new_protected:Npn \ctex_ltj_use_math_group:Nn #1#2 |
| 395 |
{ |
| 396 |
\mode_if_math:T |
| 397 |
{ |
| 398 |
\math@bgroup |
| 399 |
\cs_if_eq:cNF { M@ \f@encoding } #1 {#1} |
| 400 |
\ctex_ltj_math_group_hook: |
| 401 |
\ctex_ltj_if_jfont_math:NTF #1 |
| 402 |
{ \jfam } { \mathgroup } #2 \scan_stop: |
| 403 |
\math@egroup |
| 404 |
} |
| 405 |
} |
| 406 |
\cs_new_eq:NN \ctex_ltj_math_group_hook: \prg_do_nothing: |
| 407 |
\cs_set_eq:NN \use@mathgroup \ctex_ltj_use_math_group:Nn |
| 408 |
\cs_new_protected:Npn \ctex_ltj_set_math_letter:NN #1#2 |
| 409 |
{ |
| 410 |
\group_begin: |
| 411 |
\cs_set_protected:Npn #1 ##1##2##3 |
| 412 |
{ \ltjsetmathletter { ##1 } } |
| 413 |
#2 |
| 414 |
\group_end: |
| 415 |
} |
| 416 |
\ctex_at_end_package:nn { unicode-math } |
| 417 |
{ |
| 418 |
\cs_if_exist:NTF \um_input_math_symbol_table: |
| 419 |
{ |
| 420 |
\ctex_ltj_set_math_letter:NN |
| 421 |
\um_sym:nnn |
| 422 |
\um_input_math_symbol_table: |
| 423 |
} |
| 424 |
{ |
| 425 |
\cs_set_eq:NN \use@mathgroup \ctex_ltj_use_math_group:Nn |
| 426 |
\cs_set_protected:Npn \ctex_ltj_math_group_hook: |
| 427 |
{ \__um_switchto_literal: } |
| 428 |
\ctex_ltj_set_math_letter:NN |
| 429 |
\__um_sym:nnn |
| 430 |
\__um_input_math_symbol_table: |
| 431 |
} |
| 432 |
} |
| 433 |
\cs_new_protected:Npn \ctex_set_jfm:n #1 |
| 434 |
{ |
| 435 |
\prop_get:NnNF \l__ctex_ltj_redirect_jfm_prop {#1} \l__ctex_ltj_jfm_tl |
| 436 |
{ \tl_set:Nn \l__ctex_ltj_jfm_tl {#1} } |
| 437 |
} |
| 438 |
\cs_generate_variant:Nn \ctex_set_jfm:n { o } |
| 439 |
\prop_new:N \l__ctex_ltj_redirect_jfm_prop |
| 440 |
\prop_set_from_keyval:Nn \l__ctex_ltj_redirect_jfm_prop |
| 441 |
{ |
| 442 |
plain = mono , |
| 443 |
quanjiao = zh_CN / quanjiao , |
| 444 |
banjiao = zh_CN / banjiao , |
| 445 |
kaiming = zh_CN / kaiming |
| 446 |
} |
| 447 |
\keys_define:nn { ctex_ltj / fontspec } |
| 448 |
{ |
| 449 |
JFM .code:n = \ctex_set_jfm:n {#1} , |
| 450 |
JFM .value_required:n = true |
| 451 |
} |
| 452 |
\tl_new:N \l__ctex_ltj_jfm_tl |
| 453 |
\ctex_set_jfm:o { \l__ctex_punct_tl } |
| 454 |
\tl_const:Nn \CJK@encoding { LTJY3 } |
| 455 |
\DeclareFontEncoding { \CJK@encoding } { } { } |
| 456 |
\use:e |
| 457 |
{ |
| 458 |
\exp_not:N \DeclareFontSubstitution |
| 459 |
{ \CJK@encoding } { song } { \mddefault } { \shapedefault } |
| 460 |
} |
| 461 |
\ctex_ltj_add_kyenc:n { \CJK@encoding } |
| 462 |
\DeclareFontFamily { \CJK@encoding } { song } { } |
| 463 |
\DeclareFontShape { \CJK@encoding } { song } { \mddefault } { \shapedefault } |
| 464 |
{ <-> psft:SimSun:cid=Adobe-GB1-5;jfm=\l__ctex_ltj_jfm_tl } { } |
| 465 |
\DeclareFontShape { \CJK@encoding } { song } { \bfdefault } { \shapedefault } |
| 466 |
{ <-> psft:SimHei:cid=Adobe-GB1-5;jfm=\l__ctex_ltj_jfm_tl } { } |
| 467 |
\tl_const:Nn \c__ctex_ltj_math_tl { CJKmath } |
| 468 |
\DeclareSymbolFont { \c__ctex_ltj_math_tl } |
| 469 |
{ \CJK@encoding } { song } { \mddefault } { \shapedefault } |
| 470 |
\SetSymbolFont { \c__ctex_ltj_math_tl } { bold } |
| 471 |
{ \CJK@encoding } { song } { \bfdefault } { \shapedefault } |
| 472 |
\int_const:Nn \c__ctex_ltj_math_fam_int { \use:c { sym \c__ctex_ltj_math_tl } } |
| 473 |
\jfam \c__ctex_ltj_math_fam_int |
| 474 |
\newfontfeature { CID } { cid = #1 } |
| 475 |
\newfontfeature { JFM } { jfm = #1 } |
| 476 |
\newfontfeature { JFM-var } { jfmvar = #1 } |
| 477 |
\keys_define:nn { fontspec-preparse-external } |
| 478 |
{ |
| 479 |
NoEmbed .code:n = |
| 480 |
{ \cs_set_eq:NN \__fontspec_fontname_wrap:n \__ctex_ltj_noembed_wrap:n } |
| 481 |
} |
| 482 |
\cs_new:Npn \__ctex_ltj_noembed_wrap:n #1 { psft: #1 } |
| 483 |
\cs_new_protected:Npn \ctex_ltj_set_family:nnn #1#2#3 |
| 484 |
{ |
| 485 |
\group_begin: |
| 486 |
\clist_clear:N \l__ctex_ltj_char_range_clist |
| 487 |
\prop_clear:N \l__ctex_ltj_alternate_prop |
| 488 |
\tl_set:Nn \l__ctex_ltj_base_CJKfamily_tl {#1} |
| 489 |
\keys_set_known:nnN { ctex_ltj / fontspec } {#2} \l__ctex_ltj_tmp_tl |
| 490 |
\clist_set:No \l__ctex_ltj_font_options_clist { \l__ctex_ltj_tmp_tl } |
| 491 |
\ctex_ltj_set_alternate_family:nnF {#1} {#3} |
| 492 |
{ |
| 493 |
\prop_gput:Nnn \g__ctex_ltj_family_font_name_prop {#1} {#3} |
| 494 |
\prop_gput:Nno \g__ctex_ltj_family_font_options_prop |
| 495 |
{#1} { \l__ctex_ltj_font_options_clist } |
| 496 |
\__ctex_ltj_update_family_uid:N \l__ctex_ltj_font_options_clist |
| 497 |
\__ctex_ltj_use_global_options:N \l__ctex_ltj_font_options_clist |
| 498 |
\__ctex_ltj_gset_family_cs:nn {#1} {#3} |
| 499 |
} |
| 500 |
\group_end: |
| 501 |
} |
| 502 |
\tl_new:N \l__ctex_ltj_base_CJKfamily_tl |
| 503 |
\clist_new:N \l__ctex_ltj_font_options_clist |
| 504 |
\cs_new_protected:Npn \__ctex_ltj_use_global_options:N #1 |
| 505 |
{ |
| 506 |
\clist_concat:NNN #1 \g__ctex_ltj_default_features_clist #1 |
| 507 |
\clist_put_left:Nx #1 |
| 508 |
{ NFSSEncoding = \CJK@encoding , JFM = \l__ctex_ltj_jfm_tl } |
| 509 |
} |
| 510 |
\prop_new:N \g__ctex_ltj_family_name_prop |
| 511 |
\prop_new:N \g__ctex_ltj_family_font_name_prop |
| 512 |
\prop_new:N \g__ctex_ltj_family_font_options_prop |
| 513 |
\cs_new_protected:Npn \__ctex_ltj_check_family:n #1 |
| 514 |
{ |
| 515 |
\prop_gpop:NnNT \g__ctex_ltj_family_font_name_prop {#1} \l__ctex_ltj_tmp_tl |
| 516 |
{ |
| 517 |
\cs_undefine:c { \__ctex_ltj_family_csname:n {#1} } |
| 518 |
\cs_undefine:c { \__ctex_ltj_alternate_cs:n {#1} } |
| 519 |
\prop_gpop:NnNT \g__ctex_ltj_family_name_prop {#1} \l__ctex_ltj_base_family_tl |
| 520 |
{ |
| 521 |
\use:c { \__ctex_ltj_alternate_cs:n { clear / #1 } } |
| 522 |
\cs_undefine:c { \__ctex_ltj_alternate_cs:n { clear / #1 } } |
| 523 |
\cs_undefine:c { \__ctex_ltj_alternate_cs:n { reset / #1 } } |
| 524 |
\prop_gremove:Nn \g__ctex_ltj_reset_alternate_prop {#1} |
| 525 |
} |
| 526 |
\msg_warning:nnxx { ctex } { redefine-family } {#1} { \l__ctex_ltj_tmp_tl } |
| 527 |
} |
| 528 |
} |
| 529 |
\tl_new:N \l__ctex_ltj_tmp_tl |
| 530 |
\msg_new:nnn { ctex } { redefine-family } |
| 531 |
{ Redefining~CJKfamily~`\__ctex_ltj_msg_family_map:n {#1}'~(#2). } |
| 532 |
\cs_new_protected:Npn \__ctex_ltj_gset_family_cs:nn #1#2 |
| 533 |
{ |
| 534 |
\cs_gset_protected:cpx { \__ctex_ltj_family_csname:n {#1} } |
| 535 |
{ |
| 536 |
\group_begin: |
| 537 |
\exp_not:n { \cs_set_eq:NN \CJKfamily \use_none:n } |
| 538 |
\exp_not:n { \fontspec_gset_family:Nnn \g__ctex_ltj_fontspec_family_tl } |
| 539 |
{ \exp_not:o { \l__ctex_ltj_font_options_clist } } {#2} |
| 540 |
\prop_gput:Nno \exp_not:N \g__ctex_ltj_family_name_prop {#1} |
| 541 |
{ \exp_not:N \g__ctex_ltj_fontspec_family_tl } |
| 542 |
\__ctex_ltj_set_alternate_family:n {#1} |
| 543 |
\group_end: |
| 544 |
} |
| 545 |
} |
| 546 |
\tl_new:N \l__ctex_ltj_base_family_tl |
| 547 |
\tl_new:N \g__ctex_ltj_fontspec_family_tl |
| 548 |
\cs_new:Npn \__ctex_ltj_family_csname:n #1 { ctex_ltj/family/#1 } |
| 549 |
\cs_new_protected:Npn \__ctex_ltj_set_alternate_family:n #1 |
| 550 |
{ |
| 551 |
\tl_set:Nn \l__ctex_ltj_base_CJKfamily_tl {#1} |
| 552 |
\tl_set_eq:NN \l__ctex_ltj_base_family_tl \g__ctex_ltj_fontspec_family_tl |
| 553 |
\cs_if_exist_use:c { \__ctex_ltj_alternate_cs:n { reset / #1 } } |
| 554 |
\cs_if_exist_use:c { \__ctex_ltj_alternate_cs:n {#1} } |
| 555 |
} |
| 556 |
\cs_new:Npn \__ctex_ltj_alternate_cs:n #1 { ctex_ltj/alternate_family/#1 } |
| 557 |
\NewDocumentCommand \CJKfamily { m } |
| 558 |
{ \ctex_ltj_switch_family:x {#1} \tex_ignorespaces:D } |
| 559 |
\cs_new_protected:Npn \ctex_ltj_switch_family:n #1 |
| 560 |
{ |
| 561 |
\ctex_ltj_family_if_exist:nNTF {#1} \CJK@family |
| 562 |
{ |
| 563 |
\tl_set:Nn \l_ctex_ltj_family_tl {#1} |
| 564 |
\selectfont |
| 565 |
} |
| 566 |
{ \__ctex_ltj_family_unknown_warning:n {#1} } |
| 567 |
} |
| 568 |
\tl_new:N \l_ctex_ltj_family_tl |
| 569 |
\cs_generate_variant:Nn \ctex_ltj_switch_family:n { x } |
| 570 |
\prg_new_protected_conditional:Npnn \ctex_ltj_family_if_exist:nN #1#2 { T , F , TF } |
| 571 |
{ |
| 572 |
\prop_get:NnNTF \g__ctex_ltj_family_name_prop {#1} #2 |
| 573 |
{ \prg_return_true: } |
| 574 |
{ |
| 575 |
\cs_if_exist_use:cTF { \__ctex_ltj_family_csname:n {#1} } |
| 576 |
{ |
| 577 |
\tl_set_eq:NN #2 \g__ctex_ltj_fontspec_family_tl |
| 578 |
\prg_return_true: |
| 579 |
} |
| 580 |
{ \prg_return_false: } |
| 581 |
} |
| 582 |
} |
| 583 |
\prg_generate_conditional_variant:Nnn \ctex_ltj_family_if_exist:nN { x } { T , F , TF } |
| 584 |
\cs_new_protected:Npn \__ctex_ltj_family_unknown_warning:n #1 |
| 585 |
{ |
| 586 |
\prop_if_empty:NF \g__ctex_ltj_family_font_name_prop |
| 587 |
{ |
| 588 |
\seq_if_in:NnF \g__ctex_ltj_unknown_family_seq {#1} |
| 589 |
{ |
| 590 |
\seq_gput_right:Nn \g__ctex_ltj_unknown_family_seq {#1} |
| 591 |
\msg_warning:nnn { ctex } { family-unknown } {#1} |
| 592 |
} |
| 593 |
} |
| 594 |
} |
| 595 |
\seq_new:N \g__ctex_ltj_unknown_family_seq |
| 596 |
\msg_new:nnn { ctex } { family-unknown } |
| 597 |
{ |
| 598 |
Unknown~CJK~family~`\__ctex_ltj_msg_family_map:n {#1}'~is~being~ignored.\\ |
| 599 |
Try~to~use~`\__ctex_ltj_msg_def_family_map:n {#1}'~to~define~it. |
| 600 |
} |
| 601 |
\cs_new:Npn \__ctex_ltj_msg_def_family_map:n #1 |
| 602 |
{ |
| 603 |
\str_case_e:nnF {#1} |
| 604 |
{ |
| 605 |
\CJKrmdefault { \token_to_str:N \setCJKmainfont } |
| 606 |
\CJKsfdefault { \token_to_str:N \setCJKsansfont } |
| 607 |
\CJKttdefault { \token_to_str:N \setCJKmonofont } |
| 608 |
} |
| 609 |
{ \token_to_str:N \setCJKfamilyfont \{ #1 \} } |
| 610 |
[...]\{...\} |
| 611 |
} |
| 612 |
\cs_new:Npn \__ctex_ltj_msg_family_map:n #1 |
| 613 |
{ |
| 614 |
\str_case_e:nnF {#1} |
| 615 |
{ |
| 616 |
\CJKrmdefault { \token_to_str:N \CJKrmdefault } |
| 617 |
\CJKsfdefault { \token_to_str:N \CJKsfdefault } |
| 618 |
\CJKttdefault { \token_to_str:N \CJKttdefault } |
| 619 |
} |
| 620 |
{#1} |
| 621 |
} |
| 622 |
\cs_new_protected:Npn \ctex_ltj_fontspec:nn #1#2 |
| 623 |
{ |
| 624 |
\prop_get:NnNTF \g__ctex_ltj_fontspec_prop |
| 625 |
{ CJKfontspec/#1/#2/id } \l_ctex_ltj_family_tl |
| 626 |
{ \ctex_ltj_switch_family:x { \l_ctex_ltj_family_tl } } |
| 627 |
{ |
| 628 |
\int_gincr:N \g__ctex_ltj_family_int |
| 629 |
\__ctex_ltj_fontspec:enn |
| 630 |
{ CJKfontspec ( \int_use:N \g__ctex_ltj_family_int ) } |
| 631 |
{#1} {#2} |
| 632 |
} |
| 633 |
} |
| 634 |
\cs_new_protected:Npn \ctex_ltj_fontspec:ee #1#2 |
| 635 |
{ \use:e { \ctex_ltj_fontspec:nn {#1} {#2} } } |
| 636 |
\cs_new_protected:Npn \__ctex_ltj_fontspec:nnn #1#2#3 |
| 637 |
{ |
| 638 |
\bool_if:NT \l__ctex_ltj_add_alternate_bool |
| 639 |
{ |
| 640 |
\cs_if_free:cF |
| 641 |
{ \__ctex_ltj_alternate_cs:n { reset / \l_ctex_ltj_family_tl } } |
| 642 |
{ |
| 643 |
\cs_gset_eq:cc |
| 644 |
{ \__ctex_ltj_alternate_cs:n { reset / #1 } } |
| 645 |
{ \__ctex_ltj_alternate_cs:n { reset / \l_ctex_ltj_family_tl } } |
| 646 |
\cs_gset_eq:cc |
| 647 |
{ \__ctex_ltj_alternate_cs:n { clear / #1 } } |
| 648 |
{ \__ctex_ltj_alternate_cs:n { clear / \l_ctex_ltj_family_tl } } |
| 649 |
} |
| 650 |
\bool_set_false:N \l__ctex_ltj_add_alternate_bool |
| 651 |
} |
| 652 |
\prop_gput:Nnn \g__ctex_ltj_fontspec_prop { CJKfontspec/#2/#3/id } {#1} |
| 653 |
\ctex_ltj_set_family:nnn {#1} {#2} {#3} |
| 654 |
\ctex_ltj_switch_family:n {#1} |
| 655 |
} |
| 656 |
\cs_generate_variant:Nn \__ctex_ltj_fontspec:nnn { e } |
| 657 |
\prop_new:N \g__ctex_ltj_fontspec_prop |
| 658 |
\cs_new_protected:Npn \ctex_ltj_add_font_features:n #1 |
| 659 |
{ \ctex_ltj_add_font_features:xn { \l_ctex_ltj_family_tl } {#1} } |
| 660 |
\cs_new_protected:Npn \ctex_ltj_add_font_features:nn #1#2 |
| 661 |
{ |
| 662 |
\prop_get:NnNTF \g__ctex_ltj_family_font_name_prop |
| 663 |
{#1} \l__ctex_ltj_tmp_tl |
| 664 |
{ |
| 665 |
\prop_get:NnN \g__ctex_ltj_family_font_options_prop |
| 666 |
{#1} \l__ctex_ltj_font_options_clist |
| 667 |
\clist_put_right:Nn \l__ctex_ltj_font_options_clist {#2} |
| 668 |
\bool_set_true:N \l__ctex_ltj_add_alternate_bool |
| 669 |
\ctex_ltj_fontspec:ee |
| 670 |
{ \exp_not:o { \l__ctex_ltj_font_options_clist } } |
| 671 |
{ \exp_not:o { \l__ctex_ltj_tmp_tl } } |
| 672 |
} |
| 673 |
{ \msg_warning:nn { ctex } { addCJKfontfeature-ignored } } |
| 674 |
} |
| 675 |
\bool_new:N \l__ctex_ltj_add_alternate_bool |
| 676 |
\cs_generate_variant:Nn \ctex_ltj_add_font_features:n { x } |
| 677 |
\cs_generate_variant:Nn \ctex_ltj_add_font_features:nn { x } |
| 678 |
\msg_new:nnn { ctex } { addCJKfontfeature-ignored } |
| 679 |
{ |
| 680 |
\token_to_str:N \addCJKfontfeature (s)~ignored.\\ |
| 681 |
It~cannot~be~used~with~a~font~that~wasn't~selected~by~ctex. |
| 682 |
} |
| 683 |
\cs_new_protected:Npn \__ctex_ltj_pass_args:nnnn #1#2#3#4 |
| 684 |
{ |
| 685 |
\tl_if_novalue:nTF {#2} |
| 686 |
{ \__ctex_ltj_post_arg:w {#1} {#3} {#4} } |
| 687 |
{ |
| 688 |
\use:e { #1 {#2} {#3} } |
| 689 |
#4 |
| 690 |
} |
| 691 |
} |
| 692 |
\NewDocumentCommand \__ctex_ltj_post_arg:w { m m m O { } } |
| 693 |
{ |
| 694 |
\use:e { #1 {#4} {#2} } |
| 695 |
#3 |
| 696 |
} |
| 697 |
\NewDocumentCommand \setCJKfamilyfont { m o m } |
| 698 |
{ |
| 699 |
\__ctex_ltj_pass_args:nnnn |
| 700 |
{ \ctex_ltj_set_family:nnn {#1} } {#2} {#3} |
| 701 |
{ } |
| 702 |
} |
| 703 |
\NewDocumentCommand \newCJKfontfamily { o m o m } |
| 704 |
{ |
| 705 |
\tl_set:Nx \l__ctex_ltj_tmp_tl |
| 706 |
{ \tl_if_novalue:nTF {#1} { \cs_to_str:N #2 } {#1} } |
| 707 |
\cs_new_protected:Npx #2 |
| 708 |
{ \ctex_ltj_switch_family:n { \l__ctex_ltj_tmp_tl } } |
| 709 |
\__ctex_ltj_pass_args:nnnn |
| 710 |
{ \ctex_ltj_set_family:nnn { \l__ctex_ltj_tmp_tl } } {#3} {#4} |
| 711 |
{ } |
| 712 |
} |
| 713 |
\NewDocumentCommand \CJKfontspec { o m } |
| 714 |
{ |
| 715 |
\__ctex_ltj_pass_args:nnnn |
| 716 |
{ \ctex_ltj_fontspec:nn } {#1} {#2} |
| 717 |
{ \tex_ignorespaces:D } |
| 718 |
} |
| 719 |
\NewDocumentCommand \addCJKfontfeatures { m } |
| 720 |
{ |
| 721 |
\ctex_ltj_add_font_features:x {#1} |
| 722 |
\tex_ignorespaces:D |
| 723 |
} |
| 724 |
\cs_new_eq:NN \addCJKfontfeature \addCJKfontfeatures |
| 725 |
\NewDocumentCommand \setCJKmainfont { o m } |
| 726 |
{ |
| 727 |
\__ctex_ltj_pass_args:nnnn |
| 728 |
{ \ctex_ltj_set_family:nnn { \CJKrmdefault } } {#1} {#2} |
| 729 |
{ \normalfont } |
| 730 |
} |
| 731 |
\cs_new_eq:NN \setCJKromanfont \setCJKmainfont |
| 732 |
\NewDocumentCommand \setCJKsansfont { o m } |
| 733 |
{ |
| 734 |
\__ctex_ltj_pass_args:nnnn |
| 735 |
{ \ctex_ltj_set_family:nnn { \CJKsfdefault } } {#1} {#2} |
| 736 |
{ \normalfont } |
| 737 |
} |
| 738 |
\NewDocumentCommand \setCJKmonofont { o m } |
| 739 |
{ |
| 740 |
\__ctex_ltj_pass_args:nnnn |
| 741 |
{ \ctex_ltj_set_family:nnn { \CJKttdefault } } {#1} {#2} |
| 742 |
{ \normalfont } |
| 743 |
} |
| 744 |
\NewDocumentCommand \setCJKmathfont { o m } |
| 745 |
{ |
| 746 |
\__ctex_ltj_pass_args:nnnn |
| 747 |
{ \ctex_ltj_set_family:nnn { \c__ctex_ltj_math_tl } } {#1} {#2} |
| 748 |
{ } |
| 749 |
} |
| 750 |
\NewDocumentCommand \defaultCJKfontfeatures { m } |
| 751 |
{ \clist_gset:Nn \g__ctex_ltj_default_features_clist {#1} } |
| 752 |
\clist_new:N \g__ctex_ltj_default_features_clist |
| 753 |
\@onlypreamble \setCJKmainfont |
| 754 |
\@onlypreamble \setCJKsansfont |
| 755 |
\@onlypreamble \setCJKmonofont |
| 756 |
\@onlypreamble \setCJKmathfont |
| 757 |
\@onlypreamble \setCJKromanfont |
| 758 |
\@onlypreamble \defaultCJKfontfeatures |
| 759 |
\cs_new_protected:Npn \ctex_ltj_ensure_default_family: |
| 760 |
{ |
| 761 |
\prop_if_empty:NF \g__ctex_ltj_family_font_name_prop |
| 762 |
{ |
| 763 |
\ctex_ltj_family_if_exist:xNF { \CJKfamilydefault } \l__ctex_ltj_tmp_tl |
| 764 |
{ |
| 765 |
\str_if_eq:eeTF { \CJKfamilydefault } { \CJKrmdefault } |
| 766 |
{ \use:n } |
| 767 |
{ |
| 768 |
\ctex_ltj_family_if_exist:xNTF { \CJKrmdefault } \l__ctex_ltj_tmp_tl |
| 769 |
{ \tl_gset:Nn \CJKfamilydefault { \CJKrmdefault } \use_none:n } |
| 770 |
{ \use:n } |
| 771 |
} |
| 772 |
{ |
| 773 |
\prop_map_inline:Nn \g__ctex_ltj_family_font_name_prop |
| 774 |
{ |
| 775 |
\prop_map_break:n |
| 776 |
{ \tl_gset_rescan:Nnn \CJKfamilydefault { } { ##1 } } |
| 777 |
} |
| 778 |
} |
| 779 |
} |
| 780 |
\normalfont |
| 781 |
\ctex_ltj_update_mathfont: |
| 782 |
} |
| 783 |
} |
| 784 |
\cs_new_protected:Npn \ctex_ltj_update_mathfont: |
| 785 |
{ |
| 786 |
\ctex_ltj_family_if_exist:xNTF { \c__ctex_ltj_math_tl } \l__ctex_ltj_tmp_tl |
| 787 |
{ \ctex_ltj_update_mathfont:n { \l__ctex_ltj_tmp_tl } } |
| 788 |
{ |
| 789 |
\ctex_ltj_family_if_exist:xNT { \CJKfamilydefault } \l__ctex_ltj_tmp_tl |
| 790 |
{ \ctex_ltj_update_mathfont:n { \l__ctex_ltj_tmp_tl } } |
| 791 |
} |
| 792 |
} |
| 793 |
\cs_new_protected:Npn \ctex_ltj_update_mathfont:n #1 |
| 794 |
{ |
| 795 |
\tl_const:Nx \c__ctex_ltj_math_family_tl {#1} |
| 796 |
\DeclareSymbolFont { \c__ctex_ltj_math_tl } { \CJK@encoding } |
| 797 |
{ \c__ctex_ltj_math_family_tl } { \mddefault } { \shapedefault } |
| 798 |
\cs_if_free:cTF |
| 799 |
{ \CJK@encoding/\c__ctex_ltj_math_family_tl/\bfdefault/\shapedefault } |
| 800 |
{ |
| 801 |
\SetSymbolFont { \c__ctex_ltj_math_tl } { bold } { \CJK@encoding } |
| 802 |
{ \c__ctex_ltj_math_family_tl } { \mddefault } { \shapedefault } |
| 803 |
} |
| 804 |
{ |
| 805 |
\SetSymbolFont { \c__ctex_ltj_math_tl } { bold } { \CJK@encoding } |
| 806 |
{ \c__ctex_ltj_math_family_tl } { \bfdefault } { \shapedefault } |
| 807 |
} |
| 808 |
} |
| 809 |
\keys_define:nn { ctex_ltj / fontspec } |
| 810 |
{ |
| 811 |
AlternateFont .code:n = \ctex_ltj_set_alternate_prop:n {#1} , |
| 812 |
AlternateFont .value_required:n = true , |
| 813 |
CharRange .clist_set:N = \l__ctex_ltj_char_range_clist , |
| 814 |
CharRange .value_required:n = true |
| 815 |
} |
| 816 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_prop:n #1 |
| 817 |
{ \clist_map_function:nN {#1} \__ctex_ltj_push_alternate_prop:n } |
| 818 |
\cs_new_protected:Npn \__ctex_ltj_push_alternate_prop:n #1 |
| 819 |
{ |
| 820 |
\clist_set:Nx \l__ctex_ltj_tmp_clist { \tl_head:n {#1} } |
| 821 |
\tl_remove_all:Nn \l__ctex_ltj_tmp_clist { ~ } |
| 822 |
\exp_args:No \__ctex_ltj_push_alternate_prop:nn |
| 823 |
{ \l__ctex_ltj_tmp_clist } {#1} |
| 824 |
} |
| 825 |
\cs_new_protected:Npn \__ctex_ltj_push_alternate_prop:nn #1 |
| 826 |
{ |
| 827 |
\prop_remove:Nn \l__ctex_ltj_alternate_prop {#1} |
| 828 |
\prop_put:Nnn \l__ctex_ltj_alternate_prop {#1} |
| 829 |
} |
| 830 |
\clist_new:N \l__ctex_ltj_tmp_clist |
| 831 |
\prop_new:N \l__ctex_ltj_alternate_prop |
| 832 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnF |
| 833 |
{ |
| 834 |
\clist_if_empty:NTF \l__ctex_ltj_char_range_clist |
| 835 |
{ \__ctex_ltj_set_family_aux:nnn } |
| 836 |
{ \__ctex_ltj_set_alternate_family_aux:nnn } |
| 837 |
} |
| 838 |
\cs_new_protected:Npn \__ctex_ltj_set_family_aux:nnn #1#2#3 |
| 839 |
{ |
| 840 |
\__ctex_ltj_check_family:n {#1} |
| 841 |
\prop_if_empty:NF \l__ctex_ltj_alternate_prop |
| 842 |
{ \ctex_ltj_save_alternate_seq:cn { \__ctex_ltj_alternate_cs:n {#1} } {#2} } |
| 843 |
#3 |
| 844 |
} |
| 845 |
\cs_new_protected:Npn \__ctex_ltj_set_alternate_family_aux:nnn #1#2#3 |
| 846 |
{ \ctex_ltj_set_alternate_family:nn {#1} {#2} } |
| 847 |
\cs_new_protected:Npn \ctex_ltj_save_alternate_seq:Nn #1#2 |
| 848 |
{ |
| 849 |
\prop_map_inline:Nn \l__ctex_ltj_alternate_prop |
| 850 |
{ \__ctex_ltj_save_alternate_auxi:w ##2 { } \q_mark #1 {#2} } |
| 851 |
} |
| 852 |
\cs_new_protected:Npn \__ctex_ltj_save_alternate_auxi:w #1#2# |
| 853 |
{ |
| 854 |
\tl_if_blank:nTF {#2} |
| 855 |
{ \__ctex_ltj_save_alternate_auxii:w {#1} } |
| 856 |
{ \__ctex_ltj_save_alternate_auxii:w {#1} {#2} } |
| 857 |
} |
| 858 |
\cs_new_protected:Npn \__ctex_ltj_save_alternate_auxii:w #1#2#3 #4 \q_mark #5#6 |
| 859 |
{ |
| 860 |
\clist_set:Nn \l__ctex_ltj_char_range_clist {#1} |
| 861 |
\clist_set:Nn \l__ctex_ltj_alternate_options_clist {#3} |
| 862 |
\__ctex_ltj_use_global_options:N \l__ctex_ltj_alternate_options_clist |
| 863 |
\tl_if_blank:nTF {#2} |
| 864 |
{ \tl_set:Nn \l__ctex_ltj_tmp_tl {#6} } |
| 865 |
{ |
| 866 |
\tl_set:Nx \l__ctex_ltj_tmp_tl { \tl_trim_spaces:n {#2} } |
| 867 |
\tl_replace_all:Nnn \l__ctex_ltj_tmp_tl { * } {#6} |
| 868 |
} |
| 869 |
\use:e |
| 870 |
{ |
| 871 |
\ctex_ltj_save_alternate_family:Nnnn \exp_not:N #5 |
| 872 |
{ \exp_not:o { \l__ctex_ltj_char_range_clist } } |
| 873 |
{ \exp_not:o { \l__ctex_ltj_alternate_options_clist } } |
| 874 |
{ \exp_not:o { \l__ctex_ltj_tmp_tl } } |
| 875 |
} |
| 876 |
} |
| 877 |
\clist_new:N \l__ctex_ltj_alternate_options_clist |
| 878 |
\cs_generate_variant:Nn \ctex_ltj_save_alternate_seq:Nn { c } |
| 879 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nn #1#2 |
| 880 |
{ |
| 881 |
\__ctex_ltj_update_family_uid:N \l__ctex_ltj_font_options_clist |
| 882 |
\__ctex_ltj_use_global_options:N \l__ctex_ltj_font_options_clist |
| 883 |
\ctex_ltj_set_alternate_family:coonn |
| 884 |
{ \__ctex_ltj_alternate_cs:n {#1} } |
| 885 |
{ \l__ctex_ltj_char_range_clist } |
| 886 |
{ \l__ctex_ltj_font_options_clist } {#2} {#1} |
| 887 |
} |
| 888 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_family:Nnnnn #1#2#3#4#5 |
| 889 |
{ |
| 890 |
\prop_get:NnNT \g__ctex_ltj_family_name_prop {#5} \l__ctex_ltj_base_family_tl |
| 891 |
{ \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } |
| 892 |
\ctex_ltj_save_alternate_family:Nnnn #1 {#2} {#3} {#4} |
| 893 |
} |
| 894 |
\cs_generate_variant:Nn \ctex_ltj_set_alternate_family:Nnnnn { coo } |
| 895 |
\cs_new_protected:Npn \ctex_ltj_save_alternate_family:Nnnn #1#2#3#4 |
| 896 |
{ |
| 897 |
\cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } |
| 898 |
\cs_gset_protected:Npx #1 |
| 899 |
{ \exp_not:o { #1 \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } } |
| 900 |
} |
| 901 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnn #1#2#3 |
| 902 |
{ |
| 903 |
\group_begin: |
| 904 |
\cs_set_eq:NN \CJKfamily \use_none:n |
| 905 |
\ctex_ltj_swap_cs:NN |
| 906 |
\DeclareFontShape@ \ctex_ltj_declare_alternate_shape:nnnnnn |
| 907 |
\tl_set:Nn \l__ctex_ltj_char_range_clist {#1} |
| 908 |
\fontspec_set_family:Nnn \l__ctex_ltj_alternate_family_tl {#2} {#3} |
| 909 |
\group_end: |
| 910 |
} |
| 911 |
\tl_new:N \l__ctex_ltj_alternate_family_tl |
| 912 |
\cs_new_protected:Npn \ctex_ltj_swap_cs:NN #1#2 |
| 913 |
{ |
| 914 |
\cs_set_eq:NN \__ctex_ltj_tmp:w #1 |
| 915 |
\cs_set_eq:NN #1 #2 |
| 916 |
\cs_set_eq:NN #2 \__ctex_ltj_tmp:w |
| 917 |
\cs_undefine:N \__ctex_ltj_tmp:w |
| 918 |
} |
| 919 |
\keys_define:nn { fontspec } { LTJFONTUID .code:n = } |
| 920 |
\cs_new_protected:Npn \__ctex_ltj_update_family_uid:N #1 |
| 921 |
{ |
| 922 |
\int_gincr:N \g__ctex_ltj_family_int |
| 923 |
\clist_put_right:Nx #1 { LTJFONTUID = \int_use:N \g__ctex_ltj_family_int } |
| 924 |
} |
| 925 |
\int_new:N \g__ctex_ltj_family_int |
| 926 |
\cs_new_protected:Npn \ctex_ltj_declare_alternate_shape:nnnnnn #1#2#3#4#5#6 |
| 927 |
{ |
| 928 |
\ctex_ltj_declare_alternate_shape:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6} |
| 929 |
\ctex_ltj_set_alternate_shape:Nnnnnnn \l__ctex_ltj_char_range_clist |
| 930 |
{ \l__ctex_ltj_base_family_tl } {#3} {#4} {#2} {#3} {#4} |
| 931 |
} |
| 932 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:Nnnnnnn #1#2#3#4#5#6#7 |
| 933 |
{ |
| 934 |
\clist_map_inline:Nn #1 |
| 935 |
{ |
| 936 |
\prop_get:NnNTF \g__ctex_ltj_char_range_prop { ##1 } \l__ctex_ltj_char_range_tl |
| 937 |
{ |
| 938 |
\ctex_ltj_set_alternate_shape:nnN { #2/#3/#4 } { #5/#6/#7 } |
| 939 |
\l__ctex_ltj_char_range_tl |
| 940 |
} |
| 941 |
{ \ctex_ltj_set_alternate_shape:nnn { #2/#3/#4 } { #5/#6/#7 } { ##1 } } |
| 942 |
} |
| 943 |
\__ctex_ltj_save_alternate_shape:cn |
| 944 |
{ \__ctex_ltj_alternate_cs:n { clear / \l__ctex_ltj_base_CJKfamily_tl } } |
| 945 |
{ \ctex_ltj_clear_alt_font:n { \CJK@encoding/#2/#3/#4 } } |
| 946 |
} |
| 947 |
\NewDocumentCommand \ctex_ltj_set_alternate_shape:nnn |
| 948 |
{ m m > { \SplitArgument { 1 } { -> } } m } |
| 949 |
{ \ctex_ltj_set_alternate_shape:nnnn {#1} {#2} #3 } |
| 950 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnnn #1#2#3#4 |
| 951 |
{ |
| 952 |
\ctex_ltj_set_alternate_shape:e |
| 953 |
{ |
| 954 |
\__ctex_ltj_range_normalization:nn {#3} {#4} |
| 955 |
{ \CJK@encoding / \exp_not:n {#2} } |
| 956 |
{ \CJK@encoding / \exp_not:n {#1} } |
| 957 |
} |
| 958 |
} |
| 959 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:n #1 |
| 960 |
{ |
| 961 |
\ctex_ltj_set_alt_font:nnnn #1 |
| 962 |
\__ctex_ltj_save_alternate_shape:cn |
| 963 |
{ \__ctex_ltj_alternate_cs:n { reset / \l__ctex_ltj_base_CJKfamily_tl } } |
| 964 |
{ \ctex_ltj_set_alt_font:nnnn #1 } |
| 965 |
} |
| 966 |
\cs_generate_variant:Nn \ctex_ltj_set_alternate_shape:n { e } |
| 967 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnN #1#2#3 |
| 968 |
{ |
| 969 |
\tl_map_inline:Nn #3 |
| 970 |
{ |
| 971 |
\ctex_ltj_set_alternate_shape:n |
| 972 |
{ |
| 973 |
##1 |
| 974 |
{ \CJK@encoding/#2 } |
| 975 |
{ \CJK@encoding/#1 } |
| 976 |
} |
| 977 |
} |
| 978 |
} |
| 979 |
\cs_new_protected:Npn \__ctex_ltj_save_alternate_shape:Nn #1#2 |
| 980 |
{ |
| 981 |
\group_begin: |
| 982 |
\cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } |
| 983 |
\cs_set_eq:NN \l__ctex_ltj_base_family_tl \scan_stop: |
| 984 |
\cs_gset_protected:Npx #1 { \exp_not:o {#1} #2 } |
| 985 |
\group_end: |
| 986 |
} |
| 987 |
\cs_generate_variant:Nn \__ctex_ltj_save_alternate_shape:Nn { c } |
| 988 |
\ctex_define:n |
| 989 |
{ |
| 990 |
clearalternatefont .code:n = |
| 991 |
{ \clist_map_function:eN {#1} \ctex_ltj_clear_alternate_font:n } , |
| 992 |
resetalternatefont .code:n = |
| 993 |
{ \clist_map_function:eN {#1} \ctex_ltj_reset_alternate_font:n } , |
| 994 |
clearalternatefont .default:n = \l_ctex_ltj_family_tl , |
| 995 |
resetalternatefont .default:n = \l_ctex_ltj_family_tl |
| 996 |
} |
| 997 |
\cs_new_protected:Npn \ctex_ltj_clear_alternate_font:n #1 |
| 998 |
{ |
| 999 |
\group_begin: |
| 1000 |
\ctex_ltj_family_if_exist:xNTF {#1} \l__ctex_ltj_base_family_tl |
| 1001 |
{ |
| 1002 |
\cs_if_exist_use:cT |
| 1003 |
{ \__ctex_ltj_alternate_cs:n { clear / #1 } } |
| 1004 |
{ |
| 1005 |
\prop_gput:Nno \g__ctex_ltj_reset_alternate_prop |
| 1006 |
{#1} { \l__ctex_ltj_base_family_tl } |
| 1007 |
\tl_set_eq:NN \CJK@family \l__ctex_ltj_base_family_tl |
| 1008 |
\selectfont |
| 1009 |
} |
| 1010 |
} |
| 1011 |
{ \__ctex_ltj_family_unknown_warning:n {#1} } |
| 1012 |
\group_end: |
| 1013 |
} |
| 1014 |
\cs_new_protected:Npn \ctex_ltj_reset_alternate_font:n #1 |
| 1015 |
{ |
| 1016 |
\group_begin: |
| 1017 |
\prop_gpop:NnNT \g__ctex_ltj_reset_alternate_prop {#1} \CJK@family |
| 1018 |
{ |
| 1019 |
\tl_set_eq:NN \l__ctex_ltj_base_family_tl \CJK@family |
| 1020 |
\use:c { \__ctex_ltj_alternate_cs:n { reset / #1 } } |
| 1021 |
\selectfont |
| 1022 |
} |
| 1023 |
\group_end: |
| 1024 |
} |
| 1025 |
\prop_new:N \g__ctex_ltj_reset_alternate_prop |
| 1026 |
\cs_generate_variant:Nn \clist_map_function:nN { e } |
| 1027 |
\ctex_define:n |
| 1028 |
{ |
| 1029 |
declarecharrange .code:n = \ctex_ltj_declare_char_range:e {#1} , |
| 1030 |
declarecharrange .value_required:n = true |
| 1031 |
} |
| 1032 |
\cs_new_protected:Npn \ctex_ltj_declare_char_range:n #1 |
| 1033 |
{ \clist_map_inline:nn {#1} { \__ctex_ltj_declare_char_range:nn ##1 } } |
| 1034 |
\cs_generate_variant:Nn \ctex_ltj_declare_char_range:n { e } |
| 1035 |
\cs_new_protected:Npn \__ctex_ltj_declare_char_range:nn #1 |
| 1036 |
{ \tl_trim_spaces_apply:nN {#1} \ctex_ltj_declare_char_range:nn } |
| 1037 |
\cs_new_protected:Npn \ctex_ltj_declare_char_range:nn #1#2 |
| 1038 |
{ |
| 1039 |
\tl_clear:N \l__ctex_ltj_char_range_tl |
| 1040 |
\clist_map_function:nN {#2} \ctex_ltj_save_char_range:n |
| 1041 |
\prop_gput:Nno \g__ctex_ltj_char_range_prop {#1} { \l__ctex_ltj_char_range_tl } |
| 1042 |
\ctex_ltj_def_char_range_key:n {#1} |
| 1043 |
\tl_clear:N \l__ctex_ltj_char_range_tl |
| 1044 |
} |
| 1045 |
\tl_new:N \l__ctex_ltj_char_range_tl |
| 1046 |
\prop_new:N \g__ctex_ltj_char_range_prop |
| 1047 |
\NewDocumentCommand \ctex_ltj_save_char_range:n |
| 1048 |
{ > { \SplitArgument { 1 } { -> } } m } |
| 1049 |
{ \ctex_ltj_save_char_range:nn #1 } |
| 1050 |
\cs_new_protected:Npn \ctex_ltj_save_char_range:nn #1#2 |
| 1051 |
{ |
| 1052 |
\tl_put_right:Nx \l__ctex_ltj_char_range_tl |
| 1053 |
{ { \__ctex_ltj_range_normalization:nn {#1} {#2} } } |
| 1054 |
} |
| 1055 |
\cs_new:Npn \__ctex_ltj_range_normalization:nn #1#2 |
| 1056 |
{ |
| 1057 |
\tl_if_novalue:nTF {#2} |
| 1058 |
{ |
| 1059 |
{ \int_eval:n {#1} } |
| 1060 |
{ \int_eval:n {#1} } |
| 1061 |
} |
| 1062 |
{ |
| 1063 |
{ \int_eval:n { \tl_if_blank:nTF {#1} { \c__ctex_ltj_range_min_int } {#1} } } |
| 1064 |
{ \int_eval:n { \tl_if_blank:nTF {#2} { \c__ctex_ltj_range_max_int } {#2} } } |
| 1065 |
} |
| 1066 |
} |
| 1067 |
\int_const:Nn \c__ctex_ltj_range_min_int { "80 } |
| 1068 |
\int_const:Nn \c__ctex_ltj_range_max_int { \c_max_char_int } |
| 1069 |
\cs_new_protected:Npn \ctex_ltj_def_char_range_key:n #1 |
| 1070 |
{ |
| 1071 |
\keys_if_exist:nnF { ctex_ltj / fontspec } {#1} |
| 1072 |
{ |
| 1073 |
\keys_define:nn { ctex_ltj / fontspec } |
| 1074 |
{ #1 .code:n = \ctex_ltj_char_range_key:nn {#1} { ##1 } } |
| 1075 |
} |
| 1076 |
} |
| 1077 |
\cs_new_protected:Npn \ctex_ltj_char_range_key:nn #1#2 |
| 1078 |
{ |
| 1079 |
\tl_if_blank:nTF {#2} |
| 1080 |
{ \clist_set:Nn \l__ctex_ltj_char_range_clist {#1} } |
| 1081 |
{ \__ctex_ltj_push_alternate_prop:nn {#1} { {#1} #2 } } |
| 1082 |
} |
| 1083 |
\AtBeginDocument |
| 1084 |
{ |
| 1085 |
\ctex_appto_cmd:NnnTF \verbatim@font |
| 1086 |
{ \char_set_catcode_letter:n { 64 } } |
| 1087 |
{ \CTEX@verbatim@font@hook } |
| 1088 |
{ } |
| 1089 |
{ \ctex_patch_failure:N \verbatim@font } |
| 1090 |
} |
| 1091 |
\cs_new_protected:Npn \CTEX@verbatim@font@hook |
| 1092 |
{ \ltjsetparameter { autospacing = false , autoxspacing = false } } |
| 1093 |
\cs_set_eq:NN \@@italiccorr \/ |
| 1094 |
\cs_new_protected:Npn \ctex_ltj_set_kanjiskip:N |
| 1095 |
{ \ltj@setpar@global \ltjsetkanjiskip } |
| 1096 |
\cs_new_protected:Npn \ctex_ltj_set_xkanjiskip:N |
| 1097 |
{ \ltj@setpar@global \ltjsetxkanjiskip } |
| 1098 |
\cs_new_protected:Npn \ctex_provide_font_hook:NNN #1#2 |
| 1099 |
{ |
| 1100 |
\exp_args:Nc \__ctex_provide_font_hook_aux:NNNN |
| 1101 |
{ CTEX \cs_to_str:N #2 } #1#2 |
| 1102 |
} |
| 1103 |
\cs_if_exist:NTF \ctex_gadd_ltxhook:nn |
| 1104 |
{ |
| 1105 |
\cs_new_protected:Npn \__ctex_provide_font_hook_aux:NNNN #1#2#3#4 |
| 1106 |
{ |
| 1107 |
\tl_new:N #1 |
| 1108 |
\exp_args:Nx \ctex_gadd_ltxhook:nn { \cs_to_str:N #2 } {#1} |
| 1109 |
} |
| 1110 |
} |
| 1111 |
{ |
| 1112 |
\cs_new_protected:Npn \__ctex_provide_font_hook_aux:NNNN #1#2#3#4 |
| 1113 |
{ |
| 1114 |
\tl_new:N #1 |
| 1115 |
\cs_if_exist:NTF #3 |
| 1116 |
{ \tl_gput_right:Nn #3 {#1} } |
| 1117 |
{ \ctex_parse_name:NN \tl_replace_once:Nnn #2 {#4} { #1#4 } } |
| 1118 |
} |
| 1119 |
} |
| 1120 |
\ctex_provide_font_hook:NNN \rmfamily \@rmfamilyhook \selectfont |
| 1121 |
\ctex_provide_font_hook:NNN \sffamily \@sffamilyhook \selectfont |
| 1122 |
\ctex_provide_font_hook:NNN \ttfamily \@ttfamilyhook \selectfont |
| 1123 |
\ctex_provide_font_hook:NNN \normalfont \@defaultfamilyhook \usefont |
| 1124 |
\tl_if_exist:NF \CJKfamilydefault |
| 1125 |
{ \tl_const:Nn \CJKfamilydefault { \CJKrmdefault } } |
| 1126 |
\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { rm } } |
| 1127 |
\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { sf } } |
| 1128 |
\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { tt } } |
| 1129 |
\tl_gput_right:Nn \CTEX@rmfamilyhook { \CJKfamily { \CJKrmdefault } } |
| 1130 |
\tl_gput_right:Nn \CTEX@sffamilyhook { \CJKfamily { \CJKsfdefault } } |
| 1131 |
\tl_gput_right:Nn \CTEX@ttfamilyhook { \CJKfamily { \CJKttdefault } } |
| 1132 |
\tl_gput_right:Nn \CTEX@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } } |
| 1133 |
\normalfont |
| 1134 |
\ctex_at_end_preamble:n { \ctex_update_default_family: } |
| 1135 |
\cs_new_protected:Npn \ctex_update_default_family: |
| 1136 |
{ |
| 1137 |
\tl_if_eq:NNT \CJKfamilydefault \l__ctex_family_default_init_tl |
| 1138 |
{ |
| 1139 |
\group_begin: |
| 1140 |
\cs_set_eq:NN \__ctex_family_default_wrap:n \exp_not:n |
| 1141 |
\tl_gset:Nx \CJKfamilydefault |
| 1142 |
{ |
| 1143 |
\str_case:onF { \familydefault } |
| 1144 |
{ |
| 1145 |
{ \rmdefault } { \exp_not:N \CJKrmdefault } |
| 1146 |
{ \sfdefault } { \exp_not:N \CJKsfdefault } |
| 1147 |
{ \ttdefault } { \exp_not:N \CJKttdefault } |
| 1148 |
} |
| 1149 |
{ \CJKfamilydefault } |
| 1150 |
} |
| 1151 |
\group_end: |
| 1152 |
} |
| 1153 |
\ctex_ltj_ensure_default_family: |
| 1154 |
} |
| 1155 |
\tl_new:N \l__ctex_family_default_init_tl |
| 1156 |
\cs_new_eq:NN \__ctex_family_default_wrap:n \use:n |
| 1157 |
\tl_set:Nx \l__ctex_family_default_init_tl |
| 1158 |
{ |
| 1159 |
\exp_not:N \__ctex_family_default_wrap:n |
| 1160 |
{ \exp_not:o { \CJKfamilydefault } } |
| 1161 |
} |
| 1162 |
\tl_gset_eq:NN \CJKfamilydefault \l__ctex_family_default_init_tl |
| 1163 |
\ctex_hypersetup:n { pdfencoding = unicode } |
| 1164 |
\cs_new_protected:Npn \ctex_update_ccwd: |
| 1165 |
{ \skip_set:Nn \ccwd { \ltjgetparameter { kanjiskip } + \zw } } |
| 1166 |
\dim_new:N \ccwd |
| 1167 |
\cs_new_protected:Npn \ctex_update_ccglue: |
| 1168 |
{ \ctex_ltj_set_kanjiskip:N \l__ctex_ccglue_skip } |
| 1169 |
\skip_new:N \l__ctex_ccglue_skip |
| 1170 |
\prg_new_conditional:Npnn \ctex_if_ccglue_touched: { TF } |
| 1171 |
{ |
| 1172 |
\skip_if_eq:nnTF { \l__ctex_ccglue_skip } { \ltjgetparameter { kanjiskip } } |
| 1173 |
{ \prg_return_false: } { \prg_return_true: } |
| 1174 |
} |
| 1175 |
\cs_new_protected:Npn \ctex_update_em_unit: |
| 1176 |
{ \dim_set:Nn \ccwd { \zw } } |
| 1177 |
\cs_new_protected:Npn \ctex_add_to_selectfont:n #1 |
| 1178 |
{ |
| 1179 |
\cs_set_protected:Npx \CTEX@selectfont@hook |
| 1180 |
{ \exp_not:o { \CTEX@selectfont@hook #1 } } |
| 1181 |
} |
| 1182 |
\cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: |
| 1183 |
\bool_if:NTF \c__ctex_everysel_loaded_bool |
| 1184 |
{ |
| 1185 |
\cs_if_free:NF \@EverySelectfont@Init |
| 1186 |
{ |
| 1187 |
\group_begin: |
| 1188 |
\cs_set:Npn \__ctex_tmp:N #1 |
| 1189 |
{ |
| 1190 |
\tl_set:Nn \l__ctex_tmp_tl {#1} |
| 1191 |
\cs_new_eq:NN \CTEX@selectfont@save #1 |
| 1192 |
\cs_new_protected:Npn \__ctex_restore_selectfont: |
| 1193 |
{ |
| 1194 |
\cs_if_free:NF \scr@new@selectfont |
| 1195 |
{ |
| 1196 |
\cs_set_eq:NN \scr@new@selectfont #1 |
| 1197 |
\cs_set_eq:NN \CTEX@selectfont@save \scr@selectfont |
| 1198 |
} |
| 1199 |
\tl_put_left:Nn \@EverySelectfont@Init |
| 1200 |
{ \cs_set_eq:NN #1 \CTEX@selectfont@save } |
| 1201 |
\cs_undefine:N \__ctex_restore_selectfont: |
| 1202 |
} |
| 1203 |
} |
| 1204 |
\ctex_parse_name:NN \__ctex_tmp:N \selectfont |
| 1205 |
\exp_last_unbraced:NNo \group_end: |
| 1206 |
\ctex_patch_cmd_once:NnnnTF { \l__ctex_tmp_tl } |
| 1207 |
{ \ExplSyntaxOff } |
| 1208 |
{ \size@update } |
| 1209 |
{ \CTEX@selectfont@hook \size@update } |
| 1210 |
{ \__ctex_restore_selectfont: } |
| 1211 |
{ \ctex_patch_failure:N \selectfont } |
| 1212 |
} |
| 1213 |
\cs_new_protected:Npn \ctex_gadd_selectfont_hook:n |
| 1214 |
{ \EverySelectfont } |
| 1215 |
} |
| 1216 |
{ |
| 1217 |
\cs_new_protected:Npn \ctex_gadd_selectfont_hook:n |
| 1218 |
{ \ctex_gadd_ltxhook:nn { selectfont } } |
| 1219 |
} |
| 1220 |
\ctex_gadd_selectfont_hook:n { \CTEX@selectfont@hook } |
| 1221 |
\ctex_add_to_selectfont:n |
| 1222 |
{ |
| 1223 |
\ctex_ltj_select_font: |
| 1224 |
\ctex_ltj_select_alternate_font: |
| 1225 |
} |
| 1226 |
\tl_set:Nn \CJK@family { song } \selectfont |
| 1227 |
\tl_clear:N \CJK@family |
| 1228 |
\cs_new_protected:Npn \ctex_update_xkanjiskip: |
| 1229 |
{ |
| 1230 |
\skip_if_eq:nnT |
| 1231 |
{ \ltjgetparameter { xkanjiskip } } { \l__ctex_xkanjiskip_skip } |
| 1232 |
{ |
| 1233 |
\skip_set:Nn \l__ctex_xkanjiskip_skip { \l__ctex_xkanjiskip_tl } |
| 1234 |
\ctex_ltj_set_xkanjiskip:N \l__ctex_xkanjiskip_skip |
| 1235 |
} |
| 1236 |
} |
| 1237 |
\tl_new:N \l__ctex_xkanjiskip_tl |
| 1238 |
\tl_set:Nn \l__ctex_xkanjiskip_tl |
| 1239 |
{ .25\zw plus 1pt minus 1pt } |
| 1240 |
\skip_new:N \l__ctex_xkanjiskip_skip |
| 1241 |
\skip_set:Nn \l__ctex_xkanjiskip_skip |
| 1242 |
{ \ltjgetparameter { xkanjiskip } } |
| 1243 |
\ctex_add_to_selectfont:n { \ctex_update_xkanjiskip: } |
| 1244 |
\dim_new:N \cht |
| 1245 |
\dim_new:N \cdp |
| 1246 |
\dim_new:N \cwd |
| 1247 |
\group_begin: |
| 1248 |
\char_set_catcode_space:n { 32 } |
| 1249 |
\lua_now:e |
| 1250 |
{ |
| 1251 |
local nulltable = { } |
| 1252 |
local fmt = luatexja.jfont.font_metric_table |
| 1253 |
local getattribute = tex.getattribute |
| 1254 |
local setdimen = tex.setdimen |
| 1255 |
ctex.newluacmd("ctex_update_kanjisize:", function () |
| 1256 |
local ft = fmt[getattribute("ltj@curjfnt")] or nulltable |
| 1257 |
local ft = ft and ft.char_type or nulltable |
| 1258 |
local fk = ft and ft[0] or nulltable |
| 1259 |
setdimen("cht", fk.height or 0) |
| 1260 |
setdimen("cdp", fk.depth or 0) |
| 1261 |
setdimen("cwd", fk.width or ft.zw or 0) |
| 1262 |
end, "global", "protected") |
| 1263 |
} |
| 1264 |
\group_end: |
| 1265 |
\ctex_add_to_selectfont:n { \ctex_update_kanjisize: } |
| 1266 |
\ctex_define:n |
| 1267 |
{ |
| 1268 |
space .code:n = |
| 1269 |
{ \msg_warning:nn { ctex } { invalid-option } } |
| 1270 |
} |
| 1271 |
\ctex_define:n |
| 1272 |
{ |
| 1273 |
punct .code:n = |
| 1274 |
{ |
| 1275 |
\tl_set:Nx \l__ctex_punct_tl {#1} |
| 1276 |
\ctex_set_jfm:o { \l__ctex_punct_tl } |
| 1277 |
} , |
| 1278 |
punct .default:n = { quanjiao } , |
| 1279 |
} |
| 1280 |
%% |
| 1281 |
%% |
| 1282 |
%% End of file `ctex-engine-luatex.def'. |