[latex3-commits] [git/LaTeX3-latex3-latex3] master: Implement \token_if_font_selection:NTF (fixes #806) (6cdd9381e)
Bruno Le Floch
blflatex at gmail.com
Tue Oct 27 10:19:29 CET 2020
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/6cdd9381e7be9236c16e7315134ce383f81c6c3b
>---------------------------------------------------------------
commit 6cdd9381e7be9236c16e7315134ce383f81c6c3b
Author: Bruno Le Floch <blflatex at gmail.com>
Date: Tue Oct 27 10:19:29 2020 +0100
Implement \token_if_font_selection:NTF (fixes #806)
>---------------------------------------------------------------
6cdd9381e7be9236c16e7315134ce383f81c6c3b
l3kernel/l3token.dtx | 20 +++++++++-
l3kernel/testfiles/m3token003.lvt | 33 ++++++++++++----
l3kernel/testfiles/m3token003.tlg | 81 +++++++++++++++++++++++++++++++++------
3 files changed, 113 insertions(+), 21 deletions(-)
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 6437aa23b..468fae0e5 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -692,6 +692,14 @@
% Tests if the \meta{token} is defined to be a mathchardef.
% \end{function}
%
+% \begin{function}[EXP,pTF, added=2020-10-27]{\token_if_font_selection:N}
+% \begin{syntax}
+% \cs{token_if_font_selection_p:N} \meta{token} \\
+% \cs{token_if_font_selection:NTF} \meta{token} \Arg{true code} \Arg{false code}
+% \end{syntax}
+% Tests if the \meta{token} is defined to be a font selection command.
+% \end{function}
+%
% \begin{function}[EXP,pTF, updated=2012-01-20]{\token_if_dim_register:N}
% \begin{syntax}
% \cs{token_if_dim_register_p:N} \meta{token} \\
@@ -2222,6 +2230,7 @@
% \@@_delimit_by_char":w,
% \@@_delimit_by_count:w,
% \@@_delimit_by_dimen:w,
+% \@@_delimit_by_ font:w,
% \@@_delimit_by_macro:w,
% \@@_delimit_by_muskip:w,
% \@@_delimit_by_skip:w,
@@ -2233,6 +2242,9 @@
% argument delimited by a string, a second one delimited by
% \cs{s_@@_stop}, and returns the first one and its delimiter.
% This result is eventually compared to another string.
+% Note that the ``font'' auxiliary is delimited by a space followed by
+% ``\texttt{font}''. This avoids an unnecessary check for the
+% \tn{font} primitive below.
% \begin{macrocode}
\group_begin:
\cs_set_protected:Npn \@@_tmp:w #1
@@ -2247,6 +2259,7 @@
\@@_tmp:w { char" }
\@@_tmp:w { count }
\@@_tmp:w { dimen }
+\@@_tmp:w { ~ font }
\@@_tmp:w { macro }
\@@_tmp:w { muskip }
\@@_tmp:w { skip }
@@ -2260,6 +2273,7 @@
% \token_if_chardef:N, \token_if_mathchardef:N,
% \token_if_long_macro:N,
% \token_if_protected_macro:N, \token_if_protected_long_macro:N,
+% \token_if_font_selection:N,
% \token_if_dim_register:N, \token_if_int_register:N,
% \token_if_muskip_register:N,
% \token_if_skip_register:N, \token_if_toks_register:N,
@@ -2292,8 +2306,9 @@
% space after |\protected| but a space after |\long|, hence the
% mixture of \cs{token_to_str:N} and \cs{tl_to_str:n}.
%
-% For the first five conditionals, \cs{cs_if_exist:cT} turns out to
-% be \texttt{false}, and the code boils down to a string comparison
+% For the first six conditionals, \cs{cs_if_exist:cT} turns out to
+% be \texttt{false} (thanks to the leading space for \texttt{font}),
+% and the code boils down to a string comparison
% between the result of the auxiliary on the \tn{meaning} of the
% conditional's argument~|####1|, and~|#3|. Both are evaluated at
% run-time, as this is important to get the correct escape character.
@@ -2348,6 +2363,7 @@
{ \tl_to_str:n { \protected } macro }
\@@_tmp:w { protected_long_macro } { macro }
{ \token_to_str:N \protected \tl_to_str:n { \long } macro }
+\@@_tmp:w { font_selection } { ~ font } { select ~ font }
\@@_tmp:w { dim_register } { dimen } { \token_to_str:N \dimen }
\@@_tmp:w { int_register } { count } { \token_to_str:N \count }
\@@_tmp:w { muskip_register } { muskip } { \token_to_str:N \muskip }
diff --git a/l3kernel/testfiles/m3token003.lvt b/l3kernel/testfiles/m3token003.lvt
index bc39bc581..0bc6181c8 100644
--- a/l3kernel/testfiles/m3token003.lvt
+++ b/l3kernel/testfiles/m3token003.lvt
@@ -1,5 +1,5 @@
%
-% Copyright (C) 2009-2012,2014,2018 The LaTeX Project
+% Copyright (C) 2009-2012,2014,2018,2020 The LaTeX Project
%
\documentclass{minimal}
@@ -31,6 +31,7 @@
\int_new:N \regint
\tex_chardef:D \regchar = 7
\tex_mathchardef:D \regmathchar =999
+\tex_font:D \regfont = cmr10 ~ at ~ 8.76543pt \scan_stop:
\TIMO
\cs_set_protected:Npn \test:n #1
{
@@ -45,7 +46,8 @@
\token_if_dim_register:NTF \regskip {\TRUE}{\FALSE} \NEWLINE
\token_if_dim_register:NTF \regint {\TRUE}{\FALSE} \NEWLINE
\token_if_dim_register:NTF \regchar {\TRUE}{\FALSE} \NEWLINE
- \token_if_dim_register:NTF \regmathchar {\TRUE}{\FALSE}
+ \token_if_dim_register:NTF \regmathchar {\TRUE}{\FALSE} \NEWLINE
+ \token_if_dim_register:NTF \regfont {\TRUE}{\FALSE}
}
\TESTEXP{token_if_muskip}{
@@ -57,7 +59,8 @@
\token_if_muskip_register:NTF \regskip {\TRUE}{\FALSE} \NEWLINE
\token_if_muskip_register:NTF \regint {\TRUE}{\FALSE} \NEWLINE
\token_if_muskip_register:NTF \regchar {\TRUE}{\FALSE} \NEWLINE
- \token_if_muskip_register:NTF \regmathchar {\TRUE}{\FALSE}
+ \token_if_muskip_register:NTF \regmathchar {\TRUE}{\FALSE} \NEWLINE
+ \token_if_muskip_register:NTF \regfont {\TRUE}{\FALSE}
}
\TESTEXP{token_if_skip}{
@@ -69,7 +72,8 @@
\token_if_skip_register:NTF \regskip {\TRUE}{\FALSE} \NEWLINE
\token_if_skip_register:NTF \regint {\TRUE}{\FALSE} \NEWLINE
\token_if_skip_register:NTF \regchar {\TRUE}{\FALSE} \NEWLINE
- \token_if_skip_register:NTF \regmathchar {\TRUE}{\FALSE}
+ \token_if_skip_register:NTF \regmathchar {\TRUE}{\FALSE} \NEWLINE
+ \token_if_skip_register:NTF \regfont {\TRUE}{\FALSE}
}
\TESTEXP{token_if_int}{
@@ -81,7 +85,8 @@
\token_if_int_register:NTF \regskip {\TRUE}{\FALSE} \NEWLINE
\token_if_int_register:NTF \regint {\TRUE}{\FALSE} \NEWLINE
\token_if_int_register:NTF \regchar {\TRUE}{\FALSE} \NEWLINE
- \token_if_int_register:NTF \regmathchar {\TRUE}{\FALSE}
+ \token_if_int_register:NTF \regmathchar {\TRUE}{\FALSE} \NEWLINE
+ \token_if_int_register:NTF \regfont {\TRUE}{\FALSE}
}
\TESTEXP{token_if_chardef}{
@@ -93,7 +98,8 @@
\token_if_chardef:NTF \regskip {\TRUE}{\FALSE} \NEWLINE
\token_if_chardef:NTF \regint {\TRUE}{\FALSE} \NEWLINE
\token_if_chardef:NTF \regchar {\TRUE}{\FALSE} \NEWLINE
- \token_if_chardef:NTF \regmathchar {\TRUE}{\FALSE}
+ \token_if_chardef:NTF \regmathchar {\TRUE}{\FALSE} \NEWLINE
+ \token_if_chardef:NTF \regfont {\TRUE}{\FALSE}
}
\TESTEXP{token_if_mathchardef}{
@@ -105,7 +111,20 @@
\token_if_mathchardef:NTF \regskip {\TRUE}{\FALSE} \NEWLINE
\token_if_mathchardef:NTF \regint {\TRUE}{\FALSE} \NEWLINE
\token_if_mathchardef:NTF \regchar {\TRUE}{\FALSE} \NEWLINE
- \token_if_mathchardef:NTF \regmathchar {\TRUE}{\FALSE}
+ \token_if_mathchardef:NTF \regmathchar {\TRUE}{\FALSE} \NEWLINE
+ \token_if_mathchardef:NTF \regfont {\TRUE}{\FALSE}
+ }
+
+ \TESTEXP{token_if_font_selection}{
+ \token_if_font_selection:NTF \tex_font:D {\TRUE}{\FALSE} \NEWLINE
+ \token_if_font_selection:NTF \regmacro {\TRUE}{\FALSE} \NEWLINE
+ \token_if_font_selection:NTF \regdim {\TRUE}{\FALSE} \NEWLINE
+ \token_if_font_selection:NTF \regmuskip {\TRUE}{\FALSE} \NEWLINE
+ \token_if_font_selection:NTF \regskip {\TRUE}{\FALSE} \NEWLINE
+ \token_if_font_selection:NTF \regint {\TRUE}{\FALSE} \NEWLINE
+ \token_if_font_selection:NTF \regchar {\TRUE}{\FALSE} \NEWLINE
+ \token_if_font_selection:NTF \regmathchar {\TRUE}{\FALSE} \NEWLINE
+ \token_if_font_selection:NTF \regfont {\TRUE}{\FALSE}
}
}
\test:n {92}
diff --git a/l3kernel/testfiles/m3token003.tlg b/l3kernel/testfiles/m3token003.tlg
index 28a34e3b2..6e0807065 100644
--- a/l3kernel/testfiles/m3token003.tlg
+++ b/l3kernel/testfiles/m3token003.tlg
@@ -13,6 +13,7 @@ FALSE
FALSE
FALSE
FALSE
+FALSE
============================================================
============================================================
TEST 2: token_if_muskip
@@ -26,6 +27,7 @@ FALSE
FALSE
FALSE
FALSE
+FALSE
============================================================
============================================================
TEST 3: token_if_skip
@@ -39,6 +41,7 @@ TRUE
FALSE
FALSE
FALSE
+FALSE
============================================================
============================================================
TEST 4: token_if_int
@@ -52,6 +55,7 @@ FALSE
TRUE
FALSE
FALSE
+FALSE
============================================================
============================================================
TEST 5: token_if_chardef
@@ -65,6 +69,7 @@ FALSE
FALSE
TRUE
FALSE
+FALSE
============================================================
============================================================
TEST 6: token_if_mathchardef
@@ -78,13 +83,42 @@ FALSE
FALSE
FALSE
TRUE
+FALSE
+============================================================
+============================================================
+TEST 7: token_if_font_selection
+============================================================
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+TRUE
+============================================================
+============================================================
+TEST 8: token_if_dim
+============================================================
+FALSE
+FALSE
+FALSE
+TRUE
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
============================================================
============================================================
-TEST 7: token_if_dim
+TEST 9: token_if_muskip
============================================================
FALSE
FALSE
FALSE
+FALSE
TRUE
FALSE
FALSE
@@ -93,12 +127,13 @@ FALSE
FALSE
============================================================
============================================================
-TEST 8: token_if_muskip
+TEST 10: token_if_skip
============================================================
FALSE
FALSE
FALSE
FALSE
+FALSE
TRUE
FALSE
FALSE
@@ -106,20 +141,21 @@ FALSE
FALSE
============================================================
============================================================
-TEST 9: token_if_skip
+TEST 11: token_if_int
============================================================
FALSE
FALSE
FALSE
FALSE
FALSE
+FALSE
TRUE
FALSE
FALSE
FALSE
============================================================
============================================================
-TEST 10: token_if_int
+TEST 12: token_if_chardef
============================================================
FALSE
FALSE
@@ -127,12 +163,13 @@ FALSE
FALSE
FALSE
FALSE
+FALSE
TRUE
FALSE
FALSE
============================================================
============================================================
-TEST 11: token_if_chardef
+TEST 13: token_if_mathchardef
============================================================
FALSE
FALSE
@@ -141,11 +178,12 @@ FALSE
FALSE
FALSE
FALSE
+FALSE
TRUE
FALSE
============================================================
============================================================
-TEST 12: token_if_mathchardef
+TEST 14: token_if_font_selection
============================================================
FALSE
FALSE
@@ -158,7 +196,7 @@ FALSE
TRUE
============================================================
============================================================
-TEST 13: token_if_dim
+TEST 15: token_if_dim
============================================================
FALSE
FALSE
@@ -169,9 +207,10 @@ FALSE
FALSE
FALSE
FALSE
+FALSE
============================================================
============================================================
-TEST 14: token_if_muskip
+TEST 16: token_if_muskip
============================================================
FALSE
FALSE
@@ -182,9 +221,10 @@ FALSE
FALSE
FALSE
FALSE
+FALSE
============================================================
============================================================
-TEST 15: token_if_skip
+TEST 17: token_if_skip
============================================================
FALSE
FALSE
@@ -195,9 +235,10 @@ TRUE
FALSE
FALSE
FALSE
+FALSE
============================================================
============================================================
-TEST 16: token_if_int
+TEST 18: token_if_int
============================================================
FALSE
FALSE
@@ -208,9 +249,10 @@ FALSE
TRUE
FALSE
FALSE
+FALSE
============================================================
============================================================
-TEST 17: token_if_chardef
+TEST 19: token_if_chardef
============================================================
FALSE
FALSE
@@ -221,9 +263,24 @@ FALSE
FALSE
TRUE
FALSE
+FALSE
+============================================================
+============================================================
+TEST 20: token_if_mathchardef
+============================================================
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+FALSE
+TRUE
+FALSE
============================================================
============================================================
-TEST 18: token_if_mathchardef
+TEST 21: token_if_font_selection
============================================================
FALSE
FALSE
More information about the latex3-commits
mailing list.