向 \sffamily 添加默认字体功能

向 \sffamily 添加默认字体功能

似乎我无法fontspec在设置字体后添加任何额外的默认字体功能,例如\setsansfont。代码:

\documentclass[10pt,a4paper]{article}
\usepackage{lipsum,fontspec,xcolor}

%% <Part set by myfira.sty>
\defaultfontfeatures[MyFira]{%
  Extension      = .otf                   ,
  UprightFont    = FiraSans-Regular       ,
  ItalicFont     = FiraSans-RegularItalic ,
  BoldFont       = FiraSans-SemiBold      ,
  BoldItalicFont = FiraSans-SemiBoldItalic
}
\setsansfont{MyFira}
%% </Part set by myfira.sty>

%% <Part set by user after \usepackage{myfira.sty}>
\defaultfontfeatures+[\sffamily]{Scale=.75, Color=red}
%% </Part set by user after \usepackage{myfira.sty}>

\begin{document}

{\fontspec{MyFira}\addfontfeatures{Scale=.75, Color=blue}\lipsum[1]}% works
{\sffamily % does not work
  \defaultfontfeatures+[MyFira]{Scale=.75, Color=red}\lipsum[1]}
\sffamily % does not work
  \defaultfontfeatures+[\sffamily]{Scale=.75, Color=red}\lipsum[1]

\end{document}

用例是拥有一个定义的包MyFira,用户可以加载此包并使用添加更多功能\defaultfontfeatures+。我可以延迟\setsansfont{MyFira}\AtBeginDocument但如果用户想在文档中间更改某些内容,这无济于事。

任何提示都值得赞赏。

相关内容