From e526edff1f4884090f58dfaf692bd9a4a6c177d1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 1 Feb 2018 23:06:27 +0000 Subject: unicode-math (1feb18) git-svn-id: svn://tug.org/texlive/trunk@46515 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/latex/unicode-math/um-code-amsmath.dtx | 2 +- .../source/latex/unicode-math/um-code-compat.dtx | 2 +- .../source/latex/unicode-math/um-code-epilogue.dtx | 10 ++- .../source/latex/unicode-math/um-code-fontopt.dtx | 7 +- .../source/latex/unicode-math/um-code-main.dtx | 11 +-- .../source/latex/unicode-math/um-code-mathmap.dtx | 13 ++-- .../source/latex/unicode-math/um-code-mathtext.dtx | 77 +++++++++++++++++++ .../source/latex/unicode-math/um-code-msg.dtx | 5 ++ .../source/latex/unicode-math/um-code-opening.dtx | 20 ++++- .../latex/unicode-math/um-code-sym-commands.dtx | 89 ++-------------------- .../latex/unicode-math/um-code-variables.dtx | 5 ++ .../source/latex/unicode-math/unicode-math.dtx | 6 +- 12 files changed, 140 insertions(+), 107 deletions(-) (limited to 'Master/texmf-dist/source/latex/unicode-math') diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-amsmath.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-amsmath.dtx index 57927c73bc1..0b67a673f57 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-amsmath.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-amsmath.dtx @@ -195,7 +195,7 @@ { \box_use:N \rootbox } \@@_mathstyle_scale:NnnN #1 { \kern } { \fontdimen 64 \g_@@_sqrt_font_cmd_tl } \g_@@_sqrt_font_cmd_tl \mkern \leftroot@ mu - \box_use_clear:N \l_tmpa_box + \box_use_drop:N \l_tmpa_box } % } diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx index 2aca97a2fa9..668acbad2f9 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx @@ -124,7 +124,7 @@ { \box_ht:N \l_tmpa_box - \@@_radical_vgap:N #1 } - \box_use_clear:N \l_tmpa_box + \box_use_drop:N \l_tmpa_box } } % diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx index cb8a701bb45..3cbaefef3ba 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx @@ -74,7 +74,7 @@ } { \box_use:N \rootbox } \@@_mathstyle_scale:NnnN ##1 { \kern } { \fontdimen 64 \g_@@_sqrt_font_cmd_tl } \g_@@_sqrt_font_cmd_tl - \box_use_clear:N \l_tmpa_box + \box_use_drop:N \l_tmpa_box } } % @@ -383,11 +383,15 @@ \@@_undeclare_symbol:N \bracevert % \end{macrocode} % -% \paragraph{Fin} +% \begin{macrocode} +% +% \end{macrocode} +% +% \section*{Fin} +% % The official end of the package: % \begin{macrocode} %\endinput -% % \end{macrocode} \endinput 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 4e142e967bb..77924ee9894 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 @@ -40,6 +40,7 @@ { range .code:n = { + \bool_if:NF \g_@@_main_font_defined_bool { \@@_error:n {no-main-font} } \bool_set_false:N \l_@@_init_bool \@@_range_init: \group_begin: @@ -165,17 +166,19 @@ \cs_new_protected:Nn \@@_range_decl:n { \bool_lazy_and:nnTF { \tl_if_single_p:n {#1} } { \token_if_cs_p:N #1 } + % IF A CSNAME: { \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} } + { \seq_gput_right:Nx \g_@@_char_range_seq { #1 } } } { \@@_error:nx {bad-cs-in-range} { \tl_to_str:n {#1} } } } + % ELSE ASSUME NUMERIC INPUT: { - \seq_gput_right:Nx \g_@@_char_range_seq {#1} + \seq_gput_right:Nx \g_@@_char_range_seq { #1 } } } % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-main.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-main.dtx index 0cd47069e3c..e57fbf45d15 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-main.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-main.dtx @@ -70,6 +70,7 @@ \bool_if:NTF \l_@@_init_bool { + \bool_gset_true:N \g_@@_main_font_defined_bool % \@@_mathparam_store: \@@_log:n {default-math-font} } @@ -89,7 +90,7 @@ \AtBeginDocument { \@@_load_lm_if_necessary: } \cs_new:Nn \@@_load_lm_if_necessary: { - \cs_if_exist:NF \l_@@_fontname_tl + \bool_if:NF \g_@@_main_font_defined_bool { %\typeout{SETTING~ DEFAULT~ FONT~(latinmodern-math)} \setmathfont{latinmodern-math.otf} @@ -157,7 +158,7 @@ % Renderer = Basic, BoldItalicFont = {}, ItalicFont = {}, Script = Math, -% FontAdjustment = { \g_@@_luatex_copy_fontdimens_tl }, +% FontAdjustment = { \@@_luatex_copy_fontdimens: }, \l_@@_unknown_keys_clist } @@ -205,7 +206,7 @@ \l_@@_sscript_features_tl } } , -% FontAdjustment = { \g_@@_luatex_copy_fontdimens_tl }, +% FontAdjustment = { \@@_luatex_copy_fontdimens: }, \l_@@_unknown_keys_clist } @@ -236,10 +237,10 @@ \tl_set:Nn \g_@@_prime_font_cmd_tl { \l_@@_font } % \end{macrocode} % -% \begin{macro}{\g_@@_luatex_copy_fontdimens_tl} +% \begin{macro}{\@@_luatex_copy_fontdimens:} % \begin{macrocode} %<*LU> -\tl_const:Nn \g_@@_luatex_copy_fontdimens_tl +\cs_new_protected:Nn \@@_luatex_copy_fontdimens: { \@@_fontdimen_from_param:nn {10} {ScriptPercentScaleDown} \@@_fontdimen_from_param:nn {11} {ScriptScriptPercentScaleDown} diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-mathmap.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-mathmap.dtx index b3257369c0d..056e03bd715 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-mathmap.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-mathmap.dtx @@ -75,14 +75,17 @@ \clist_map_inline:Nn \l_@@_alphabet_clist { - \clist_map_inline:cn {g_@@_named_slots_ \l_@@_style_tl _ ####1 _clist} + \clist_if_exist:cT {g_@@_named_slots_ \l_@@_style_tl _ ####1 _clist} { - \clist_map_inline:Nn \l_@@_mathmap_charints_clist + \clist_map_inline:cn {g_@@_named_slots_ \l_@@_style_tl _ ####1 _clist} { - \@@_int_if_slot_in_range:nnT {################1} {########1} + \clist_map_inline:Nn \l_@@_mathmap_charints_clist { - \seq_gput_right:Nn \g_@@_mathalph_seq {##1} - \clist_map_break:n { \clist_map_break:n { \clist_map_break: } } + \@@_int_if_slot_in_range:nnT {################1} {########1} + { + \seq_gput_right:Nn \g_@@_mathalph_seq {##1} + \clist_map_break:n { \clist_map_break:n { \clist_map_break: } } + } } } } diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-mathtext.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-mathtext.dtx index c576d63770b..903cd0407e1 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-mathtext.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-mathtext.dtx @@ -10,6 +10,7 @@ % \subsection{\cs{setmathfontface}} % % \begin{macro}{\@@_setmathfontface:Nnn} +% Interface around \cs{SetMathAlphabet}. % \begin{macrocode} \keys_define:nn {@@_mathface} { @@ -47,6 +48,81 @@ % \end{macro} % % +% \subsection{Hooks into \LaTeXe} +% +% Switching to a different style of alphabetic symbols was traditionally performed with +% commands like \cmd\mathbf, which literally changes fonts to access alternate symbols. +% This is not as simple with Unicode fonts. +% +% In traditional \TeX{} maths font setups, you simply switch between different `families' (\cmd\fam), which is analogous to changing from one font to another---a symbol such as `a' will be upright in one font, bold in another, and so on. +% In pkg{unicode-math}, a different mechanism is used to switch between styles. For every letter (start with ascii a-zA-Z and numbers to keep things simple for now), they are assigned a `mathcode' with \cmd\Umathcode\ that maps from input letter to output font glyph slot. This is done with the equivalent of +% \begin{Verbatim} +% \Umathcode`\a = 7 1 "1D44E\relax +% \Umathcode`\b = 7 1 "1D44F\relax +% \Umathcode`\c = 7 1 "1D450\relax +% ... +% \end{Verbatim} +% When switching from regular letters to, say, \cmd\mathrm, we now need to execute a new mapping: +% \begin{Verbatim} +% \Umathcode`\a = 7 1 `\a\relax +% \Umathcode`\b = 7 1 `\b\relax +% \Umathcode`\c = 7 1 `\c\relax +% ... +% \end{Verbatim} +% This is fairly straightforward to perform when we're defining our own commands such as \cmd\symbf\ and so on. However, this means that `classical' \TeX\ font setups will break, because with the original mapping still in place, the engine will be attempting to insert unicode maths glyphs from a standard font. +% +% \begin{macro}{\use@mathgroup} +% To overcome this, we patch \cs{use@mathgroup}, which is only used inside of commands +% such as \cs{mathXYZ}, so this shouldn't have any side-effects. +% Omit the test for math mode because this is only called \emph{inside} \cs{mathrm} or similar, +% which already has a math mode check. +% \begin{macrocode} +\cs_set:Npn \use@mathgroup #1 #2 + { + \@@_group_begin: + \cs_if_eq:cNF {M@\f@encoding} #1 {#1} + \@@_switchto_literal: + \@@_mathgroup_set:n {#2} + \@@_group_end:n + } +% \end{macrocode} +% \end{macro} +% +% In LaTeX maths, the command |\operator@font| is defined that switches to the |operator| mathgroup. The classic example is the |\sin| in |$\sin{x}$|; essentially we’re using |\mathrm| to typeset the upright symbols, but the syntax is |{\operator@font sin}|. +% I thought that hooking into |\operator@font| would be hard because all other maths font selection in 2e uses |\mathrm{...}| style. +% Then reading source2e a little more I stumbled upon \cs{@fontswitch}. +% Reimplement that here to avoid \cs{bgroup}/\cs{egroup}. +% \begin{macro}{\operator@font} +% \begin{macrocode} +\cs_set:Npn \operator@font + { + \@@_switchto_literal: + \@@_fontswitch:n { \g_@@_operator_mathfont_tl } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_fontswitch:n} +% Omit the check for math mode as \verb|#1| should do that for us. +% \begin{macrocode} +\cs_set:Nn \@@_fontswitch:n + { + \cs_set_eq:NN \math@bgroup \scan_stop: + \cs_set_eq:NN \@@_group_begin: \scan_stop: + \cs_set:Npn \@@_group_end:n % takes no argument in this case + { + \cs_set_eq:NN \@@_group_begin: \@@_group_begin_frozen: + \cs_set_eq:NN \@@_group_end:n \@@_group_end_frozen:n + \cs_set_eq:NN \math@bgroup \@@math@bgroup + \cs_set_eq:NN \math@egroup \@@math@egroup + } + \cs_set_eq:NN \math@egroup \@@_group_end:n + #1 \scan_stop: + } +% \end{macrocode} +% \end{macro} +% +% % \subsection{Hooks into \pkg{fontspec}} % % Historically, \cs{mathrm} and so on were completely overwritten by \pkg{unicode-math}, and \pkg{fontspec}'s methods for setting these fonts in the classical manner were bypassed. @@ -91,6 +167,7 @@ % \end{macrocode} % % \subsubsection{Maths font} +% % If the maths fonts are set explicitly, then the text commands above will not execute their branches to set the maths font alphabets. % \begin{macrocode} \cs_set:Nn \__fontspec_setmathrm_hook:nn diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-msg.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-msg.dtx index db561dcebb3..9e51fd6600a 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-msg.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-msg.dtx @@ -114,6 +114,11 @@ since they relate to input commands not output glyphs. Use `bfit` or `bfup` (etc.) to specify which. } +\@@_msg_new:nn {no-main-font} + { + No main maths font has been set up yet.\\If you simply want ‘the default’, use: \\ + \iow_indent:n {\token_to_str:N\setmathfont{latinmodern-math.otf}} + } % \end{macrocode} % % \begin{macrocode} diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-opening.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-opening.dtx index 4e9493bb65e..76fe65e33e3 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-opening.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-opening.dtx @@ -42,9 +42,9 @@ % % \begin{macrocode} \cs_set_eq:NN \@@_group_begin: \group_begin: -\cs_set_eq:NN \@@_group_end: \group_end: +\cs_set_protected:Npn \@@_group_end:n #1 { #1 \group_end: } \cs_set_eq:NN \@@_group_begin_frozen: \@@_group_begin: -\cs_set_eq:NN \@@_group_end_frozen: \@@_group_end: +\cs_set_eq:NN \@@_group_end_frozen:n \@@_group_end:n % \end{macrocode} % % @@ -182,6 +182,18 @@ } % \end{macrocode} % +% \subsubsection{NFSS-related interfaces} +% +% \begin{macro}{\@@_mathgroup_set:n} +% Remember that \cs{mathgroup} is just \cs{fam}! +% \begin{macrocode} +\cs_new_protected:Nn \@@_mathgroup_set:n + { + \tex_fam:D #1 \scan_stop: + } +% \end{macrocode} +% \end{macro} +% % \subsubsection{Font parameters} % % \begin{macro}{\@@_copy_fontdimen:nnN} @@ -211,7 +223,9 @@ %<*LU> \cs_new_protected:Nn \@@_fontdimen_from_param:nn { - \fontdimen #1 \font = \directlua{fontspec.mathfontdimen(font.current(),"#2")}\relax + \fontdimen #1 \font = + \lua_now:n { fontspec.mathfontdimen(font.current(),"#2") } + \scan_stop: } % % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-sym-commands.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-sym-commands.dtx index cd7263ecf9e..9b1d67a3061 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-sym-commands.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-sym-commands.dtx @@ -8,83 +8,6 @@ %<*package> % \end{macrocode} % -% Switching to a different style of alphabetic symbols was traditionally performed with -% commands like \cmd\mathbf, which literally changes fonts to access alternate symbols. -% This is not as simple with Unicode fonts. -% -% In traditional \TeX{} maths font setups, you simply switch between different `families' (\cmd\fam), which is analogous to changing from one font to another---a symbol such as `a' will be upright in one font, bold in another, and so on. -% In pkg{unicode-math}, a different mechanism is used to switch between styles. For every letter (start with ascii a-zA-Z and numbers to keep things simple for now), they are assigned a `mathcode' with \cmd\Umathcode\ that maps from input letter to output font glyph slot. This is done with the equivalent of -% \begin{Verbatim} -% \Umathcode`\a = 7 1 "1D44E\relax -% \Umathcode`\b = 7 1 "1D44F\relax -% \Umathcode`\c = 7 1 "1D450\relax -% ... -% \end{Verbatim} -% When switching from regular letters to, say, \cmd\mathrm, we now need to execute a new mapping: -% \begin{Verbatim} -% \Umathcode`\a = 7 1 `\a\relax -% \Umathcode`\b = 7 1 `\b\relax -% \Umathcode`\c = 7 1 `\c\relax -% ... -% \end{Verbatim} -% This is fairly straightforward to perform when we're defining our own commands such as \cmd\symbf\ and so on. However, this means that `classical' \TeX\ font setups will break, because with the original mapping still in place, the engine will be attempting to insert unicode maths glyphs from a standard font. -% -% \subsection{Hooks into \LaTeXe} -% -% To overcome this, we patch \cs{use@mathgroup}. -% (An alternative is to patch \cs{extract@alph@from@version}, which constructs the \cs{mathXYZ} commands, but this method fails if the command has been defined using \cs{DeclareSymbolFontAlphabet}.) -% As far as I can tell, this is only used inside of commands such as \cs{mathXYZ}, so this shouldn't have any major side-effects. -% -% \begin{macrocode} -\cs_set:Npn \use@mathgroup #1 #2 - { - \mode_if_math:T % <- not sure if this is really necessary since we've just checked for mmode and raised an error if not! - { - \math@bgroup - \cs_if_eq:cNF {M@\f@encoding} #1 {#1} - \@@_switchto_literal: - \mathgroup #2 \relax - \math@egroup - } - } -% \end{macrocode} -% -% In LaTeX maths, the command |\operator@font| is defined that switches to the |operator| mathgroup. The classic example is the |\sin| in |$\sin{x}$|; essentially we’re using |\mathrm| to typeset the upright symbols, but the syntax is |{\operator@font sin}|. -% I thought that hooking into |\operator@font| would be hard because all other maths font selection in 2e uses |\mathrm{...}| style. -% Then reading source2e a little more I stumbled upon \cs{@fontswitch}. -% Reimplement that here to avoid \cs{bgroup}/\cs{egroup}. -% \begin{macro}{\operator@font} -% \begin{macrocode} -\cs_set:Npn \operator@font - { - \@@_switchto_literal: - \@@_fontswitch:n { \g_@@_operator_mathfont_tl } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_fontswitch:n} -% \begin{macrocode} -\cs_set:Nn \@@_fontswitch:n - { - \mode_if_math:T - { - \cs_set_eq:NN \math@bgroup \scan_stop: - \cs_set_eq:NN \@@_group_begin: \scan_stop: - \cs_set:Npn \@@_group_end: - { - \cs_set_eq:NN \@@_group_begin: \@@_group_begin_frozen: - \cs_set_eq:NN \@@_group_end: \@@_group_end_frozen: - \cs_set_eq:NN \math@bgroup \@@math@bgroup - \cs_set_eq:NN \math@egroup \@@math@egroup - } - \cs_set_eq:NN \math@egroup \@@_group_end: - #1 \scan_stop: - } - } -% \end{macrocode} -% \end{macro} -% % % \subsection{Setting styles} % @@ -134,19 +57,17 @@ { \seq_gput_right:Nn \g_@@_mathstyles_seq {#1} \@@_init_alphabet:n {#1} - \cs_set_protected:cpx {sym#1} ##1 + \cs_set_protected:cpx {sym#1} { \@@_group_begin: \exp_not:n { - \mode_if_math:F - { - \exp_args:Nc \non@alpherr {sym#1} - } + \mode_if_math:F { \exp_args:Nc \non@alpherr {sym#1} } \tl_set:Nn \l_@@_mathstyle_tl {#1} } - \exp_not:c {@@_switchto_#1:} ##1 - \@@_group_end: + \exp_not:c {@@_switchto_#1:} + \@@_mathgroup_set:n {-1} + \@@_group_end:n } } % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-variables.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-variables.dtx index 082a38bb3cb..bb5a6ebe3af 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-variables.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-variables.dtx @@ -15,6 +15,11 @@ \bool_new:N \l_@@_ot_math_bool % \end{macrocode} % +% Set when \cs{setmathfont} is run to trap the problem of no main font defined. +% \begin{macrocode} +\bool_new:N \g_@@_main_font_defined_bool +% \end{macrocode} +% % \begin{macrocode} \bool_new:N \l_@@_init_bool \bool_new:N \l_@@_implicit_alph_bool diff --git a/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx b/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx index 83f4012d528..ea0d86dca4d 100644 --- a/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx @@ -60,15 +60,15 @@ %\ProvidesExplPackage{unicode-math} %\ProvidesExplPackage{unicode-math-xetex} %\ProvidesExplPackage{unicode-math-luatex} -% {2018/01/13} {v0.8k} {Unicode maths in XeLaTeX and LuaLaTeX} +% {2018/02/02} {v0.8l} {Unicode maths in XeLaTeX and LuaLaTeX} % \end{macrocode} % % Here the version and date are setup for typesetting the documentation. % \begin{macrocode} %<*dtx> \date{ - \def\filedate{2018/01/13} - \def\fileversion{v0.8k} + \def\filedate{2018/02/02} + \def\fileversion{v0.8l} \filedate \qquad \fileversion } % -- cgit v1.2.3