在文本中的 Math 和 OsF 中排列数字 - ArnoPro 字体 - 使用 XeLaTeX

在文本中的 Math 和 OsF 中排列数字 - ArnoPro 字体 - 使用 XeLaTeX

我的代码如下:

\documentclass{book}
\RequirePackage[]{fontspec}%
\setmainfont[Ligatures=TeX, Mapping=tex-text,Path = ./Fonts/ArnoPro/ ,Numbers=OldStyle,
UprightFont= ArnoPro-Regular.otf,
BoldFont= ArnoPro-Bold.otf,
ItalicFont= ArnoPro-Italic.otf,
BoldItalicFont= ArnoPro-BoldItalic.otf,
]{ArnoPro}%
\usepackage[italic]{mathastext}%

\makeatletter
\AtBeginDocument{
\DeclareSymbolFont{numbers}{\encodingdefault}{\rmdefault}{m}{n}%
\DeclareMathSymbol{0}{\mathalpha}{numbers}{"30}%
\DeclareMathSymbol{1}{\mathalpha}{numbers}{"31}%
\DeclareMathSymbol{2}{\mathalpha}{numbers}{"32}%
\DeclareMathSymbol{3}{\mathalpha}{numbers}{"33}%
\DeclareMathSymbol{4}{\mathalpha}{numbers}{"34}%
\DeclareMathSymbol{5}{\mathalpha}{numbers}{"35}%
\DeclareMathSymbol{6}{\mathalpha}{numbers}{"36}%
\DeclareMathSymbol{7}{\mathalpha}{numbers}{"37}%
\DeclareMathSymbol{8}{\mathalpha}{numbers}{"38}%
\DeclareMathSymbol{9}{\mathalpha}{numbers}{"39}%
}
\makeatother
\begin{document}

1234567890

$1234567890$


\end{document}

它产生的输出如下:

在此处输入图片描述

但我需要的输出应该是OsF文本和Lining数字的格式Math,我已经尝试过

\everymath{\addfontfeatures{Numbers={Lining}}}%

但什么也没发生,请指教。

答案1

我没有 Arno Pro,所以我用不同的字体。只需%从注释选项中删除即可。

\documentclass{book}
\usepackage{fontspec}

% replace GaramondLibre with ArnoPro
\setmainfont{GaramondLibre}[
  %Path = ./Fonts/ArnoPro/,
  Extension=.otf,
  Numbers=OldStyle,
  UprightFont=*-Regular,
  BoldFont=*-Bold,
  ItalicFont=*-Italic,
  BoldItalicFont=*-BoldItalic,
]
\newfontfamily{\arnoprolining}{GaramondLibre}[
  %Path = ./Fonts/ArnoPro/,
  Extension=.otf,
  Ligatures=TeX,
  %Numbers=Lining,
  UprightFont=*-Regular,
  BoldFont=*-Bold,
  ItalicFont=*-Italic,
  BoldItalicFont=*-BoldItalic,
  NFSSFamily=apl,
]

\AtBeginDocument{
  \DeclareSymbolFont{numbers}{TU}{apl}{m}{n}%
  \SetSymbolFont{numbers}{bold}{TU}{apl}{b}{n}%
  \DeclareMathSymbol{0}{\mathalpha}{numbers}{"30}%
  \DeclareMathSymbol{1}{\mathalpha}{numbers}{"31}%
  \DeclareMathSymbol{2}{\mathalpha}{numbers}{"32}%
  \DeclareMathSymbol{3}{\mathalpha}{numbers}{"33}%
  \DeclareMathSymbol{4}{\mathalpha}{numbers}{"34}%
  \DeclareMathSymbol{5}{\mathalpha}{numbers}{"35}%
  \DeclareMathSymbol{6}{\mathalpha}{numbers}{"36}%
  \DeclareMathSymbol{7}{\mathalpha}{numbers}{"37}%
  \DeclareMathSymbol{8}{\mathalpha}{numbers}{"38}%
  \DeclareMathSymbol{9}{\mathalpha}{numbers}{"39}%
}

\begin{document}

1234567890 $1234567890$ {\boldmath$01234567890$}

\end{document}

在此处输入图片描述

您不需要mathastext(至少对于数字而言)。还请注意和Ligatures=TeX是相同的,但后者对于 LuaLaTeX 无效。然而它不是必需的,因为在处理Mapping=tex-text时它默认处于启用状态。\setmainfont

由于“奇怪”的原因,您需要mathastext在之后加载\setmainfont。我相信这是一个错误功能。

答案2

这是代码的修订版本,应该可以实现所需的输出:

\documentclass{book}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX, Numbers=OldStyle]{ArnoPro}

\usepackage[italic]{mathastext}
\MTsetmathskips{true}
\MTversion[lcg]{varnormal}

\makeatletter
\AtBeginDocument{
  \DeclareSymbolFont{numbers}{\encodingdefault}{\rmdefault}{m}{n}
  \DeclareMathSymbol{0}{\mathalpha}{numbers}{"30}
  \DeclareMathSymbol{1}{\mathalpha}{numbers}{"31}
  \DeclareMathSymbol{2}{\mathalpha}{numbers}{"32}
  \DeclareMathSymbol{3}{\mathalpha}{numbers}{"33}
  \DeclareMathSymbol{4}{\mathalpha}{numbers}{"34}
  \DeclareMathSymbol{5}{\mathalpha}{numbers}{"35}
  \DeclareMathSymbol{6}{\mathalpha}{numbers}{"36}
  \DeclareMathSymbol{7}{\mathalpha}{numbers}{"37}
  \DeclareMathSymbol{8}{\mathalpha}{numbers}{"38}
  \DeclareMathSymbol{9}{\mathalpha}{numbers}{"39}
}
\makeatother

\begin{document}

1234567890

$1234567890$

\end{document}

相关内容