使用单独的带有 unicode-math 的 .fontspec 文件

使用单独的带有 unicode-math 的 .fontspec 文件

当我使用 fontspec 和 XeLaTeX 时,我可以将字体放在单独的fonts/子目录中,并将<fontname>.fontspec文件放在 TeX 文件旁边,以指定 fontspec 应如何查找字体(下面的示例 1)。使用 unicode-math,\setmathfont如果我以内联方式指定路径、文件名和扩展名,我可以使用设置数学字体(下面的示例 2)。但是,使用 unicode-math 似乎无法使用<fontname>.fontspec像 fontspec 那样的外部字体(下面的示例 3):在日志中,我看到.fontspec文件加载多次,然后出现kpathsea错误,然后fontspec error: "font-not-found"

如何\setmathfont{Foo}在单独的文件中指定使用 unicode-math 指定的数学字体的路径,例如Foo.fontspec


示例 1:fontspec 和外部 .fontspec 文件(有效)

例子.tex

\documentclass{memoir}
\usepackage{fontspec}
\setmainfont{Arno Pro}
\begin{document}
Hello world!
\end{document}

ArnoPro.字体规范

\defaultfontfeatures[Arno Pro]
{
Path=fonts/,
Extension=.otf,
UprightFont=ArnoPro-Regular,
BoldFont=ArnoPro-Bold,
ItalicFont=ArnoPro-Italic,
BoldItalicFont=ArnoPro-BoldItalic,
}

xelatex 例子.tex

This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018/Arch Linux) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./example.tex
LaTeX2e <2018-04-01> patch level 2
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/share/texmf-dist/tex/latex/memoir/memoir.cls
Document Class: memoir 2018/04/04 v3.7g configurable book, report, article docu
ment class
(/usr/share/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texmf-dist/tex/latex/ifetex/ifetex.sty
(/usr/share/texmf-dist/tex/plain/ifetex/ifetex.tex))
(/usr/share/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-dist/tex/latex/memoir/mem10.clo))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def)))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texmf-dist/tex/latex/base/tuenc.def))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.cfg))) (./ArnoPro.fontspec)
No file example.aux.
[1] (./example.aux) )
Output written on example.pdf (1 page).
Transcript written on example.log.

示例 2:unicode-math 和内联配置(有效)

示例-math-inline.tex

\documentclass{memoir}
\usepackage{unicode-math}
\setmathfont[Path=fonts/,Extension=.ttf]{CambriaMath}
\begin{document}
$Hello world$
\end{document}

xelatex 示例-math-inline.tex

This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018/Arch Linux) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./example-math-inline.tex
LaTeX2e <2018-04-01> patch level 2
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/share/texmf-dist/tex/latex/memoir/memoir.cls
Document Class: memoir 2018/04/04 v3.7g configurable book, report, article docu
ment class
(/usr/share/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texmf-dist/tex/latex/ifetex/ifetex.sty
(/usr/share/texmf-dist/tex/plain/ifetex/ifetex.tex))
(/usr/share/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-dist/tex/latex/memoir/mem10.clo))
(/usr/share/texmf-dist/tex/latex/unicode-math/unicode-math.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/share/texmf-dist/tex/latex/unicode-math/unicode-math-xetex.sty
(/usr/share/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texmf-dist/tex/latex/base/tuenc.def))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/share/texmf-dist/tex/latex/filehook/filehook.sty
(/usr/share/texmf-dist/tex/latex/filehook/filehook-memoir.sty))
(/usr/share/texmf-dist/tex/latex/base/fix-cm.sty
(/usr/share/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex)))
No file example-math-inline.aux.
[1] (./example-math-inline.aux) )
Output written on example-math-inline.pdf (1 page).
Transcript written on example-math-inline.log.

示例数学内联.pdf

Cambria Math 中的“Helloworld”


示例 3:unicode-math 和外部 .fontspec 文件(错误;无输出)

示例-math-external.tex

\documentclass{memoir}
\usepackage{unicode-math}
\setmathfont{Cambria Math}
\begin{document}
$Hello world$
\end{document}

CambriaMath.fontspec

\defaultfontfeatures[Cambria Math]
{
Path=fonts/,
UprightFont=CambriaMath.ttf,
}

xelatex 示例-math-external.tex

This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018/Arch Linux) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./example-math-external.tex
LaTeX2e <2018-04-01> patch level 2
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/share/texmf-dist/tex/latex/memoir/memoir.cls
Document Class: memoir 2018/04/04 v3.7g configurable book, report, article docu
ment class
(/usr/share/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texmf-dist/tex/latex/ifetex/ifetex.sty
(/usr/share/texmf-dist/tex/plain/ifetex/ifetex.tex))
(/usr/share/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-dist/tex/latex/memoir/mem10.clo))
(/usr/share/texmf-dist/tex/latex/unicode-math/unicode-math.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/share/texmf-dist/tex/latex/unicode-math/unicode-math-xetex.sty
(/usr/share/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texmf-dist/tex/latex/base/tuenc.def))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/share/texmf-dist/tex/latex/filehook/filehook.sty
(/usr/share/texmf-dist/tex/latex/filehook/filehook-memoir.sty))
(/usr/share/texmf-dist/tex/latex/base/fix-cm.sty
(/usr/share/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex)))
(./CambriaMath.fontspec) (./CambriaMath.fontspec) (./CambriaMath.fontspec)
(./CambriaMath.fontspec) (./CambriaMath.fontspec) (./CambriaMath.fontspec)kpathsea:make_tex: Invalid filename `[fonts/Cambria Math.ttf]/OT', contains '['


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! 
! The font "Cambria Math" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.3 \setmathfont{Cambria Math}

? 
! Emergency stop.
!...............................................  

l.3 \setmathfont{Cambria Math}

No pages of output.
Transcript written on example-math-external.log.

相关内容