使用 fontspec 为自己的字体定义 SizeFeatures

使用 fontspec 为自己的字体定义 SizeFeatures

我使用的字体种类繁多,包含很多字体。除了标准的 Upright、Bold、Italic 和 BoldItalic 之外,我还需要使用 Semibold 等字体。

我定义新面孔

FontFace        =   {semibold}{n}{*Semibold},
FontFace        =   {semibold}{it}{*SemiboldIt},

我需要类似的东西

UprightFeatures =   {
                        SizeFeatures={
                            {Size={-8.9},       Font    =   *Capt},
                            {Size={8.4-12.9},   Font    =   *Regular},
                            {Size={13.0-22.9},  Font    =   *Subh},
                            {Size={22.9-},      Font    =   *Disp}
                        }
},

但对于半粗体来说。

我怎样才能做到这一点?

LuaLaTeX 消息格式:

\documentclass{article}

\newcommand{\MyPath}{} % Your Path to the fonts here

\usepackage{polyglossia}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{booktabs}

\setmainlanguage{english}

\setmainfont{WarnockPro-}[%
    Extension       =   .otf,
    UprightFont     =   *Regular,
    ItalicFont      =   *It,
    BoldFont        =   *Bold,
    BoldItalicFont  =   *BoldIt,
    FontFace        =   {semibold}{n}{*Semibold},
    FontFace        =   {semibold}{it}{*SemiboldIt},
    Path            =   \MyPath,
    Ligatures       =   {TeX,Rare,Common},
    Contextuals     =   {Swash},
    Numbers         =   {Uppercase},
    Style           =   {Historic},
    Kerning         =   {On},
    UprightFeatures =   {
                            SizeFeatures={
                                {Size={-8.9},       Font    =   *Capt},
                                {Size={8.4-12.9},   Font    =   *Regular},
                                {Size={13.0-22.9},  Font    =   *Subh},
                                {Size={22.9-},      Font    =   *Disp}
                            }
    },
    ItalicFeatures  =   {
                            SizeFeatures={
                                {Size={-8.9},       Font    =   *ItCapt},
                                {Size={8.4-12.9},   Font    =   *It},
                                {Size={13.0-22.9},  Font    =   *ItSubh},
                                {Size={22.9-},      Font    =   *ItDisp}
                            }
    },
    BoldFeatures    =   {
                            SizeFeatures={
                                {Size={-8.9},       Font    =   *BoldCapt},
                                {Size={8.4-12.9},   Font    =   *Bold},
                                {Size={13.0-22.9},  Font    =   *BoldSubh},
                                {Size={22.9-},      Font    =   *BoldDisp}
                            }
    },
    BoldItalicFeatures  =   {
                            SizeFeatures={
                                {Size={-8.9},       Font    =   *BoldItCapt},
                                {Size={8.4-12.9},   Font    =   *BoldIt},
                                {Size={13.0-22.9},  Font    =   *BoldItSubh},
                                {Size={22.9-},      Font    =   *BoldItDisp}
                            }
    },
]

\makeatletter

\DeclareRobustCommand\semiboldseries % Defines SEMIBOLD series
{\not@math@alphabet\semiboldseries\mathbf
    \fontseries{semibold}\selectfont
}

\makeatother 

\newcommand{\GO}{ % Typesets dummy text
    \resizebox{!}{12pt}{\fontsize{7}{7}\selectfont Test Word}

    \resizebox{!}{12pt}{\fontsize{10}{10}\selectfont Test Word}

    \resizebox{!}{12pt}{\fontsize{16}{16}\selectfont Test Word}

    \resizebox{!}{12pt}{\fontsize{40}{40}\selectfont Test Word}
}

\begin{document}


\begin{tabularx}{\textwidth}{ X X X X }
    \toprule
           & Regular              & Semibold                   & Bold                 \\ \midrule
    Italic & \itshape\mdseries\GO & \itshape\semiboldseries\GO & \itshape\bfseries\GO \\[3mm]
    Up     & \mdseries\GO         & \semiboldseries\GO         & \bfseries\GO         \\ \bottomrule
\end{tabularx}


\end{document}

正如预期的那样适用于斜体和粗体:

enter image description here

答案1

半粗体的“官方”NFSS 标识符是sb (参见 LaTeX 2e 字体选择),所以我将使用这个而不是semibold。您可以将字体功能(包括)SizeFeatures传递FontFace

FontFace        =   {sb}{n}{
                        Font = *Semibold,
                        SizeFeatures = {
                          {Size= -8.9,   Font    =   *CaptSemibold},
                          {Size=8.9-22.9}, % No Font=, so *Semibold is used
                          {Size=22.9- ,   Font    =   *DispSemibold},
                        }
                    },

欲了解更多信息,您可以查看fontspec 文档,第 2.3 节

相关内容