This question concerns two attributes of fonts in LaTeX: series (e.g. bold extended) and shape (e.g. italic small-caps). The problem does not arise for encoding (e.g. T1) or family (e.g. yesjw).
How can I do one of the following two things?
- Determine whether the currently active font has been substituted by the kernel (or similar) and, if it has, which font has been substituted. I do not want to include substitutions defined using the macros characteristic of
.fdfiles. (It would be OK if I caught these, too, but I don't especially want to.) - Determine the real attributes of the currently active font. This is straightforward for encoding and family, but I can't figure out how to do it reliably for series or shape.
I think I must be missing something obvious, but I just can't see it. That is, I can think of ways to do one or other of the above, but I can't think of ways which play nicely with anything else at all. For example, I could undefine the current font and then try reinitialising it, resetting it to some default in case of failure, but that seems akin to bombing an anthill: unduly costly, unnecessarily destructive and of questionable effectiveness.
To see why somebody might want to determine this, consider the following MWE:
\documentclass{article} \pagestyle{empty} \begin{document} \makeatletter \def\exfs@existence#1/#2/#3/#4\@nil{#1/#2/#3/#4 : \ifcsname #1/#2/#3/#4\endcsname existent\else nonexistent\fi} \def\exfs@curr@existence{\expandafter\exfs@existence\curr@fontshape\@nil} \exfs@curr@existence \scshape\exfs@curr@existence \upshape \exfs@existence\f@encoding/\f@family/ec/\f@shape\@nil \exfs@curr@existence \fontseries{ec}\selectfont \exfs@curr@existence \exfs@existence\f@encoding/\f@family/el/\f@shape\@nil \exfs@curr@existence \fontseries{el}\selectfont \exfs@existence\f@encoding/\f@family/el/\f@shape\@nil\marginpar{??!!} \exfs@curr@existence\marginpar{??!!} \exfs@existence\f@encoding/\f@family/\f@series/sc\@nil \scshape \exfs@existence\f@encoding/\f@family/\f@series/sc\@nil\marginpar{??!!} \exfs@curr@existence\marginpar{??!!} \end{document} Note that requesting a switch to a non-existent series orthogonal to the current one is handled gracefully and it remains straightforward to retrieve the font attributes.
But requesting a switch to a non-existent series congruent with the current one causes chaos. I'm not particularly bothered about this. In particular, I do not think it is a bug unless the developers think so. But I am bothered by my inability to reliably catch it. In particular, I'd like to avoid providing commands which fail or report spurious success when they encounter it.
Note that it isn't necessary to use anything as esoteric as \fontshape{el}\selectfont to see the problem. Something as innocuous as
\normalfont\scshape \exfs@curr@existence \bfseries \exfs@curr@existence\marginpar{??!!} demonstrates the basic issue, even though the typeset result is arguably correct.
Note that this question is in relation to package support for 'traditional' fonts, so LuaTeX etc. is definitely out.
[Don't know if this is 'inner enough' for latex-base, but there doesn't seem to be a better tag available?]




OT1/cmr/el/scisn't defined in the environment (usually by the.fdfile),\ExpandArgs{c}\show{OT1/cmr/el/sc}will tell you that this is\relax. But if you do something that requests that nonexistent font, a substitution will happen and the (internal) control sequence\OT1/cmr/el/scwill be made equivalent to the one corresponding to the substitute font.\elweightcreating a font.