Fontspec 在罗马字体、Mono 字体和数学字体之间匹配小写字母

Fontspec 在罗马字体、Mono 字体和数学字体之间匹配小写字母

我一直在尝试制作romanmono匹配math fonts小写。更具体地说,我使用PalatinoromanAMS-Euler。但是,到目前为止我还没有成功。我的情况如图所示。从左到右,我们有数学字体、罗马字体和 mono 字体mathdejavu sansmono

小写和大写字母的插图

这是 MWE

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = xelatex

\documentclass[a4paper,12pt]{article}

\usepackage{fontspec} 
\defaultfontfeatures{Mapping=tex-text,Ligatures={TeX,Common},Scale=MatchLowercase,Color=textcolor}
\defaultfontfeatures[\rmfamily]{Scale=1} % To scale all fonts correctly

\setromanfont[Numbers=OldStyle]{Palatino Linotype}
\setmainfont[Numbers=OldStyle]{Palatino Linotype}
\setmonofont{DejaVuSansMono.ttf}
% Setting Euler as math font
\usepackage[math-style=TeX,vargreek-shape=unicode,math-style=upright]{unicode-math}

\setmathfont[bold-style=ISO]{ams-euler.ttf} %Can be downloaded from http://www.fontain.org/ams-euler/ 

\begin{document}

Upper case: $W$W{\tt W}

Lower case: $w$w{\tt w}

\end{document}

有人知道如何缩放这些字体以使大写和/或小写匹配吗?

答案1

\开始{编辑}{2018-05-17}

你可能想看看这个答案详细介绍了如何最好地使用 Neo Euler。需要考虑的一个主要问题是,Neo Euler 自 2011 年以来一直没有被使用,github repo 指出

该项目已放弃,该存储库仅用于历史目的

所以我不知道使用 Euler、AMS Euler 或 Neo Euler 是否仍然是个好主意。您可能想让死者安息,并使用活字体。看看最新版本unicode-math 文档做出更明智的决定,了解如何最好地继续前进。

\结束{编辑}


该选项Scale=MatchLowercase在 下有效XeLaTeX。我偶然发现,“正确”的方法是遵循文档中的示例 1:

\setmainfont{texgyrebonum-regular.otf}
\setsansfont{lmsans10-regular.otf}[Scale=MatchLowercase]
\setmonofont{Inconsolatazi4-Regular.otf}[Scale=MatchLowercase]

也就是说,不要将设置Scale=MatchLowercase

\defaultfontfeatures{...}

而是作为“辅助”字体的可选参数,然后它将自己定位到主字体,该字体已由\setmainfont{...}

第二(是的,我没有提到‘第一’,别介意),从fontspec文档中,我们得到:

任何数学字体包(例如 euler)之后都必须加载 fontspec 包才能成功。(实际上,只有 euler 才是问题所在。5)

5:说到欧拉,如果您想使用它的[mathbf]选项,它将不起作用,您需要在fontspec加载后放置这个:\AtBeginDocument{\DeclareMathAlphabet\mathbf{U}{eur}{b}{n}

第三,主字体似乎有问题Palatino Linotype,因为以下代码......

\documentclass{article}
\usepackage[math-style=upright]{unicode-math}
\setmathfont[Color={00D419},Scale=MatchLowercase]{ams-euler.otf}
\usepackage{fontspec}
\setmainfont{Palatino Linotype}
\setmonofont[Color={0019D4},Scale=MatchLowercase]{DejaVu Sans Mono}
\begin{document}
Upper case: $W$W{\tt W}

Lower case: $w$w{\tt w}
\end{document}

产量

小写字母的高度不同

但是如果我只是将字体更改为Libertinus Serif(我没有测试其他字体),...

\documentclass{article}
\usepackage[math-style=upright]{unicode-math}
\setmathfont[Color={00D419},Scale=MatchLowercase]{ams-euler.otf}
\usepackage{fontspec}
\setmainfont{Libertinus Serif}
\setmonofont[Color={0019D4},Scale=MatchLowercase]{DejaVu Sans Mono}
\begin{document}
Upper case: $W$W{\tt W}

Lower case: $w$w{\tt w}
\end{document}

我们得到了完美匹配的小写类型。它也能与 一起使用MatchUppercase

小写字母大小匹配

附言:有人能告诉我这个\setromanfont术语出自哪里吗?在文档中找不到这个术语fontspec

相关内容