siunitx 与非平凡系列的 fontspec 不匹配

siunitx 与非平凡系列的 fontspec 不匹配

我对 XeTeX 和 Fontspec 还不太熟悉,但我正在尝试使用具有多种粗细的 Google 字体(Alegreya)。我认为我\setmainfont正确地将各种粗细定义为不同的系列,一切似乎都运行良好。但是当我使用并将数字和单位的排版方式与上下文相匹配的siunitx选项时,只有一些系列被正确识别。detect-all

如下例所示,siunitx似乎确实在尝试匹配系列(参见浅色和粗体情况)。然而,同样从对的快速检查来看siunitx.sty,在我看来,它只尝试匹配系列的第一个字母,\lseries如果系列以“l”开头,则推断出浅色权重,如果系列以“b”开头,则推断出粗体权重。该banything系列似乎证实了这一假设。如果这是正确的,是否有一个简单的解决方案来siunitx检测并使用精确的系列?

以下是示例:

\documentclass{article}
\usepackage{fontspec}

\setmainfont{Alegreya Sans}[
  Ligatures=TeX,
  UprightFont = * Regular,
  ItalicFont = * Italic,
  BoldFont = * Bold,
  BoldItalicFont = * Bold Italic,
  FontFace = {banything}{n}{* Thin},          % just for testing purposes
  FontFace = {banything}{it}{* Thin Italic},  % just for testing purposes
  FontFace = {el}{n}{* Thin},
  FontFace = {el}{it}{* Thin Italic},
  FontFace = {l}{n}{* Light},
  FontFace = {l}{it}{* Light Italic},
  FontFace = {sb}{n}{* Medium},
  FontFace = {sb}{it}{* Medium Italic},
  FontFace = {eb}{n}{* ExtraBold},
  FontFace = {eb}{it}{* ExtraBold Italic},
  FontFace = {ub}{n}{* Black},
  FontFace = {ub}{it}{* Black Italic}
  ]

\DeclareRobustCommand{\elseries}{\fontseries{el}\selectfont}
\DeclareTextFontCommand{\textel}{\elseries}
\DeclareRobustCommand{\lseries}{\fontseries{l}\selectfont}
\DeclareTextFontCommand{\textl}{\lseries}
\DeclareRobustCommand{\sbseries}{\fontseries{sb}\selectfont}
\DeclareTextFontCommand{\textsb}{\sbseries}
\DeclareRobustCommand{\ebseries}{\fontseries{eb}\selectfont}
\DeclareTextFontCommand{\texteb}{\ebseries}
\DeclareRobustCommand{\ubseries}{\fontseries{ub}\selectfont}
\DeclareTextFontCommand{\textub}{\ubseries}

\usepackage{siunitx}

\sisetup{detect-all}

% just for testing purposes
\DeclareRobustCommand{\banythingseries}{\fontseries{banything}\selectfont}
\DeclareTextFontCommand{\textbanything}{\banythingseries}

\begin{document}
\begin{itemize}
\item \textel{This is thin, \textsc{small caps}, and \emph{Italic}: 1 µm and \SI{1}{\um}.}
\item \textl{This is light, \textsc{small caps}, and \emph{Italic}: 1 µm and \SI{1}{\um}.}
\item This is regular, \textsc{small caps}, and \emph{Italic}: 1 µm and \SI{1}{\um}.
\item \textsb{This is medium, \textsc{small caps}, and \emph{Italic}: 1 µm and \SI{1}{\um}.}
\item \textbf{This is bold, \textsc{small caps}, and \emph{Italic}: 1 µm and \SI{1}{\um}.}
\item \texteb{This is extra bold, \textsc{small caps}, and \emph{Italic}: 1 µm and \SI{1}{\um}.}
\item \textub{This is black, \textsc{small caps}, and \emph{Italic}: 1 µm and \SI{1}{\um}.}
\item \textbanything{This is thin but the series in named ``banything'': 1 µm and \SI{1}{\um}.}
\end{itemize}
\end{document}

结果如下:

XeTeX 输出

相关内容