Inconsistent formatting of \printbibliography with \textsc before
I noticed that formatting of \printbibliography changes depending of the position of \textsc before or after it. This happens when a font with no small-caps is used, e.g., tinos, paratype, etc.
\begin{filecontents}{\jobname.bib}
@misc{biblatex,
url = {https://ctan.org/pkg/biblatex},
}
\end{filecontents}
\documentclass{article}
\usepackage{tinos}
% \usepackage{paratype}
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
% \textsc{url} % uncomment to observe inconsistency
\nocite{*}\printbibliography
\textsc{url}
\end{document}
In this example url field is rendered as "URL:" and the text is rendered as "url".
If we put \textsc before \printbibliography, formatting becomes different: url field is rendered as url:, just like the text.
I expected formatting to be consistent regardless of the \textsc position. Is there a way to enforce the former behavior everywhere?
I am using the latest BibLaTeX 3.16 (r57272) from TeX Live 2020.
Thank you for reporting that issue. It seems that the code used to detect whether small caps are available in the current font
https://github.com/plk/biblatex/blob/4c0a029acf7c226daacf381957c65df1178cca49/tex/latex/biblatex/biblatex.def#L396-L400
does not work correctly in all circumstances.
In particular the csname \f@encoding/\f@family/\f@series/sc ends up defined after a \textsc call even if the font doesn't have any small caps.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tinos}
\usepackage{etoolbox}
\begin{document}
\makeatletter
\csmeaning{\f@encoding/\f@family/\f@series/sc}
\textsc{url}
\csmeaning{\f@encoding/\f@family/\f@series/sc}
\end{document}
I'm not sure if this is a recent change in LaTeX or something that has been with us for a while. I couldn't find a reliable way to check if small caps are available just now.
Thank you for a quick response! As I workaround I overrode the \mkbibacro macros as \renewcommand*{\mkbibacro}[1]{#1}.
This issue seems to be with us for a while. I observed this behavior for the first time in October 2018 or maybe even earlier. Since it is quite unlikely \textsc to be used before biblatex is imported, is it possible to test this in advance?
Since it is quite unlikely
\textscto be used beforebiblatexis imported, is it possible to test this in advance?
Yes, we could do that, but if we test any time before we actually want to print our small caps we can never be sure if we are testing the right font. (Suppose you were to use tinos only for your bibliography and the rest of the document uses lmodern. If we test at any point where lmodern is selected as the current font we find out that there are small caps, yet when we need to use them tinos is selected which doesn't have them.)
Via https://tex.stackexchange.com/q/540612/35864 I found https://tex.stackexchange.com/q/218539/35864 which shows a way to test if font features exist without substitutions getting in the way. Unfortunately, this requires patches to LaTeX kernel commands, which is always a bit tricky.