编辑

编辑

pdf(la)tex是否可以在文档主体中测试当前字体 (和)是否支持小写字母xe(la)tex?我想要做的是:

\usepackage{xifthen}
...
\ifthenelse{<small caps are available with the current font>}{%
  \textsc{my text}%
}{%
  \uppercase{my text}%
}

答案1

编辑

好的,正如 David 在评论中指出的那样,仅仅查看\f@encoding/\f@family/\f@series/sc是不够的,因为此命令是在替换期间定义的。因此,可能需要记录是否发生了替换:

\documentclass[11pt,a4paper]{scrartcl}
\makeatletter
\def\define@newfont{%
  \begingroup
    \let\typeout\@font@info
    \escapechar\m@ne
    \expandafter\expandafter\expandafter
       \split@name\expandafter\string\font@name\@nil
      \try@load@fontshape % try always
    \expandafter\ifx
       \csname\curr@fontshape\endcsname \relax
       \expandafter\gdef\csname \curr@fontshape/sub\endcsname{}% new      
      \wrong@fontshape\else
      \extract@font\fi
  \endgroup}

\newcommand\testsc{%
 \ifcsname \f@encoding/\f@family/\f@series/sc/sub\endcsname
  no
 \else 
  \ifcsname \f@encoding/\f@family/\f@series/sc\endcsname  yes \else no \fi
 \fi   
 \textsc{Aa}}
\makeatother
\begin{document}
\testsc

\bfseries \testsc 

\scshape \testsc

\end{document}

编辑2

除了修补之外,\define@newfont还可以修补\wrong@fontshape

\usepackage{etoolbox}
\makeatletter
\preto\wrong@fontshape{\expandafter\gdef\csname \curr@fontshape/sub\endcsname{}}
....

在此处输入图片描述

相关内容