summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/unicode-math/um-code-fontopt.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-01-07 23:46:58 +0000
committerKarl Berry <karl@freefriends.org>2018-01-07 23:46:58 +0000
commitf15ab98da224024bdcb9d2b70a263c7f6143a91b (patch)
tree8368ce018ac0869d5d556cc47b29de4770ad3e62 /Master/texmf-dist/source/latex/unicode-math/um-code-fontopt.dtx
parent6c0d576e1d48613f952b56e99e4dd9d59e41a265 (diff)
unicode-math (7jan18)
git-svn-id: svn://tug.org/texlive/trunk@46240 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/unicode-math/um-code-fontopt.dtx')
-rw-r--r--Master/texmf-dist/source/latex/unicode-math/um-code-fontopt.dtx243
1 files changed, 151 insertions, 92 deletions
diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-fontopt.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-fontopt.dtx
index 59805971ee7..4e142e967bb 100644
--- a/Master/texmf-dist/source/latex/unicode-math/um-code-fontopt.dtx
+++ b/Master/texmf-dist/source/latex/unicode-math/um-code-fontopt.dtx
@@ -1,4 +1,5 @@
%%^^A%% um-code-fontopt.dtx -- part of UNICODE-MATH <wspr.io/unicode-math>
+%%^^A%% Keyval for `\setmathfont`
% \section{Font loading options}
%
@@ -21,79 +22,79 @@
% \subsection{Script and scriptscript font options}
% \begin{macrocode}
\keys_define:nn {unicode-math}
- {
- script-features .tl_set:N = \l_@@_script_features_tl ,
- sscript-features .tl_set:N = \l_@@_sscript_features_tl ,
- script-font .tl_set:N = \l_@@_script_font_tl ,
- sscript-font .tl_set:N = \l_@@_sscript_font_tl ,
- }
+ {
+ script-features .tl_set:N = \l_@@_script_features_tl ,
+ sscript-features .tl_set:N = \l_@@_sscript_features_tl ,
+ script-font .tl_set:N = \l_@@_script_font_tl ,
+ sscript-font .tl_set:N = \l_@@_sscript_font_tl ,
+ }
% \end{macrocode}
%
% \subsection{Range processing}
% \seclabel{rangeproc}
%
+% Locally redefined all math symbol commands to their slot number prefixed by a quark.
+% Similary for the math classes.
% \begin{macrocode}
\keys_define:nn {unicode-math}
- {
- range .code:n =
- {
- \bool_set_false:N \l_@@_init_bool
+ {
+ range .code:n =
+ {
+ \bool_set_false:N \l_@@_init_bool
+ \@@_range_init:
+ \group_begin:
+ \seq_map_inline:Nn \g_@@_mathclasses_seq
+ {
+ \cs_set:Npn ##1 { \use_none:n \q_unicode_math \exp_not:N ##1 }
+ }
+ \cs_set:Npn \_@@_sym:nnn ##1 ##2 ##3
+ {
+ \cs_set:Npn ##2 { \use_none:n \q_unicode_math ##1 }
+ }
+ \@@_input_math_symbol_table:
+ \@@_range_process:n {#1}
+ \group_end:
+ }
+ }
% \end{macrocode}
+%
+% \begin{macro}{\@@_range_init:}
% Set processing functions if we're not defining the full Unicode math repetoire.
% Math symbols are defined with \cmd\_@@_sym:nnn; see \secref{mathsymbol}
% for the individual definitions
% \begin{macrocode}
+\cs_new:Nn \@@_range_init:
+ {
\int_incr:N \g_@@_fam_int
\tl_set:Nx \l_@@_symfont_label_tl {@@_fam\int_use:N\g_@@_fam_int}
\cs_set_eq:NN \_@@_sym:nnn \@@_process_symbol_parse:nnn
- \cs_set_eq:NN \@@_set_mathalphabet_char:Nnn \@@_mathmap_parse:Nnn
\cs_set_eq:NN \@@_remap_symbol:nnn \@@_remap_symbol_parse:nnn
\cs_set_eq:NN \@@_maybe_init_alphabet:n \use_none:n
- \cs_set_eq:NN \@@_map_char_single:nn \@@_map_char_parse:nn
\cs_set_eq:NN \@@_assign_delcode:nn \@@_assign_delcode_parse:nn
\cs_set_eq:NN \@@_make_mathactive:nNN \@@_make_mathactive_parse:nNN
% \end{macrocode}
% Proceed by filling up the various `range' seqs according to the user options.
% \begin{macrocode}
- \seq_clear:N \l_@@_char_range_seq
- \seq_clear:N \l_@@_mclass_range_seq
- \seq_clear:N \l_@@_cmd_range_seq
- \seq_clear:N \l_@@_mathalph_seq
-
- \clist_map_inline:nn {#1}
- {
- \@@_if_mathalph_decl:nTF {##1}
- {
- \seq_put_right:Nx \l_@@_mathalph_seq
- {
- { \exp_not:V \l_@@_tmpa_tl }
- { \exp_not:V \l_@@_tmpb_tl }
- { \exp_not:V \l_@@_tmpc_tl }
- }
- }
- {
+ \seq_gclear:N \g_@@_char_range_seq
+ \seq_gclear:N \g_@@_mclass_range_seq
+ \seq_gclear:N \g_@@_mathalph_seq
+ }
% \end{macrocode}
-% Four cases:
-% math class matching the known list;
-% single item that is a control sequence---command name;
-% single item that isn't---edge case, must be 0--9;
-% none of the above---char range.
+% \end{macro}
+%
+% \begin{macro}{\@@_range_process:}
% \begin{macrocode}
- \seq_if_in:NnTF \g_@@_mathclasses_seq {##1}
- { \seq_put_right:Nn \l_@@_mclass_range_seq {##1} }
- {
- \bool_lazy_and:nnTF { \tl_if_single_p:n {##1} } { \token_if_cs_p:N ##1 }
- { \seq_put_right:Nn \l_@@_cmd_range_seq {##1} }
- { \seq_put_right:Nn \l_@@_char_range_seq {##1} }
- }
- }
- }
- }
- }
+\cs_new:Nn \@@_range_process:n
+ {
+ \clist_map_inline:nn {#1}
+ {
+ \@@_mathalph_decl:nF {##1} { \@@_range_decl:n {##1} }
+ }
+}
% \end{macrocode}
+% \end{macro}
%
-%
-% \begin{macro}{\@@_if_mathalph_decl:nTF}
+% \begin{macro}{\@@_mathalph_decl:nF}
% Possible forms of input:\\
% |\mathscr|\\
% |\mathscr->\mathup|\\
@@ -107,65 +108,95 @@
% The remap style can also be |\mathcal->stixcal|, which I marginally prefer
% in the general case.
% \begin{macrocode}
-\prg_new_conditional:Nnn \@@_if_mathalph_decl:n {TF}
- {
- \tl_set:Nn \l_@@_tmpa_tl {#1}
- \tl_clear:N \l_@@_tmpb_tl
- \tl_clear:N \l_@@_tmpc_tl
+\cs_new:Nn \@@_mathalph_decl:nF
+ {
+
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \tl_clear:N \l_@@_tmpb_tl
+ \tl_clear:N \l_@@_tmpc_tl
- \tl_if_in:NnT \l_@@_tmpa_tl {->}
- { \exp_after:wN \@@_split_arrow:w \l_@@_tmpa_tl \q_nil }
+ \tl_if_in:NnT \l_@@_tmpa_tl {->}
+ { \exp_after:wN \@@_split_arrow:w \l_@@_tmpa_tl \q_nil }
- \tl_if_in:NnT \l_@@_tmpa_tl {/}
- { \exp_after:wN \@@_split_slash:w \l_@@_tmpa_tl \q_nil }
+ \tl_if_in:NnT \l_@@_tmpa_tl {/}
+ { \exp_after:wN \@@_split_slash:w \l_@@_tmpa_tl \q_nil }
- \tl_set:Nx \l_@@_tmpa_tl { \tl_to_str:N \l_@@_tmpa_tl }
- \exp_args:NNx \tl_remove_all:Nn \l_@@_tmpa_tl { \token_to_str:N \math }
- \exp_args:NNx \tl_remove_all:Nn \l_@@_tmpa_tl { \token_to_str:N \sym }
- \tl_trim_spaces:N \l_@@_tmpa_tl
+ \tl_set:Nx \l_@@_tmpa_tl { \tl_to_str:N \l_@@_tmpa_tl }
+ \exp_args:NNx \tl_remove_all:Nn \l_@@_tmpa_tl { \token_to_str:N \math }
+ \exp_args:NNx \tl_remove_all:Nn \l_@@_tmpa_tl { \token_to_str:N \sym }
+ \tl_trim_spaces:N \l_@@_tmpa_tl
- \tl_if_empty:NT \l_@@_tmpc_tl
- { \tl_set_eq:NN \l_@@_tmpc_tl \l_@@_tmpa_tl }
+ \tl_if_empty:NT \l_@@_tmpc_tl
+ { \tl_set_eq:NN \l_@@_tmpc_tl \l_@@_tmpa_tl }
- \seq_if_in:NVTF \g_@@_named_ranges_seq \l_@@_tmpa_tl
- { \prg_return_true: } { \prg_return_false: }
- }
+ \clist_if_in:NVT \g_@@_bad_alpha_clist \l_@@_tmpa_tl { \@@_error:n {range-not-bf-sf} }
+
+ \prop_if_exist:cTF {g_@@_named_range_ \l_@@_tmpa_tl _prop}
+ {
+ \seq_gput_right:Nx \g_@@_mathalph_seq
+ {
+ { \exp_not:V \l_@@_tmpa_tl }
+ { \exp_not:V \l_@@_tmpb_tl }
+ { \exp_not:V \l_@@_tmpc_tl }
+ }
+ }
+ {#2}
+ }
% \end{macrocode}
+%
% \begin{macrocode}
\cs_set:Npn \@@_split_arrow:w #1->#2 \q_nil
- {
- \tl_set:Nx \l_@@_tmpa_tl { \tl_trim_spaces:n {#1} }
- \tl_set:Nx \l_@@_tmpc_tl { \tl_trim_spaces:n {#2} }
- }
+ {
+ \tl_set:Nx \l_@@_tmpa_tl { \tl_trim_spaces:n {#1} }
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_trim_spaces:n {#2} }
+ }
% \end{macrocode}
% \begin{macrocode}
\cs_set:Npn \@@_split_slash:w #1/#2 \q_nil
- {
- \tl_set:Nx \l_@@_tmpa_tl { \tl_trim_spaces:n {#1} }
- \tl_set:Nx \l_@@_tmpb_tl { \tl_trim_spaces:n {#2} }
- }
+ {
+ \tl_set:Nx \l_@@_tmpa_tl { \tl_trim_spaces:n {#1} }
+ \tl_set:Nx \l_@@_tmpb_tl { \tl_trim_spaces:n {#2} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_range_decl:n}
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_range_decl:n
+ {
+ \bool_lazy_and:nnTF { \tl_if_single_p:n {#1} } { \token_if_cs_p:N #1 }
+ {
+ \tl_if_in:VnTF #1 { \q_unicode_math }
+ {
+ \seq_if_in:NnTF \g__um_mathclasses_seq {#1}
+ { \seq_gput_right:Nn \g_@@_mclass_range_seq {#1} }
+ { \seq_gput_right:Nx \g_@@_char_range_seq {#1} }
+ }
+ { \@@_error:nx {bad-cs-in-range} { \tl_to_str:n {#1} } }
+ }
+ {
+ \seq_gput_right:Nx \g_@@_char_range_seq {#1}
+ }
+ }
% \end{macrocode}
% \end{macro}
%
-% Pretty basic comma separated range processing.
-% Donald Arseneau's \pkg{selectp} package has a cleverer technique.
%
-% \begin{macro}{\@@_if_char_spec:nNNT}
+% \begin{macro}{\@@_if_char_spec:nNT}
% \darg{Unicode character slot}
-% \darg{control sequence (character macro)}
% \darg{control sequence (math class)}
% \darg{code to execute}
-% This macro expands to |#4|
-% if any of its arguments are contained in \cmd\l_@@_char_range_seq.
+% This macro expands to |#3|
+% if any of its arguments are contained in \cmd\g_@@_char_range_seq.
% This list can contain either character ranges (for checking with |#1|) or control sequences.
% These latter can either be the command name of a specific character, \emph{or} the math
% type of one (\eg, \cmd\mathbin).
%
-% Character ranges are passed to \cs{@@_if_char_spec:nNNT}, which accepts input in the form shown in \tabref{ranges}.
+% Character ranges are passed to \cs{@@_if_char_spec:nNT}, which accepts input in the form shown in \tabref{ranges}.
%
% \begin{table}[htbp]
% \centering
-% \topcaption{Ranges accepted by \cs{@@_if_char_spec:nNNT}.}
+% \topcaption{Ranges accepted by \cs{@@_if_char_spec:nNT}.}
% \label{tab:ranges}
% \begin{tabular}{>{\ttfamily}cc}
% \textrm{Input} & Range \\
@@ -180,19 +211,18 @@
% We have three tests, performed sequentially in order of execution time.
% Any test finding a match jumps directly to the end.
% \begin{macrocode}
-\cs_new:Nn \@@_if_char_spec:nNNT
+\cs_new:Nn \@@_if_char_spec:nNT
{
% math class:
- \seq_if_in:NnT \l_@@_mclass_range_seq {#3}
- { \use_none_delimit_by_q_nil:w }
-
- % command name:
- \seq_if_in:NnT \l_@@_cmd_range_seq {#2}
+ \seq_if_in:NnT \g_@@_mclass_range_seq {#2}
{ \use_none_delimit_by_q_nil:w }
% character slot:
- \seq_map_inline:Nn \l_@@_char_range_seq
+ \seq_map_inline:Nn \g_@@_char_range_seq
{
+ \@@_int_if_slot_is_last_in_range:nnT {#1} {##1}
+ { \seq_gremove_all:Nn \g_@@_char_range_seq {##1} }
+
\@@_int_if_slot_in_range:nnT {#1} {##1}
{ \seq_map_break:n { \use_none_delimit_by_q_nil:w } }
}
@@ -202,14 +232,20 @@
\q_nil
\use:n
{
- \clist_put_right:Nx \l_@@_char_nrange_clist { \int_eval:n {#1} }
- #4
+ \cs_if_eq:NNT #2 \mathalpha
+ {
+ \clist_put_right:Nx \l_@@_mathmap_charints_clist { \int_eval:n {#1} }
+ }
+ #3
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_int_if_slot_in_range:nnT}
+% Pretty basic comma separated range processing.
+% Donald Arseneau's \pkg{selectp} package has a cleverer technique.
+%
% A `numrange' is like |-2,5-8,12,17-| (can be unsorted).
%
% Four cases, four argument types:
@@ -223,7 +259,9 @@
%
% \begin{macrocode}
\cs_new:Nn \@@_int_if_slot_in_range:nnT
- { \@@_numrange_parse:nwT {#1} #2 - \q_nil - \q_stop {#3} }
+ {
+ \@@_numrange_parse:nwT {#1} #2 - \q_nil - \q_stop {#3}
+ }
% \end{macrocode}
%
% \begin{macrocode}
@@ -241,6 +279,27 @@
% \end{macrocode}
% \end{macro}
%
+%
+% \begin{macrocode}
+\cs_new:Nn \@@_int_if_slot_is_last_in_range:nnT
+ {
+ \@@_numrange_last_parse:nwT {#1} #2 - \q_nil - \q_stop {#3}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_set:Npn \@@_numrange_last_parse:nwT #1 #2 - #3 - #4 \q_stop #5
+ {
+ \tl_if_empty:nTF {#4} { \int_compare:nT {#1==#2} {#5} }
+ {
+ \tl_if_empty:nTF {#2} { \int_compare:nT {#1==#3} {#5} }
+ {
+ \int_compare:nT {#1==#3} {#5}
+ } }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</package>
% \end{macrocode}
@@ -256,7 +315,7 @@
% the conditions of the LaTeX Project Public License, version 1.3c or higher
% (your choice): <http://www.latex-project.org/lppl/>.
% ------------------------------------------------
-% Copyright 2006-2017 Will Robertson, LPPL "maintainer"
+% Copyright 2006-2018 Will Robertson, LPPL "maintainer"
% Copyright 2010-2017 Philipp Stephani
% Copyright 2011-2017 Joseph Wright
% Copyright 2012-2015 Khaled Hosny