Closed lemzwerg closed 4 years ago
Here are my two cents on this issue: I will use \setmonofont
as an example. The commands \setmainfont
and \setsansfont
should be considered too.
\g_@@_nfss_enc_tl
and \l_@@_ttfamily_family_tl
needed during the redefinition of \ttfamily
?\fontfamily { \ttdefault }
make more sense than the current \exp_not:N \fontfamily { \l_@@_ttfamily_family_tl }
?As a reference, here is the definition of \ttfamily
in the LaTeX2e kernel:
https://github.com/latex3/latex2e/blob/c32747acdc17a30e55e374e4926bfa9680875b1d/base/ltfssini.dtx#L168-L170
Thanks both. This is almost certainly an oversight since I have:
\tl_set_eq:NN \ttdefault \l_@@_ttfamily_family_tl
first, it only makes sense to keep using \ttdefault here:
\exp_not:N \fontfamily { \l_@@_ttfamily_family_tl }
I’ll try to fix up and run some tests, but I’m afraid I’m pretty snowed under at work at the moment.
If you’d like to write some short fontspec test files for the repository I could probably patch immediately…
I’m actually quite confused why I have this code written in this way. There must have been some reason (I assume!!) that I didn’t just write something more like:
\DeclareRobustCommand \ttfamily
{
\fontencoding { \g_@@_nfss_enc_tl }
\fontfamily { \l_@@_ttfamily_family_tl }
\selectfont
}
Or maybe there was once a reason and it’s no longer applicable...
@wspr I never worked with the LaTeX3 validation system before. But guessing from the existing files, does the test file you seek look like this?
\input{fontspec-testsetup.tex}
\usepackage{fontspec}
\begin{document}
\TIMO\SEPARATOR
\MSG{SET FONT FAMILIES}
\setmainfont{texgyretermes-regular.otf}
\setsansfont{texgyreheros-regular.otf}
\setmonofont{texgyrecursor-regular.otf}
\rmfamily
\CURRNFSS
\sffamily
\CURRNFSS
\ttfamily
\CURRNFSS
\TIMO\SEPARATOR
\MSG{REDEFINE FONT FAMILIES}
\renewcommand\rmdefault{lmr}
\renewcommand\sfdefault{lmss}
\renewcommand\ttdefault{lmtt}
\rmfamily
\CURRNFSS
\sffamily
\CURRNFSS
\ttfamily
\CURRNFSS
\end{document}
@RuixiZhang42 — many thanks!!
I'm not quite sure whether I like the current solution of patching \rmfamily
and friends unconditionally (and not only if the corresponding fontspec
command has been issued) (commits 06471c9 and 127ad61). This makes it quite hard to mix Unicode and legacy fonts in a document. Consider for example this:
\documentclass{article}
\usepackage{fontspec}
\usepackage[T1]{fontenc}
\def\rmdefault{qtm}
\rmfamily
\stop
which fails to load T1/qtm
, because latex is trying to find TU/qtm
instead. (The same BTW for the MWE from the OP, if you replace lmtt
with any other font that doesn't have a TU
definition.)
@schlcht — you're right, I forgot to test this use case. Fixing this up now, thanks very much.
@schlcht — now fixed I hope.
@wspr Yes, thanks a lot for the quick response!
As discussed in https://tex.stackexchange.com/questions/512432/xelatex-libertine-renewcommand-ttdefault-no-longer-works/512548, please document that manipulation of
\ttdefault
and siblings has no influence since fontspec version 2.6.