这是在文本和数学模式下使用任何 Stix Two Math OTF 字符,无需将其加载为数学字体。
使用David Carlisle的方法,我制作了以下包文件:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{Stix2OTFCalligraphic}[07/01/2023]
\newfontface\StixTwoMathZero{STIXTwoMath-Regular.otf}[NFSSFamily=stixtwocal,Script=Math]
\DeclareSymbolFont{stixtwocal}{TU}{stixtwocal}{m}{n}
\Umathchardef\stixc@lA "0 \symstixtwocal "1D49C
\Umathchardef\stixc@lB "0 \symstixtwocal "0212C
\Umathchardef\stixc@lC "0 \symstixtwocal "1D49E
\Umathchardef\stixc@lD "0 \symstixtwocal "1D49F
\Umathchardef\stixc@lE "0 \symstixtwocal "02130
\Umathchardef\stixc@lF "0 \symstixtwocal "02131
\Umathchardef\stixc@lG "0 \symstixtwocal "1D4A2
\Umathchardef\stixc@lH "0 \symstixtwocal "0210B
\Umathchardef\stixc@lI "0 \symstixtwocal "02110
\Umathchardef\stixc@lJ "0 \symstixtwocal "1D4A5
\Umathchardef\stixc@lK "0 \symstixtwocal "1D4A6
\Umathchardef\stixc@lL "0 \symstixtwocal "02112
\Umathchardef\stixc@lM "0 \symstixtwocal "02133
\Umathchardef\stixc@lN "0 \symstixtwocal "1D4A9
\Umathchardef\stixc@lO "0 \symstixtwocal "1D4AA
\Umathchardef\stixc@lP "0 \symstixtwocal "1D4AB
\Umathchardef\stixc@lQ "0 \symstixtwocal "1D4AC
\Umathchardef\stixc@lR "0 \symstixtwocal "0211B
\Umathchardef\stixc@lS "0 \symstixtwocal "1D4AE
\Umathchardef\stixc@lT "0 \symstixtwocal "1D4AF
\Umathchardef\stixc@lU "0 \symstixtwocal "1D4B0
\Umathchardef\stixc@lV "0 \symstixtwocal "1D4B1
\Umathchardef\stixc@lW "0 \symstixtwocal "1D4B2
\Umathchardef\stixc@lX "0 \symstixtwocal "1D4B3
\Umathchardef\stixc@lY "0 \symstixtwocal "1D4B4
\Umathchardef\stixc@lZ "0 \symstixtwocal "1D4B5
\Umathchardef\stixc@la "0 \symstixtwocal "1D4B6
\Umathchardef\stixc@lb "0 \symstixtwocal "1D4B7
\Umathchardef\stixc@lc "0 \symstixtwocal "1D4B8
\Umathchardef\stixc@ld "0 \symstixtwocal "1D4B9
\Umathchardef\stixc@le "0 \symstixtwocal "0212F
\Umathchardef\stixc@lf "0 \symstixtwocal "1D4BB
\Umathchardef\stixc@lg "0 \symstixtwocal "0210A
\Umathchardef\stixc@lh "0 \symstixtwocal "1D4BD
\Umathchardef\stixc@li "0 \symstixtwocal "1D4BE
\Umathchardef\stixc@lj "0 \symstixtwocal "1D4BF
\Umathchardef\stixc@lk "0 \symstixtwocal "1D4C0
\Umathchardef\stixc@ll "0 \symstixtwocal "1D4C1
\Umathchardef\stixc@lm "0 \symstixtwocal "1D4C2
\Umathchardef\stixc@ln "0 \symstixtwocal "1D4C3
\Umathchardef\stixc@lo "0 \symstixtwocal "02134
\Umathchardef\stixc@lp "0 \symstixtwocal "1D4C5
\Umathchardef\stixc@lq "0 \symstixtwocal "1D4C6
\Umathchardef\stixc@lr "0 \symstixtwocal "1D4C7
\Umathchardef\stixc@ls "0 \symstixtwocal "1D4C8
\Umathchardef\stixc@lt "0 \symstixtwocal "1D4C9
\Umathchardef\stixc@lu "0 \symstixtwocal "1D4CA
\Umathchardef\stixc@lv "0 \symstixtwocal "1D4CB
\Umathchardef\stixc@lw "0 \symstixtwocal "1D4CC
\Umathchardef\stixc@lx "0 \symstixtwocal "1D4CD
\Umathchardef\stixc@ly "0 \symstixtwocal "1D4CE
\Umathchardef\stixc@lz "0 \symstixtwocal "1D4CF
\Umathchardef\stixc@lbfA "0 \symstixtwocal "1D4D0
\Umathchardef\stixc@lbfB "0 \symstixtwocal "1D4D1
\Umathchardef\stixc@lbfC "0 \symstixtwocal "1D4D2
\Umathchardef\stixc@lbfD "0 \symstixtwocal "1D4D3
\Umathchardef\stixc@lbfE "0 \symstixtwocal "1D4D4
\Umathchardef\stixc@lbfF "0 \symstixtwocal "1D4D5
\Umathchardef\stixc@lbfG "0 \symstixtwocal "1D4D6
\Umathchardef\stixc@lbfH "0 \symstixtwocal "1D4D7
\Umathchardef\stixc@lbfI "0 \symstixtwocal "1D4D8
\Umathchardef\stixc@lbfJ "0 \symstixtwocal "1D4D9
\Umathchardef\stixc@lbfK "0 \symstixtwocal "1D4DA
\Umathchardef\stixc@lbfL "0 \symstixtwocal "1D4DB
\Umathchardef\stixc@lbfM "0 \symstixtwocal "1D4DC
\Umathchardef\stixc@lbfN "0 \symstixtwocal "1D4DD
\Umathchardef\stixc@lbfO "0 \symstixtwocal "1D4DE
\Umathchardef\stixc@lbfP "0 \symstixtwocal "1D4DF
\Umathchardef\stixc@lbfQ "0 \symstixtwocal "1D4E0
\Umathchardef\stixc@lbfR "0 \symstixtwocal "1D4E1
\Umathchardef\stixc@lbfS "0 \symstixtwocal "1D4E2
\Umathchardef\stixc@lbfT "0 \symstixtwocal "1D4E3
\Umathchardef\stixc@lbfU "0 \symstixtwocal "1D4E4
\Umathchardef\stixc@lbfV "0 \symstixtwocal "1D4E5
\Umathchardef\stixc@lbfW "0 \symstixtwocal "1D4E6
\Umathchardef\stixc@lbfX "0 \symstixtwocal "1D4E7
\Umathchardef\stixc@lbfY "0 \symstixtwocal "1D4E8
\Umathchardef\stixc@lbfZ "0 \symstixtwocal "1D4E9
\Umathchardef\stixc@lbfa "0 \symstixtwocal "1D4EA
\Umathchardef\stixc@lbfb "0 \symstixtwocal "1D4EB
\Umathchardef\stixc@lbfc "0 \symstixtwocal "1D4EC
\Umathchardef\stixc@lbfd "0 \symstixtwocal "1D4ED
\Umathchardef\stixc@lbfe "0 \symstixtwocal "1D4EE
\Umathchardef\stixc@lbff "0 \symstixtwocal "1D4EF
\Umathchardef\stixc@lbfg "0 \symstixtwocal "1D4F0
\Umathchardef\stixc@lbfh "0 \symstixtwocal "1D4F1
\Umathchardef\stixc@lbfi "0 \symstixtwocal "1D4F2
\Umathchardef\stixc@lbfj "0 \symstixtwocal "1D4F3
\Umathchardef\stixc@lbfk "0 \symstixtwocal "1D4F4
\Umathchardef\stixc@lbfl "0 \symstixtwocal "1D4F5
\Umathchardef\stixc@lbfm "0 \symstixtwocal "1D4F6
\Umathchardef\stixc@lbfn "0 \symstixtwocal "1D4F7
\Umathchardef\stixc@lbfo "0 \symstixtwocal "1D4F8
\Umathchardef\stixc@lbfp "0 \symstixtwocal "1D4F9
\Umathchardef\stixc@lbfq "0 \symstixtwocal "1D4FA
\Umathchardef\stixc@lbfr "0 \symstixtwocal "1D4FB
\Umathchardef\stixc@lbfs "0 \symstixtwocal "1D4FC
\Umathchardef\stixc@lbft "0 \symstixtwocal "1D4FD
\Umathchardef\stixc@lbfu "0 \symstixtwocal "1D4FE
\Umathchardef\stixc@lbfv "0 \symstixtwocal "1D4FF
\Umathchardef\stixc@lbfw "0 \symstixtwocal "1D500
\Umathchardef\stixc@lbfx "0 \symstixtwocal "1D501
\Umathchardef\stixc@lbfy "0 \symstixtwocal "1D502
\Umathchardef\stixc@lbfz "0 \symstixtwocal "1D503
\def\ifiscseq#1{\ifcat$\expandafter\@gobble\string#1$\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}
\def\stix@@cal#1#2\@nil{%
\ifiscseq{#1}{\ifcsdef{stixc@l\@xp\@gobble\string#1}{\csname stixc@l\@xp\@gobble\string#1\endcsname}{#1}}{%not a cs
\csname stixc@l#1\endcsname}
\ifblank{#2}{\relax}{\stix@@cal #2\@nil}}
\def\stix@@calbf#1#2\@nil{%
\ifiscseq{#1}{\ifcsdef{stixc@lbf\@xp\@gobble\string#1}{\csname stixc@lbf\@xp\@gobble\string#1\endcsname}{#1}}{%not a cs
\csname stixc@lbf#1\endcsname}
\ifblank{#2}{\relax}{\stix@@calbf #2\@nil}}
\DeclareRobustCommand*{\stixcal}[1]{\stix@@cal#1\@nil}
\DeclareRobustCommand*{\stixcalbf}[1]{\stix@@calbf#1\@nil}
这效果很好。我知道可能有办法让它更简洁,我欢迎你在这方面的意见。
现在,如果我添加
\newfontface\StixTwoMathOne{STIXTwoMath-Regular.otf}[NFSSFamily=stixtwochan,Script=Math,StylisticSet=1]
\DeclareSymbolFont{stixtwochan}{TU}{stixtwochan}{m}{n}
和
\def\stix@@chan#1#2\@nil{%
\ifiscseq{#1}{\ifcsdef{stixch@n\@xp\@gobble\string#1}{\csname stixch@n\@xp\@gobble\string#1\endcsname}{#1}}{%not a cs
\csname stixch@n#1\endcsname}
\ifblank{#2}{\relax}{\stix@@chan #2\@nil}}
\def\stix@@chanbf#1#2\@nil{%
\ifiscseq{#1}{\ifcsdef{stixch@nbf\@xp\@gobble\string#1}{\csname stixch@nbf\@xp\@gobble\string#1\endcsname}{#1}}{%not a cs
\csname stixch@nbf#1\endcsname}
\ifblank{#2}{\relax}{\stix@@chanbf #2\@nil}}
\DeclareRobustCommand*{\stixchan}[1]{\stix@@chan#1\@nil}
\DeclareRobustCommand*{\stixchanbf}[1]{\stix@@chanbf#1\@nil}
在底部和整个线条的形式
\Umathchardef\stixch@nA "0 \symstixtwochan "1D49C
在这期间,我遇到了大量以以下内容开头的错误
\symstixtwocal=\mathgroup15
! LaTeX Error: Too many symbol fonts declared.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.7 ...bolFont{stixtwochan}{TU}{stixtwochan}{m}{n}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
! Undefined control sequence.
l.117 \Umathchardef\stixch@nA "0 \symstixtwochan
"1D49C
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Bad math family (119964).
l.117 ...ardef\stixch@nA "0 \symstixtwochan "1D49C
Since I expected to read a number between 0 and 255,
I changed this one to zero.
! Missing number, treated as zero.
<to be read again>
\Umathchardef
l.118 \Umathchardef
\stixch@nB "0 \symstixtwochan "0212C
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
我已经包含了我认为相关的内容。以下错误是重复的,我认为它们(包括最后显示的三个)都源于第一个错误,因为第 17 个数学组从未被声明过。
整个努力都是为了解决这个限制。再次强调,我使用 XeTeX 进行编译fontspec
,而不是unicode-math
,因为我不想用 MathTime Pro II 替换我的数学字体。我所有的文本字体都是 OpenType。我试图将mtpro2
尽可能多的非数学字体移到 OpenType。我做错了什么?
答案1
一个更简单的测试文件是
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
%\patchcmd\DeclareSymbolFont@m@dropped{15}{255}{\typeout{patched}}{\ERROR}
\makeatother
\usepackage{fontspec}
\newfontface\StixTwoMathOne
[NFSSFamily=stixtwochan,Script=Math,StylisticSet=1]
{STIXTwoMath-Regular.otf}
\DeclareSymbolFont{stixtwochan}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochana}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochanb}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochanc}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochand}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochane}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochanf}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochang}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochanh}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochani}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochanj}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochank}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochanl}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochanm}{TU}{stixtwochan}{m}{n}
\DeclareSymbolFont{stixtwochann}{TU}{stixtwochan}{m}{n}
\begin{document}
$x$
\end{document}
取消注释第 5 行会给 Latex 一个提示,有超过 16 个系列可用